app: delay Window.Close until after event processing

The fix for #340, b2a99fddca, deferred
all driver functions until after event processing. Deferring functions
breaks Window.Run which expects to complete during event processing.
This change is an alternative, more targeted fix, namely deferring just
Window.Close until after event processing.

A follow-up will revert the previous fix.

References: https://todo.sr.ht/~eliasnaur/gio/340
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2022-01-29 13:30:23 +01:00
parent 7648a5e381
commit f23a4f8452
+6 -1
View File
@@ -54,6 +54,7 @@ type Window struct {
out chan event.Event
frames chan *op.Ops
frameAck chan struct{}
closing bool
// dead is closed when the window is destroyed.
dead chan struct{}
@@ -326,7 +327,7 @@ func (w *Window) SetCursorName(name pointer.CursorName) {
// all others are stubbed.
func (w *Window) Close() {
w.driverDefer(func(d driver) {
d.Close()
w.closing = true
})
}
@@ -429,6 +430,10 @@ func (c *callbacks) Event(e event.Event) {
}
c.w.defers = c.w.defers[:0]
c.w.updateState(c.d)
if c.w.closing {
c.w.closing = false
c.d.Close()
}
}
// SemanticRoot returns the ID of the semantic root.