-
Notifications
You must be signed in to change notification settings - Fork 211
Expand file tree
/
Copy pathwindows_ge1.21.go
More file actions
37 lines (32 loc) · 846 Bytes
/
windows_ge1.21.go
File metadata and controls
37 lines (32 loc) · 846 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//go:build windows && go1.21
package screenshot
import (
"image"
"runtime"
"syscall"
"unsafe"
"github.com/lxn/win"
)
func NumActiveDisplays() int {
count := new(int)
pinner := new(runtime.Pinner)
pinner.Pin(count)
defer pinner.Unpin()
*count = 0
ptr := unsafe.Pointer(count)
enumDisplayMonitors(win.HDC(0), nil, syscall.NewCallback(countupMonitorCallback), uintptr(ptr))
return *count
}
func GetDisplayBounds(displayIndex int) image.Rectangle {
ctx := new(getMonitorBoundsContext)
pinner := new(runtime.Pinner)
pinner.Pin(ctx)
defer pinner.Unpin()
ctx.Index = displayIndex
ctx.Count = 0
ptr := unsafe.Pointer(ctx)
enumDisplayMonitors(win.HDC(0), nil, syscall.NewCallback(getMonitorBoundsCallback), uintptr(ptr))
return image.Rect(
int(ctx.Rect.Left), int(ctx.Rect.Top),
int(ctx.Rect.Right), int(ctx.Rect.Bottom))
}