Backported handling view unmap while grabbed from tinywl

This commit is contained in:
Keith Bowes 2022-11-09 23:09:45 -05:00
parent 18950eb844
commit 4f0f564e27
3 changed files with 9 additions and 1 deletions

View file

@ -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 */

View file

@ -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);

View file

@ -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);