view: expose view_set_maximized() instead of view_restore_to()

view_restore_to() (which is just set_maximized() + view_move_resize())
hasn't aged well and doesn't line up with typical usage anymore:

 - it's missing view_set_untiled(), which has to be called separately
 - it always forces view_move_resize() even when that's not needed
 - it doesn't allow un-maximizing only one axis (see next commit)
 - the fullscreen check is unnecessary (already checked in callers)

Eliminate it and just expose view_set_maximized() instead.

No functional change intended in this commit.
This commit is contained in:
John Lindgren 2025-09-01 11:49:24 -04:00 committed by Johan Malm
parent 72a5df16ea
commit 6d2140c4b7
4 changed files with 20 additions and 27 deletions

View file

@ -660,7 +660,7 @@ view_move_relative(struct view *view, int x, int y)
view_maximize(view, VIEW_AXIS_NONE, /*store_natural_geometry*/ false);
if (view_is_tiled(view)) {
view_set_untiled(view);
view_restore_to(view, view->natural_geometry);
view_move_resize(view, view->natural_geometry);
}
view_move(view, view->pending.x + x, view->pending.y + y);
}
@ -678,7 +678,7 @@ view_move_to_cursor(struct view *view)
view_maximize(view, VIEW_AXIS_NONE, /*store_natural_geometry*/ false);
if (view_is_tiled(view)) {
view_set_untiled(view);
view_restore_to(view, view->natural_geometry);
view_move_resize(view, view->natural_geometry);
}
struct border margin = ssd_thickness(view);
@ -1367,10 +1367,18 @@ view_apply_special_geometry(struct view *view)
}
}
/* For internal use only. Does not update geometry. */
static void
set_maximized(struct view *view, enum view_axis maximized)
/*
* Sets maximized state without updating geometry. Used in interactive
* move/resize. In most other cases, use view_maximize() instead.
*/
void
view_set_maximized(struct view *view, enum view_axis maximized)
{
assert(view);
if (view->maximized == maximized) {
return;
}
if (view->impl->maximize) {
view->impl->maximize(view, maximized);
}
@ -1386,23 +1394,6 @@ set_maximized(struct view *view, enum view_axis maximized)
ssd_update_margin(view->ssd);
}
/*
* Un-maximize view and move it to specific geometry. Does not reset
* tiled state (use view_set_untiled() if you want that).
*/
void
view_restore_to(struct view *view, struct wlr_box geometry)
{
assert(view);
if (view->fullscreen) {
return;
}
if (view->maximized != VIEW_AXIS_NONE) {
set_maximized(view, VIEW_AXIS_NONE);
}
view_move_resize(view, geometry);
}
bool
view_is_tiled(struct view *view)
{
@ -1505,7 +1496,7 @@ view_maximize(struct view *view, enum view_axis axis,
view->natural_geometry = view_get_fallback_natural_geometry(view);
}
set_maximized(view, axis);
view_set_maximized(view, axis);
if (view_is_floating(view)) {
view_apply_natural_geometry(view);
} else {