Skip to content

Commit

Permalink
snap: use unbordered box when resizing during range intersect check
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
myQwil committed Oct 13, 2024
1 parent c50ed6f commit 63a2149
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/layout/IHyprLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand Down

0 comments on commit 63a2149

Please sign in to comment.