Skip to content

Commit

Permalink
Fix crash when no displays are detected
Browse files Browse the repository at this point in the history
  • Loading branch information
msrd0 committed Oct 22, 2024
1 parent eab4298 commit 51b4e47
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

Check failure on line 41 in backend/utils/display.go

View workflow job for this annotation

GitHub Actions / lint-backend (ubuntu-latest)

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/satisfactorymodding/SatisfactoryModManager) -s blank -s dot --custom-order (gci)

Check failure on line 41 in backend/utils/display.go

View workflow job for this annotation

GitHub Actions / lint-backend (windows-latest)

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/satisfactorymodding/SatisfactoryModManager) -s blank -s dot --custom-order (gci)

Check failure on line 41 in backend/utils/display.go

View workflow job for this annotation

GitHub Actions / lint-backend (macos-latest)

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/satisfactorymodding/SatisfactoryModManager) -s blank -s dot --custom-order (gci)
}

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

0 comments on commit 51b4e47

Please sign in to comment.