interactive: set grab parameters at cursor press

Add interactive_set_grab_context() which is called when the mouse button
is first pressed, before interactive_begin(). This fixes two small issues:

- The cursor origin position for interactive move/resize was slightly
  off (depending on mouse resolution), because it was set after the
  mouse had already moved slightly. Now it's exact.

- If app- or keybind-initiated maximize (etc.) happened after the button
  press but before the mouse was moved, then interactive_begin() would
  still start move/resize even though the view might now be far away
  from the cursor. Now interactive_cancel() works as expected, even if
  called before interactive_begin().

Also, make sure to call interactive_cancel() for un-maximize as well.
This commit is contained in:
John Lindgren 2026-02-09 23:49:42 -05:00 committed by Johan Malm
parent 3ea46ba45a
commit a672e8a9fd
7 changed files with 90 additions and 36 deletions

View file

@ -1147,6 +1147,7 @@ cursor_process_button_press(struct seat *seat, uint32_t button, uint32_t time_ms
if (ctx.view || ctx.surface) {
/* Store cursor context for later action processing */
cursor_context_save(&seat->pressed, &ctx);
interactive_set_grab_context(&ctx);
}
if (server->input_mode == LAB_INPUT_STATE_MENU) {
@ -1277,6 +1278,9 @@ cursor_finish_button_release(struct seat *seat, uint32_t button)
/* Exit interactive move/resize mode */
interactive_finish(server->grabbed_view);
return true;
} else if (server->grabbed_view) {
/* Button was released without starting move/resize */
interactive_cancel(server->grabbed_view);
}
return false;