From 965187a8bb9a9b6699fc80fd3f0c737ea7d2c9e5 Mon Sep 17 00:00:00 2001 From: MikeSchaap <35368821+MikeSchaap@users.noreply.github.com> Date: Wed, 26 Jan 2022 08:48:39 +0100 Subject: [PATCH] Updated windows window/frontend to fix issue with html select positioning (#1082) * Updated windows window/frontend to fix issue with html select positioning * Moved notifyParentWindowPositionChanged to the Window struct and moved RegMsgHandler to Run * Update v2/internal/frontend/desktop/windows/window.go Co-authored-by: Lea Anthony * Moved winc.RegMsgHandler back to old location * fixed error with merge Co-authored-by: Lea Anthony --- v2/internal/frontend/desktop/windows/frontend.go | 3 ++- v2/internal/frontend/desktop/windows/window.go | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/v2/internal/frontend/desktop/windows/frontend.go b/v2/internal/frontend/desktop/windows/frontend.go index 381b96088..5c7c5c24f 100644 --- a/v2/internal/frontend/desktop/windows/frontend.go +++ b/v2/internal/frontend/desktop/windows/frontend.go @@ -116,6 +116,8 @@ func (f *Frontend) Run(ctx context.Context) error { f.WindowCenter() f.setupChromium() + f.mainWindow.notifyParentWindowPositionChanged = f.chromium.NotifyParentWindowPositionChanged + mainWindow.OnSize().Bind(func(arg *winc.Event) { f.chromium.Resize() }) @@ -133,7 +135,6 @@ func (f *Frontend) Run(ctx context.Context) error { f.frontendOptions.OnStartup(f.ctx) } }() - mainWindow.Run() mainWindow.Close() return nil diff --git a/v2/internal/frontend/desktop/windows/window.go b/v2/internal/frontend/desktop/windows/window.go index 22b82a883..cdd277ad0 100644 --- a/v2/internal/frontend/desktop/windows/window.go +++ b/v2/internal/frontend/desktop/windows/window.go @@ -16,8 +16,9 @@ import ( type Window struct { winc.Form - frontendOptions *options.App - applicationMenu *menu.Menu + frontendOptions *options.App + applicationMenu *menu.Menu + notifyParentWindowPositionChanged func() error } func NewWindow(parent winc.Controller, appoptions *options.App) *Window { @@ -89,6 +90,16 @@ func (w *Window) Run() int { } func (w *Window) WndProc(msg uint32, wparam, lparam uintptr) uintptr { + + switch msg { + case w32.WM_NCLBUTTONDOWN: + w32.SetFocus(w.Handle()) + case w32.WM_MOVE, w32.WM_MOVING: + if w.notifyParentWindowPositionChanged != nil { + w.notifyParentWindowPositionChanged() + } + } + if w.frontendOptions.Frameless { switch msg { case w32.WM_ACTIVATE: