cursor: Factor out cursor_update_common() and fix some glitches

Fix a couple of glitches seen when exiting interactive move/resize:

 - Cursor briefly set to left_ptr rather than the correct cursor image
 - Cursor not updated if the view being moved/resized is destroyed

Also make sure to exit interactive mode if the view is going fullscreen
(labwc gets very confused otherwise).

Code changes in detail:

 - Factor out set_server_cursor() which will set the correct cursor
   image for non-client areas (either XCURSOR_DEFAULT or one of the
   resize cursors).
 - Unify the logic from cursor_rebase() and process_cursor_motion by
   factoring out cursor_update_common().  This corrects some logic
   discrepancies between the two, which should be a good thing(TM).
 - Remove the extra cursor_set(XCURSOR_DEFAULT) from interactive_end()
   and instead rely on cursor_update_focus() to do the right thing.
 - Simplify cursor_button() by just calling interactive_end() when we
   want to exit interactive mode.
 - Call cursor_update_focus() from view_destroy() if the view had mouse
   focus or was being interactively moved/resized.

v2: Eliminate force_reenter parameters and figure out automatically
    when we need to re-enter the surface.
v3: Rename wlseat -> wlr_seat.
v4: Simplify client/server cursor logic.
This commit is contained in:
John Lindgren 2022-09-12 13:14:18 -04:00
parent 4ba59f7074
commit 6c6e406507
6 changed files with 129 additions and 167 deletions

View file

@ -11,7 +11,7 @@ unmanaged_handle_request_configure(struct wl_listener *listener, void *data)
wlr_xwayland_surface_configure(xsurface, ev->x, ev->y, ev->width, ev->height);
if (unmanaged->node) {
wlr_scene_node_set_position(unmanaged->node, ev->x, ev->y);
cursor_update_focus(unmanaged->server, false);
cursor_update_focus(unmanaged->server);
}
}
@ -23,7 +23,7 @@ unmanaged_handle_set_geometry(struct wl_listener *listener, void *data)
struct wlr_xwayland_surface *xsurface = unmanaged->xwayland_surface;
if (unmanaged->node) {
wlr_scene_node_set_position(unmanaged->node, xsurface->x, xsurface->y);
cursor_update_focus(unmanaged->server, false);
cursor_update_focus(unmanaged->server);
}
}
@ -51,7 +51,7 @@ unmanaged_handle_map(struct wl_listener *listener, void *data)
unmanaged->server->unmanaged_tree,
xsurface->surface)->buffer->node;
wlr_scene_node_set_position(unmanaged->node, xsurface->x, xsurface->y);
cursor_update_focus(unmanaged->server, false);
cursor_update_focus(unmanaged->server);
}
static void
@ -105,7 +105,7 @@ unmanaged_handle_unmap(struct wl_listener *listener, void *data)
seat_reset_pressed(seat);
}
unmanaged->node = NULL;
cursor_update_focus(unmanaged->server, false);
cursor_update_focus(unmanaged->server);
if (seat->seat->keyboard_state.focused_surface == xsurface->surface) {
focus_next_surface(unmanaged->server, xsurface);