From 65078cdece5ce63e3d1f015c91ee87635eacdd59 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Sun, 7 Jun 2020 14:48:54 +0200 Subject: [PATCH] app/internal/window: [macOS] simplify NewWindow Signed-off-by: Elias Naur --- app/internal/window/os_macos.go | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/app/internal/window/os_macos.go b/app/internal/window/os_macos.go index d3d5b605..6ca473f7 100644 --- a/app/internal/window/os_macos.go +++ b/app/internal/window/os_macos.go @@ -292,26 +292,23 @@ func gio_onFinishLaunching() { func NewWindow(win Callbacks, opts *Options) error { <-launched errch := make(chan error) - var window *window runOnMain(func() { w, err := newWindow(win, opts) - window = w - errch <- err - }) - if err := <-errch; err != nil { - return err - } - runOnMain(func() { + if err != nil { + errch <- err + return + } // Window sizes is in unscaled screen coordinates, not device pixels. cfg := configFor(1.0) width := cfg.Px(opts.Width) height := cfg.Px(opts.Height) title := C.CString(opts.Title) defer C.free(unsafe.Pointer(title)) - nextTopLeft = C.gio_createWindow(window.view, title, C.CGFloat(width), C.CGFloat(height), nextTopLeft) - win.SetDriver(window) + errch <- nil + nextTopLeft = C.gio_createWindow(w.view, title, C.CGFloat(width), C.CGFloat(height), nextTopLeft) + win.SetDriver(w) }) - return nil + return <-errch } func newWindow(win Callbacks, opts *Options) (*window, error) {