From 4e626b702892cf8f2fca3c79c6ce2c9f03f9fa7a Mon Sep 17 00:00:00 2001 From: Sohimaster Date: Sun, 22 Dec 2024 22:54:08 +0200 Subject: [PATCH 1/3] fix incorrect display bounds recognition on multiple displays if the primary display is not the first --- nix.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/nix.go b/nix.go index 7529118..133b5f9 100644 --- a/nix.go +++ b/nix.go @@ -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() @@ -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 } From 6690c51b67f2c3efad4b1fbcae35f54b6df28832 Mon Sep 17 00:00:00 2001 From: Sohimaster Date: Sun, 22 Dec 2024 22:59:07 +0200 Subject: [PATCH 2/3] update module name --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 8520db0..85acb7b 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/kbinani/screenshot +module github.com/Sohimaster/screenshot go 1.21 From 8dff4b2b3800b50db5d4ffbd854aad788cdc732f Mon Sep 17 00:00:00 2001 From: Sohimaster Date: Sun, 22 Dec 2024 23:00:36 +0200 Subject: [PATCH 3/3] Update go.mod --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 85acb7b..8520db0 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/Sohimaster/screenshot +module github.com/kbinani/screenshot go 1.21