-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
128 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
//go:build !s390x && !ppc64le && !darwin && !windows && (linux || freebsd || openbsd || netbsd) | ||
|
||
package screenshot | ||
|
||
import ( | ||
"github.com/jezek/xgb" | ||
"github.com/jezek/xgb/xinerama" | ||
"image" | ||
) | ||
|
||
// NumActiveDisplays returns the number of active displays. | ||
func NumActiveDisplays() (num int) { | ||
defer func() { | ||
e := recover() | ||
if e != nil { | ||
num = 0 | ||
} | ||
}() | ||
|
||
c, err := xgb.NewConn() | ||
if err != nil { | ||
return 0 | ||
} | ||
defer c.Close() | ||
|
||
err = xinerama.Init(c) | ||
if err != nil { | ||
return 0 | ||
} | ||
|
||
reply, err := xinerama.QueryScreens(c).Reply() | ||
if err != nil { | ||
return 0 | ||
} | ||
|
||
num = int(reply.Number) | ||
return num | ||
} | ||
|
||
// 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() | ||
if e != nil { | ||
rect = image.Rectangle{} | ||
} | ||
}() | ||
|
||
c, err := xgb.NewConn() | ||
if err != nil { | ||
return image.Rectangle{} | ||
} | ||
defer c.Close() | ||
|
||
err = xinerama.Init(c) | ||
if err != nil { | ||
return image.Rectangle{} | ||
} | ||
|
||
reply, err := xinerama.QueryScreens(c).Reply() | ||
if err != nil { | ||
return image.Rectangle{} | ||
} | ||
|
||
if displayIndex >= int(reply.Number) { | ||
return image.Rectangle{} | ||
} | ||
|
||
primary := reply.ScreenInfo[0] | ||
x0 := int(primary.XOrg) | ||
y0 := int(primary.YOrg) | ||
|
||
screen := reply.ScreenInfo[displayIndex] | ||
x := int(screen.XOrg) - x0 | ||
y := int(screen.YOrg) - y0 | ||
w := int(screen.Width) | ||
h := int(screen.Height) | ||
rect = image.Rect(x, y, x+w, y+h) | ||
return rect | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//go:build freebsd | ||
|
||
package screenshot | ||
|
||
import ( | ||
"image" | ||
) | ||
|
||
// Capture returns screen capture of specified desktop region. | ||
// x and y represent distance from the upper-left corner of primary display. | ||
// Y-axis is downward direction. This means coordinates system is similar to Windows OS. | ||
func Capture(x, y, width, height int) (img *image.RGBA, e error) { | ||
return captureXinerama(x, y, width, height) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters