Skip to content

Commit 56a7ee7

Browse files
authored
Fix crash when no displays are detected (#259)
1 parent fbcd792 commit 56a7ee7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

backend/utils/display.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func GetDisplayBounds() []image.Rectangle {
1616
bounds = append(bounds, screenshot.GetDisplayBounds(i))
1717
}
1818

19-
if runtime.GOOS == "linux" {
19+
if runtime.GOOS == "linux" && n > 0 {
2020
// gdk_monitor_get_geometry considers 0,0 to be the corner of the bounding box of all the monitors,
2121
// not the 0,0 of the main monitor
2222
boundingBox := bounds[0]
@@ -36,7 +36,10 @@ func GetDisplayBoundsAt(x, y int) image.Rectangle {
3636

3737
displays := GetDisplayBounds()
3838

39-
curDisplay := displays[0] // use main display as fallback
39+
curDisplay := image.Rect(0, 0, 0, 0)
40+
if len(displays) > 0 {
41+
curDisplay = displays[0] // use main display as fallback
42+
}
4043

4144
for _, d := range displays {
4245
if point.In(d) {

0 commit comments

Comments
 (0)