diff options
| author | Marinus Klasen <marinus@mklasen.nl> | 2026-08-19 21:05:34 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2026-08-29 07:55:45 +0000 |
| commit | f8a367896a57d84967d7b537ee618aae8081e2ea (patch) | |
| tree | 2137909a2e6b2b5f3a943f36f5b023e75eb15a4d | |
| parent | wayland: handle_global_remove(): call wl_fixes::ack_global_remove(), when available (diff) | |
wayland: clear touch focus in wayl_win_destroy()
wl_touch has no leave event, so unmapping the surfaces cannot drop touch
focus the way it drops keyboard and pointer focus. seat->touch.surface
kept pointing at the window being destroyed, and seat->touch.state stayed
HELD/DRAGGING, so the guard in wl_touch_up() and wl_touch_motion() did not
fire. A wl_touch.up dispatched from the roundtrips in wayl_win_destroy()
then dereferenced the freed window:
#0 wl_touch_up () at input.c:3587
#12 wayl_roundtrip () at wayland.c:2416
#13 wayl_win_destroy () at wayland.c:2297
Reproduced by touching a foot window and holding while the window is
destroyed: 3/3 crashes before, 0/7 after.
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | wayland.c | 17 |
2 files changed, 18 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 67b64049..24d0b840 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -137,6 +137,7 @@ * Crash in `select-quote` when the right-side quote appeared right after a newline, in column 0 ([#2405][2405]). * Resizing a terminal window may break current selection. +* Crash when closing a window that touch input focus. [2353]: https://codeberg.org/dnkl/foot/issues/2353 [2352]: https://codeberg.org/dnkl/foot/issues/2352 @@ -2235,6 +2235,23 @@ wayl_win_destroy(struct wl_window *win) close(win->csd.move_timeout_fd); /* + * wl_touch has no leave event, so the unmapping below cannot drop touch + * focus the way it drops keyboard and pointer focus. Reset it here, or a + * wl_touch.up/motion dispatched from the roundtrips below runs against + * this window after it has been destroyed. + */ + tll_foreach(term->wl->seats, it) { + struct seat *seat = &it->item; + + if (seat->touch.surface != NULL && + wl_surface_get_user_data(seat->touch.surface) == win) + { + seat->touch.state = TOUCH_STATE_IDLE; + seat->touch.surface = NULL; + } + } + + /* * First, unmap all surfaces to trigger things like * keyboard_leave() and wl_pointer_leave(). * |
