aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--wayland.c17
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
diff --git a/wayland.c b/wayland.c
index 7d81b486..f15c1687 100644
--- a/wayland.c
+++ b/wayland.c
@@ -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().
*