snap: cache and ignore last-snapped edge when growing or shrinking

When growing or shrinking a view by snapping to an edge, a client may
ignore the requested size and instead keep its original size or
substitute a different (possibly constrained) size. In this case, the
view may not actually contact the snapped edge, and a subsequent snap
attempt will just keep re-trying (and failing) to contact the same ege.

To mitigate this, remember the last-snapped view, snapping direction and
offset of the snapping edge in snap.c; when re-attempting a snap for the
same view in the same direction, ignore the edge that was last "hit", to
allow snapping to progress beyond the problematic edge.
This commit is contained in:
Andrew J. Hesford 2024-04-02 15:58:50 -04:00 committed by Johan Malm
parent 9de487cecf
commit 2bf285a2c6
11 changed files with 271 additions and 44 deletions

View file

@ -8,6 +8,7 @@
#include "decorations.h"
#include "labwc.h"
#include "node.h"
#include "snap-constraints.h"
#include "view.h"
#include "view-impl-common.h"
#include "window-rules.h"
@ -141,6 +142,7 @@ handle_commit(struct wl_listener *listener, void *data)
* actual view.
*/
if (!view->pending_configure_serial) {
snap_constraints_update(view);
view->pending = view->current;
/*
@ -188,6 +190,7 @@ handle_configure_timeout(void *data)
view->current.width, view->current.height);
/* Re-sync pending view with current state */
snap_constraints_update(view);
view->pending = view->current;
return 0; /* ignored per wl_event_loop docs */