forked from joejulian/gio
app: [Wayland] don't send events after DestroyEvent
Like a previous commit for X11, this change ensures no events are sent after DestroyEvent. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+14
-10
@@ -216,6 +216,8 @@ type window struct {
|
|||||||
|
|
||||||
wakeups chan struct{}
|
wakeups chan struct{}
|
||||||
|
|
||||||
|
closing bool
|
||||||
|
|
||||||
// invMu avoids the race between the destruction of disp and
|
// invMu avoids the race between the destruction of disp and
|
||||||
// Invalidate waking it up.
|
// Invalidate waking it up.
|
||||||
invMu sync.Mutex
|
invMu sync.Mutex
|
||||||
@@ -556,7 +558,7 @@ func gio_onXdgSurfaceConfigure(data unsafe.Pointer, wmSurf *C.struct_xdg_surface
|
|||||||
//export gio_onToplevelClose
|
//export gio_onToplevelClose
|
||||||
func gio_onToplevelClose(data unsafe.Pointer, topLvl *C.struct_xdg_toplevel) {
|
func gio_onToplevelClose(data unsafe.Pointer, topLvl *C.struct_xdg_toplevel) {
|
||||||
w := callbackLoad(data).(*window)
|
w := callbackLoad(data).(*window)
|
||||||
w.close(nil)
|
w.closing = true
|
||||||
}
|
}
|
||||||
|
|
||||||
//export gio_onToplevelConfigure
|
//export gio_onToplevelConfigure
|
||||||
@@ -1139,7 +1141,7 @@ func (w *window) Perform(actions system.Action) {
|
|||||||
walkActions(actions, func(action system.Action) {
|
walkActions(actions, func(action system.Action) {
|
||||||
switch action {
|
switch action {
|
||||||
case system.ActionClose:
|
case system.ActionClose:
|
||||||
w.close(nil)
|
w.closing = true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -1366,6 +1368,11 @@ func gio_onFrameDone(data unsafe.Pointer, callback *C.struct_wl_callback, t C.ui
|
|||||||
func (w *window) close(err error) {
|
func (w *window) close(err error) {
|
||||||
w.ProcessEvent(WaylandViewEvent{})
|
w.ProcessEvent(WaylandViewEvent{})
|
||||||
w.ProcessEvent(DestroyEvent{Err: err})
|
w.ProcessEvent(DestroyEvent{Err: err})
|
||||||
|
w.destroy()
|
||||||
|
w.invMu.Lock()
|
||||||
|
w.disp.destroy()
|
||||||
|
w.disp = nil
|
||||||
|
w.invMu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *window) dispatch() {
|
func (w *window) dispatch() {
|
||||||
@@ -1374,7 +1381,7 @@ func (w *window) dispatch() {
|
|||||||
w.w.Invalidate()
|
w.w.Invalidate()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := w.disp.dispatch(); err != nil {
|
if err := w.disp.dispatch(); err != nil || w.closing {
|
||||||
w.close(err)
|
w.close(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -1399,13 +1406,6 @@ func (w *window) Event() event.Event {
|
|||||||
w.dispatch()
|
w.dispatch()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if _, destroy := evt.(DestroyEvent); destroy {
|
|
||||||
w.destroy()
|
|
||||||
w.invMu.Lock()
|
|
||||||
w.disp.destroy()
|
|
||||||
w.disp = nil
|
|
||||||
w.invMu.Unlock()
|
|
||||||
}
|
|
||||||
return evt
|
return evt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1515,6 +1515,10 @@ func (d *wlDisplay) wakeup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *window) destroy() {
|
func (w *window) destroy() {
|
||||||
|
if w.lastFrameCallback != nil {
|
||||||
|
C.wl_callback_destroy(w.lastFrameCallback)
|
||||||
|
w.lastFrameCallback = nil
|
||||||
|
}
|
||||||
if w.cursor.surf != nil {
|
if w.cursor.surf != nil {
|
||||||
C.wl_surface_destroy(w.cursor.surf)
|
C.wl_surface_destroy(w.cursor.surf)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user