forked from joejulian/gio
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 {
|
if c.d == nil {
|
||||||
panic("event while no driver active")
|
panic("event while no driver active")
|
||||||
}
|
}
|
||||||
|
c.waitEvents = append(c.waitEvents, e)
|
||||||
if c.busy {
|
if c.busy {
|
||||||
c.waitEvents = append(c.waitEvents, e)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.busy = true
|
c.busy = true
|
||||||
defer func() {
|
defer func() {
|
||||||
c.busy = false
|
c.busy = false
|
||||||
}()
|
}()
|
||||||
c.w.processEvent(c.d, e)
|
|
||||||
for _, e := range c.waitEvents {
|
for _, e := range c.waitEvents {
|
||||||
c.w.processEvent(c.d, e)
|
c.w.processEvent(c.d, e)
|
||||||
}
|
}
|
||||||
c.waitEvents = c.waitEvents[:0]
|
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 {
|
for _, f := range c.w.defers {
|
||||||
f(c.d)
|
f(c.d)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user