diff --git a/v2/internal/frontend/desktop/windows/window.go b/v2/internal/frontend/desktop/windows/window.go index d6c8d42e..6e765fc9 100644 --- a/v2/internal/frontend/desktop/windows/window.go +++ b/v2/internal/frontend/desktop/windows/window.go @@ -7,15 +7,12 @@ import ( "github.com/leaanthony/winc/w32" "github.com/wailsapp/wails/v2/pkg/menu" "github.com/wailsapp/wails/v2/pkg/options" - "sync" ) type Window struct { winc.Form frontendOptions *options.App applicationMenu *menu.Menu - m sync.Mutex - dispatchq []func() } func NewWindow(parent winc.Controller, appoptions *options.App) *Window { @@ -86,32 +83,9 @@ func NewWindow(parent winc.Controller, appoptions *options.App) *Window { } func (w *Window) Run() int { - var m w32.MSG - - for w32.GetMessage(&m, 0, 0, 0) != 0 { - if m.Message == w32.WM_APP { - // Credit: https://github.com/jchv/go-webview2 - w.m.Lock() - q := append([]func(){}, w.dispatchq...) - w.dispatchq = []func(){} - w.m.Unlock() - for _, v := range q { - v() - } - } - if !w.PreTranslateMessage(&m) { - w32.TranslateMessage(&m) - w32.DispatchMessage(&m) - } - } - - w32.GdiplusShutdown() - return int(m.WParam) + return winc.RunMainLoop() } func (w *Window) Dispatch(f func()) { - w.m.Lock() - w.dispatchq = append(w.dispatchq, f) - w.m.Unlock() - w32.PostMainThreadMessage(w32.WM_APP, 0, 0) + w.Invoke(f) }