view: Anchor right/bottom edge only when resizing via top/left edge

Currently, we anchor the right/bottom edge of the view whenever the top/
left edge is moving (current.x/y != pending.x/y). Doing so doesn't make
much sense when the right/bottom edge is also moving. In that case it's
probably best to move the view (or at least its top/left corner)
directly to its final position.

The most noticeable effect of this change is with views that don't
accept their requested size exactly when tiled or maximized (examples:
havoc, xfce4-terminal). Previously, their right-bottom corner would be
aligned with the screen edge, leaving gaps on the left and top. Now the
top-left corner will be aligned and the gaps will be on the right and
bottom. This is still not ideal, but IMHO less surprising to the user.
This commit is contained in:
John Lindgren 2023-02-25 12:05:22 -05:00 committed by Johan Malm
parent 9f00087a82
commit 0b34b9f69f
4 changed files with 77 additions and 35 deletions

View file

@ -74,31 +74,18 @@ handle_commit(struct wl_listener *listener, void *data)
wlr_xdg_surface_get_geometry(xdg_surface, &size);
struct wlr_box *current = &view->current;
struct wlr_box *pending = &view->pending;
bool update_required = false;
if (current->width != size.width || current->height != size.height) {
update_required = true;
current->width = size.width;
current->height = size.height;
}
bool update_required = current->width != size.width
|| current->height != size.height;
uint32_t serial = view->pending_configure_serial;
if (serial > 0 && serial >= xdg_surface->current.configure_serial) {
if (current->x != pending->x) {
update_required = true;
current->x = pending->x + pending->width - size.width;
}
if (current->y != pending->y) {
update_required = true;
current->y = pending->y + pending->height - size.height;
}
update_required = true;
if (serial == xdg_surface->current.configure_serial) {
view->pending_configure_serial = 0;
}
}
if (update_required) {
view_moved(view);
view_impl_apply_geometry(view, size.width, size.height);
}
}