mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-03 08:25:34 +00:00
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 <mail@eliasnaur.com>
This commit is contained in:
+6
-2
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user