Skip to content

Commit

Permalink
Fix crash when no displays are detected (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
msrd0 authored Oct 22, 2024
1 parent fbcd792 commit 56a7ee7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions backend/utils/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func GetDisplayBounds() []image.Rectangle {
bounds = append(bounds, screenshot.GetDisplayBounds(i))
}

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

displays := GetDisplayBounds()

curDisplay := displays[0] // use main display as fallback
curDisplay := image.Rect(0, 0, 0, 0)
if len(displays) > 0 {
curDisplay = displays[0] // use main display as fallback
}

for _, d := range displays {
if point.In(d) {
Expand Down

0 comments on commit 56a7ee7

Please sign in to comment.