diff --git a/include/waybox/cursor.h b/include/waybox/cursor.h index 38af5ad..8468835 100644 --- a/include/waybox/cursor.h +++ b/include/waybox/cursor.h @@ -30,5 +30,6 @@ struct wb_cursor { struct wb_cursor *wb_cursor_create(struct wb_server *server); void wb_cursor_destroy(struct wb_cursor *cursor); +void reset_cursor_mode(struct wb_server *server); #endif /* cursor.h */ diff --git a/waybox/cursor.c b/waybox/cursor.c index 2adf32c..b1d604e 100644 --- a/waybox/cursor.c +++ b/waybox/cursor.c @@ -1,6 +1,12 @@ #include "waybox/cursor.h" #include "waybox/xdg_shell.h" +void reset_cursor_mode(struct wb_server *server) { + /* Reset the cursor mode to passthrough */ + server->cursor->cursor_mode = WB_CURSOR_PASSTHROUGH; + server->grabbed_view = NULL; +} + static void process_cursor_move(struct wb_server *server) { /* Move the grabbed view to the new position. */ struct wb_view *view = server->grabbed_view; @@ -161,7 +167,7 @@ static void handle_cursor_button(struct wl_listener *listener, void *data) { cursor->server->cursor->cursor->x, cursor->server->cursor->cursor->y, &surface, &sx, &sy); if (event->state == WLR_BUTTON_RELEASED) { /* If you released any buttons, we exit interactive move/resize mode. */ - cursor->cursor_mode = WB_CURSOR_PASSTHROUGH; + reset_cursor_mode(cursor->server); } else { /* Focus that client if the button was _pressed_ */ focus_view(view, surface); diff --git a/waybox/xdg_shell.c b/waybox/xdg_shell.c index 1acbc59..196b78a 100644 --- a/waybox/xdg_shell.c +++ b/waybox/xdg_shell.c @@ -170,6 +170,7 @@ static void xdg_toplevel_unmap(struct wl_listener *listener, void *data) { struct wb_view *view = wl_container_of(listener, view, unmap); if (view->xdg_toplevel->base->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) return; + reset_cursor_mode(view->server); /* Focus the next view, if any. */ struct wb_view *next_view = wl_container_of(view->link.next, next_view, link);