mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 18:35:34 +00:00
app: [macOS] ensure the Window is initalized before Run functions
Don't call eventLoop.FlushEvents which in turn applies Options and executes Run functions before the window is fully initialized. References: https://todo.sr.ht/~eliasnaur/gio/575 Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+7
-2
@@ -326,6 +326,7 @@ type window struct {
|
|||||||
cursor pointer.Cursor
|
cursor pointer.Cursor
|
||||||
pointerBtns pointer.Buttons
|
pointerBtns pointer.Buttons
|
||||||
loop *eventLoop
|
loop *eventLoop
|
||||||
|
initialized bool
|
||||||
|
|
||||||
scale float32
|
scale float32
|
||||||
config Config
|
config Config
|
||||||
@@ -833,7 +834,9 @@ func (w *window) draw() {
|
|||||||
|
|
||||||
func (w *window) ProcessEvent(e event.Event) {
|
func (w *window) ProcessEvent(e event.Event) {
|
||||||
w.w.ProcessEvent(e)
|
w.w.ProcessEvent(e)
|
||||||
w.loop.FlushEvents()
|
if w.initialized {
|
||||||
|
w.loop.FlushEvents()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *window) Event() event.Event {
|
func (w *window) Event() event.Event {
|
||||||
@@ -924,7 +927,6 @@ func newWindow(win *callbacks, options []Option) {
|
|||||||
}
|
}
|
||||||
w.loop = newEventLoop(w.w, w.wakeup)
|
w.loop = newEventLoop(w.w, w.wakeup)
|
||||||
win.SetDriver(w)
|
win.SetDriver(w)
|
||||||
res <- struct{}{}
|
|
||||||
if err := w.init(); err != nil {
|
if err := w.init(); err != nil {
|
||||||
w.ProcessEvent(DestroyEvent{Err: err})
|
w.ProcessEvent(DestroyEvent{Err: err})
|
||||||
return
|
return
|
||||||
@@ -942,6 +944,9 @@ func newWindow(win *callbacks, options []Option) {
|
|||||||
nextTopLeft = C.cascadeTopLeftFromPoint(window, nextTopLeft)
|
nextTopLeft = C.cascadeTopLeftFromPoint(window, nextTopLeft)
|
||||||
// makeKeyAndOrderFront assumes ownership of our window reference.
|
// makeKeyAndOrderFront assumes ownership of our window reference.
|
||||||
C.makeKeyAndOrderFront(window)
|
C.makeKeyAndOrderFront(window)
|
||||||
|
w.initialized = true
|
||||||
|
res <- struct{}{}
|
||||||
|
w.loop.FlushEvents()
|
||||||
})
|
})
|
||||||
<-res
|
<-res
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user