feat(ui): нативный максимум окна через Win32 (над панелью задач)
This commit is contained in:
48
internal/ui/desktop/maximize_windows.go
Normal file
48
internal/ui/desktop/maximize_windows.go
Normal 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)
|
||||
}
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user