From 1bad440ef60429b62a30145b712a6e618f748bd1 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Thu, 27 Jan 2022 12:13:20 +0100 Subject: [PATCH] app: ensure deferred functions are run outside of FrameEvents Simplify callbacks.Event a bit while here. Fixes: https://todo.sr.ht/~eliasnaur/gio/348 Signed-off-by: Elias Naur --- app/window.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/window.go b/app/window.go index 8a4259d3..d4f450a6 100644 --- a/app/window.go +++ b/app/window.go @@ -398,19 +398,23 @@ func (c *callbacks) Event(e event.Event) { if c.d == nil { panic("event while no driver active") } + c.waitEvents = append(c.waitEvents, e) if c.busy { - c.waitEvents = append(c.waitEvents, e) return } c.busy = true defer func() { c.busy = false }() - c.w.processEvent(c.d, e) for _, e := range c.waitEvents { c.w.processEvent(c.d, e) } c.waitEvents = c.waitEvents[:0] + select { + case f := <-c.w.driverFuncs: + c.w.defers = append(c.w.defers, f) + default: + } for _, f := range c.w.defers { f(c.d) }