mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-08-12 09:34:05 +08:00
- 关闭时隐藏保活,重开复用现有进程并通过可见性版本消除竞态 - 拆分 AI 与工作台资源,使用启动状态白名单减少序列化开销 - 修复设置中心层级、Windows 前台切换及独立窗口关闭交互 - 补齐状态同步、断线重放与窗口生命周期回归测试
29 lines
703 B
Go
29 lines
703 B
Go
//go:build windows
|
|
|
|
package nativewindow
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"golang.org/x/sys/windows"
|
|
)
|
|
|
|
var allowSetForegroundWindowProc = windows.NewLazySystemDLL("user32.dll").NewProc("AllowSetForegroundWindow")
|
|
|
|
var allowSetForegroundWindow = func(processID uint32) bool {
|
|
result, _, _ := allowSetForegroundWindowProc.Call(uintptr(processID))
|
|
return result != 0
|
|
}
|
|
|
|
func grantParentForegroundAccess() error {
|
|
parentProcessID := os.Getppid()
|
|
if parentProcessID <= 0 {
|
|
return fmt.Errorf("invalid parent process ID %d", parentProcessID)
|
|
}
|
|
if !allowSetForegroundWindow(uint32(parentProcessID)) {
|
|
return fmt.Errorf("AllowSetForegroundWindow rejected parent process %d", parentProcessID)
|
|
}
|
|
return nil
|
|
}
|