mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 18:05:35 +00:00
app: [Windows] ensure the Window is initalized before Run functions
Like the previous commit for macOS, this defers event processing until after the Window is ready. Fixes: https://todo.sr.ht/~eliasnaur/gio/575 Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+8
-3
@@ -49,7 +49,8 @@ type window struct {
|
|||||||
// placement saves the previous window position when in full screen mode.
|
// placement saves the previous window position when in full screen mode.
|
||||||
placement *windows.WindowPlacement
|
placement *windows.WindowPlacement
|
||||||
|
|
||||||
animating bool
|
animating bool
|
||||||
|
initialized bool
|
||||||
|
|
||||||
borderSize image.Point
|
borderSize image.Point
|
||||||
config Config
|
config Config
|
||||||
@@ -104,7 +105,6 @@ func newWindow(win *callbacks, options []Option) {
|
|||||||
w.loop = newEventLoop(w.w, w.wakeup)
|
w.loop = newEventLoop(w.w, w.wakeup)
|
||||||
w.w.SetDriver(w)
|
w.w.SetDriver(w)
|
||||||
err := w.init()
|
err := w.init()
|
||||||
done <- struct{}{}
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.ProcessEvent(DestroyEvent{Err: err})
|
w.ProcessEvent(DestroyEvent{Err: err})
|
||||||
return
|
return
|
||||||
@@ -118,6 +118,9 @@ func newWindow(win *callbacks, options []Option) {
|
|||||||
// Since the window class for the cursor is null,
|
// Since the window class for the cursor is null,
|
||||||
// set it here to show the cursor.
|
// set it here to show the cursor.
|
||||||
w.SetCursor(pointer.CursorDefault)
|
w.SetCursor(pointer.CursorDefault)
|
||||||
|
w.initialized = true
|
||||||
|
done <- struct{}{}
|
||||||
|
w.loop.FlushEvents()
|
||||||
w.runLoop()
|
w.runLoop()
|
||||||
}()
|
}()
|
||||||
<-done
|
<-done
|
||||||
@@ -600,7 +603,9 @@ func (w *window) SetAnimating(anim bool) {
|
|||||||
|
|
||||||
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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user