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

@ -134,14 +134,7 @@ interactive_end(struct view *view)
view_snap_to_edge(view, "down");
}
}
/*
* First set the cursor image in case we moved / resized via SSD.
* Then allow an application to set its own image in case there
* is a surface below the cursor (e.g. moved / resized via 'Alt'
* modifier). If there is no surface below the cursor the second
* call is a no-op.
*/
cursor_set(&view->server->seat, XCURSOR_DEFAULT);
cursor_update_focus(view->server, true);
/* Update focus/cursor image */
cursor_update_focus(view->server);
}
}