Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Incorrect Display Bounds Calculation for Linux #33

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions nix.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ func NumActiveDisplays() (num int) {
}

// GetDisplayBounds returns the bounds of displayIndex'th display.
// The main display is displayIndex = 0.
func GetDisplayBounds(displayIndex int) (rect image.Rectangle) {
defer func() {
e := recover()
Expand Down Expand Up @@ -67,15 +66,14 @@ func GetDisplayBounds(displayIndex int) (rect image.Rectangle) {
return image.Rectangle{}
}

primary := reply.ScreenInfo[0]
x0 := int(primary.XOrg)
y0 := int(primary.YOrg)

// Retrieve the screen info for the target display
screen := reply.ScreenInfo[displayIndex]
x := int(screen.XOrg) - x0
y := int(screen.YOrg) - y0
x := int(screen.XOrg)
y := int(screen.YOrg)
w := int(screen.Width)
h := int(screen.Height)

// Use absolute coordinates without offsets
rect = image.Rect(x, y, x+w, y+h)
return rect
}