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

@ -1433,14 +1433,11 @@ view_maximize(struct view *view, enum view_axis axis)
bool store_natural_geometry = !in_interactive_move(view);
view_set_shade(view, false);
if (axis != VIEW_AXIS_NONE) {
/*
* Maximize via keybind or client request cancels
* interactive move/resize since we can't move/resize
* a maximized view.
*/
interactive_cancel(view);
}
/*
* Maximize/unmaximize via keybind or client request cancels
* interactive move/resize.
*/
interactive_cancel(view);
/*
* Update natural geometry for any axis that wasn't already