From 63a2149a9f3c0a5c4d804f98b409398291e81632 Mon Sep 17 00:00:00 2001 From: Mike Will Date: Sun, 13 Oct 2024 16:10:16 -0400 Subject: [PATCH] snap: use unbordered box when resizing during range intersect check This makes it so that when resizing, corners will only snap when resizing *towards* the window we want to snap to. At the same time, when moving a window, tip-snapping still works because it uses the bordered box for its checks. --- src/layout/IHyprLayout.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp index 445f6fce826f..3edb8c15fc04 100644 --- a/src/layout/IHyprLayout.cpp +++ b/src/layout/IHyprLayout.cpp @@ -438,9 +438,10 @@ void snapWindows(CBox& wb, PHLWINDOW DRAGGINGWINDOW, const double oldGap, const const CBox box = other->getWindowMainSurfaceBox(); const CBox ob = {box.x, box.y, box.x + box.w, box.y + box.h}; const CBox bb = {ob.x - bord, ob.y - bord, ob.w + bord, ob.h + bord}; + const CBox& mb = mode == MBIND_RESIZE ? ob : bb; // only snap windows if their ranges intersect in the opposite axis - if (wb.y <= bb.h && bb.y <= wv.y) { + if (wb.y <= mb.h && mb.y <= wv.y) { if (c & (CORNER_TOPLEFT | CORNER_BOTTOMLEFT) && canSnap(wb.x, bb.w, gap)) { snapLeft(wb.x, wb.w, bb.w); // now check corners @@ -457,7 +458,7 @@ void snapWindows(CBox& wb, PHLWINDOW DRAGGINGWINDOW, const double oldGap, const } } - if (wb.x <= bb.w && bb.x <= wv.x) { + if (wb.x <= mb.w && mb.x <= wv.x) { if (c & (CORNER_TOPLEFT | CORNER_TOPRIGHT) && canSnap(wb.y, bb.h, gap)) { snapUp(wb.y, wb.h, bb.h); if (c & CORNER_TOPLEFT && canSnap(wb.x, ob.x, gap))