chore: release v0.21.3
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
//go:build windows
|
||||
|
||||
package main
|
||||
|
||||
import "syscall"
|
||||
|
||||
// GetSystemMetrics indices for the virtual desktop — the rectangle spanning
|
||||
// every attached monitor. Wails' ScreenGetAll reports each monitor's size but
|
||||
// not its offset, so it cannot answer "is this coordinate on any screen?"; the
|
||||
// Win32 metrics can.
|
||||
const (
|
||||
smXVirtualScreen = 76
|
||||
smYVirtualScreen = 77
|
||||
smCXVirtualScreen = 78
|
||||
smCYVirtualScreen = 79
|
||||
)
|
||||
|
||||
var (
|
||||
user32Dll = syscall.NewLazyDLL("user32.dll")
|
||||
procGetSystemMetrics = user32Dll.NewProc("GetSystemMetrics")
|
||||
)
|
||||
|
||||
func systemMetric(index int) int {
|
||||
r, _, _ := procGetSystemMetrics.Call(uintptr(index))
|
||||
return int(int32(r)) // signed: the virtual desktop origin is negative with a monitor to the left
|
||||
}
|
||||
|
||||
// virtualScreenBounds returns the rectangle covering all monitors, and whether
|
||||
// it could be determined at all.
|
||||
func virtualScreenBounds() (x, y, w, h int, ok bool) {
|
||||
w, h = systemMetric(smCXVirtualScreen), systemMetric(smCYVirtualScreen)
|
||||
if w <= 0 || h <= 0 {
|
||||
return 0, 0, 0, 0, false
|
||||
}
|
||||
return systemMetric(smXVirtualScreen), systemMetric(smYVirtualScreen), w, h, true
|
||||
}
|
||||
Reference in New Issue
Block a user