feat(ui): нативный максимум окна через Win32 (над панелью задач)
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

This commit is contained in:
ki.sagidullin
2026-08-21 20:14:43 +05:00
parent 180afb1336
commit 37cc29e4cd
2 changed files with 49 additions and 1 deletions

View File

@@ -0,0 +1,48 @@
//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)
}

View File

@@ -72,7 +72,6 @@ func New(appID string, store ui.Store) *Window {
tabSession: map[*container.TabItem]*ui.Session{},
}
w.win = fa.NewWindow("Ratatoskr")
w.win.SetFullScreen(true)
w.build()
w.win.SetCloseIntercept(func() {
// Закрытие окна = сворачивание (спец 12.6): Core продолжает работать.
@@ -325,6 +324,7 @@ func (w *Window) OnMessage(h chat.Handler) { w.handler = h }
// Run показывает окно и запускает Fyne-цикл. Блокирует до Quit.
func (w *Window) Run(ctx context.Context) error {
w.win.Show()
maximizeWindow()
go func() {
<-ctx.Done()
w.fyneApp.Quit()