aboutsummaryrefslogtreecommitdiff
path: root/tinywl/tinywl.c
diff options
context:
space:
mode:
authorKirill Primak <vyivel@eclair.cafe>2022-11-07 19:55:40 +0300
committerKirill Primak <vyivel@eclair.cafe>2022-11-07 20:09:25 +0300
commitb7623694ac5cde4cec8e434ee329b84712fcb965 (patch)
tree01c2d7b823a9f4d9dc02a18f2e8ed0dfd147ad04 /tinywl/tinywl.c
parentea68506b737e459a9856fba85c38ab55c681b0b7 (diff)
tinywl: handle view unmap while grabbed
Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3372
Diffstat (limited to 'tinywl/tinywl.c')
-rw-r--r--tinywl/tinywl.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/tinywl/tinywl.c b/tinywl/tinywl.c
index 4fc8477c..7e3c8c1e 100644
--- a/tinywl/tinywl.c
+++ b/tinywl/tinywl.c
@@ -363,6 +363,12 @@ static struct tinywl_view *desktop_view_at(
return tree->node.data;
}
+static void reset_cursor_mode(struct tinywl_server *server) {
+ /* Reset the cursor mode to passthrough. */
+ server->cursor_mode = TINYWL_CURSOR_PASSTHROUGH;
+ server->grabbed_view = NULL;
+}
+
static void process_cursor_move(struct tinywl_server *server, uint32_t time) {
/* Move the grabbed view to the new position. */
struct tinywl_view *view = server->grabbed_view;
@@ -515,7 +521,7 @@ static void server_cursor_button(struct wl_listener *listener, void *data) {
server->cursor->x, server->cursor->y, &surface, &sx, &sy);
if (event->state == WLR_BUTTON_RELEASED) {
/* If you released any buttons, we exit interactive move/resize mode. */
- server->cursor_mode = TINYWL_CURSOR_PASSTHROUGH;
+ reset_cursor_mode(server);
} else {
/* Focus that client if the button was _pressed_ */
focus_view(view, surface);
@@ -636,6 +642,11 @@ static void xdg_toplevel_unmap(struct wl_listener *listener, void *data) {
/* Called when the surface is unmapped, and should no longer be shown. */
struct tinywl_view *view = wl_container_of(listener, view, unmap);
+ /* Reset the cursor mode if the grabbed view was unmapped. */
+ if (view == view->server->grabbed_view) {
+ reset_cursor_mode(view->server);
+ }
+
wl_list_remove(&view->link);
}