Files
ratatoskr-go/internal/ui/desktop/maximize_windows.go
ki.sagidullin 37cc29e4cd
Some checks failed
CI / test (push) Failing after 1m20s
CI / build-and-package (amd64, linux) (push) Failing after 1m4s
CI / build-and-package (amd64, windows) (push) Successful in 29s
feat(ui): нативный максимум окна через Win32 (над панелью задач)
2026-08-21 20:14:43 +05:00

49 lines
1.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//go:build cgo
package desktop
import (
"os"
"syscall"
"unsafe"
)
// Нативный максимум окна через Win32.
//
// Fyne (v2.6) не даёт ни Move, ни Maximize у fyne.Window, поэтому разворот на
// экран (над панелью задач) делаем напрямую через user32: находим HWND нашего
// процесса через EnumWindows и вызываем ShowWindow(SW_MAXIMIZE).
// Только Windows (платформа приложения по спеке — Windows).
const (
swMaximize = 9
)
var (
user32 = syscall.NewLazyDLL("user32.dll")
procEnumWindows = user32.NewProc("EnumWindows")
procGetWindowThreadProcID = user32.NewProc("GetWindowThreadProcessId")
procIsWindowVisible = user32.NewProc("IsWindowVisible")
procShowWindow = user32.NewProc("ShowWindow")
)
func maximizeWindow() {
pid := uint32(os.Getpid())
cb := syscall.NewCallback(func(hwnd syscall.Handle, _ uintptr) uintptr {
var winPid uint32
procGetWindowThreadProcID.Call(uintptr(hwnd), uintptr(unsafe.Pointer(&winPid)))
if winPid != pid {
return 1 // continue перечисление
}
visible, _, _ := procIsWindowVisible.Call(uintptr(hwnd))
if visible == 0 {
return 1 // continue перечисление
}
procShowWindow.Call(uintptr(hwnd), swMaximize)
return 0 // остановить перечисление
})
procEnumWindows.Call(cb, 0)
}