diff --git a/v2/internal/frontend/desktop/windows/frontend.go b/v2/internal/frontend/desktop/windows/frontend.go index 13d568b8..537cf771 100644 --- a/v2/internal/frontend/desktop/windows/frontend.go +++ b/v2/internal/frontend/desktop/windows/frontend.go @@ -40,11 +40,10 @@ type Frontend struct { startURL string // main window handle - mainWindow *Window - minWidth, minHeight, maxWidth, maxHeight int - bindings *binding.Bindings - dispatcher frontend.Dispatcher - servingFromDisk bool + mainWindow *Window + bindings *binding.Bindings + dispatcher frontend.Dispatcher + servingFromDisk bool hasStarted bool } @@ -57,10 +56,6 @@ func NewFrontend(ctx context.Context, appoptions *options.App, myLogger *logger. bindings: appBindings, dispatcher: dispatcher, ctx: ctx, - minHeight: appoptions.MinHeight, - minWidth: appoptions.MinWidth, - maxHeight: appoptions.MaxHeight, - maxWidth: appoptions.MaxWidth, startURL: "file://wails/", } @@ -171,8 +166,6 @@ func (f *Frontend) WindowSetTitle(title string) { func (f *Frontend) WindowFullscreen() { runtime.LockOSThread() - f.mainWindow.SetMaxSize(0, 0) - f.mainWindow.SetMinSize(0, 0) if f.frontendOptions.Frameless && f.frontendOptions.DisableResize == false { f.ExecJS("window.wails.flags.enableResize = false;") } @@ -185,8 +178,6 @@ func (f *Frontend) WindowUnFullscreen() { f.ExecJS("window.wails.flags.enableResize = true;") } f.mainWindow.UnFullscreen() - f.mainWindow.SetMaxSize(f.maxWidth, f.maxHeight) - f.mainWindow.SetMinSize(f.minWidth, f.minHeight) } func (f *Frontend) WindowShow() { @@ -227,14 +218,10 @@ func (f *Frontend) WindowUnminimise() { func (f *Frontend) WindowSetMinSize(width int, height int) { runtime.LockOSThread() - f.minWidth = width - f.minHeight = height f.mainWindow.SetMinSize(width, height) } func (f *Frontend) WindowSetMaxSize(width int, height int) { runtime.LockOSThread() - f.maxWidth = width - f.maxHeight = height f.mainWindow.SetMaxSize(width, height) } diff --git a/v2/internal/frontend/desktop/windows/window.go b/v2/internal/frontend/desktop/windows/window.go index f89abb19..690bfe63 100644 --- a/v2/internal/frontend/desktop/windows/window.go +++ b/v2/internal/frontend/desktop/windows/window.go @@ -16,14 +16,20 @@ import ( type Window struct { winc.Form - frontendOptions *options.App - applicationMenu *menu.Menu - notifyParentWindowPositionChanged func() error + frontendOptions *options.App + applicationMenu *menu.Menu + notifyParentWindowPositionChanged func() error + minWidth, minHeight, maxWidth, maxHeight int } func NewWindow(parent winc.Controller, appoptions *options.App) *Window { - result := new(Window) - result.frontendOptions = appoptions + result := &Window{ + frontendOptions: appoptions, + minHeight: appoptions.MinHeight, + minWidth: appoptions.MinWidth, + maxHeight: appoptions.MaxHeight, + maxWidth: appoptions.MaxWidth, + } result.SetIsForm(true) var exStyle int @@ -89,6 +95,33 @@ func (w *Window) Run() int { return winc.RunMainLoop() } +func (w *Window) Fullscreen() { + w.Form.SetMaxSize(0, 0) + w.Form.SetMinSize(0, 0) + w.Form.Fullscreen() +} + +func (w *Window) UnFullscreen() { + if !w.IsFullScreen() { + return + } + w.Form.UnFullscreen() + w.SetMinSize(w.minWidth, w.minHeight) + w.SetMaxSize(w.maxWidth, w.maxHeight) +} + +func (w *Window) SetMinSize(minWidth int, minHeight int) { + w.minWidth = minWidth + w.minHeight = minHeight + w.Form.SetMinSize(minWidth, minHeight) +} + +func (w *Window) SetMaxSize(maxWidth int, maxHeight int) { + w.maxWidth = maxWidth + w.maxHeight = maxHeight + w.Form.SetMaxSize(maxWidth, maxHeight) +} + func (w *Window) WndProc(msg uint32, wparam, lparam uintptr) uintptr { switch msg {