fix: bind Cua pixel actions to current screenshot geometry
Correct native scroll scaling, reject stale or out-of-bounds pixel targets, and scope DPI awareness to geometry reads. Package adapter 0.36.0+artemis.3 and document the high-effort cross-device verification. Validation: Go tests and vet, packaged MCP schema and handshake, Python checks, and user-run high-effort task completed with a passed verdict and explicit coverage limits.
This commit is contained in:
1 parent
9c98b6bf8a
commit
889a951c9b
13 files changed
+363
-19
No files matched your search
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
@@ -12,7 +13,6 @@ var kernel32 = syscall.NewLazyDLL("kernel32.dll")
|
||||
|
||||
func configureProcess(c *exec.Cmd) {
|
||||
c.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
|
||||
user32.NewProc("SetThreadDpiAwarenessContext").Call(^uintptr(3))
|
||||
}
|
||||
func windowOwned(pid, hwnd int64) bool {
|
||||
var actual uint32
|
||||
@@ -24,6 +24,17 @@ func windowOwned(pid, hwnd int64) bool {
|
||||
return int64(actual) == pid
|
||||
}
|
||||
func verifyWindow(pid, hwnd int64, b obj) (obj, bool) {
|
||||
// DPI context belongs to an OS thread, not a Go goroutine. Apply it around
|
||||
// the actual geometry reads; setting it once while starting a child leaks
|
||||
// context and later GetSystemMetrics can return virtualized dimensions.
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
setDPI := user32.NewProc("SetThreadDpiAwarenessContext")
|
||||
previous, _, _ := setDPI.Call(^uintptr(3))
|
||||
if previous == 0 {
|
||||
return nil, false
|
||||
}
|
||||
defer setDPI.Call(previous)
|
||||
if !windowOwned(pid, hwnd) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user