mirror of
https://github.com/hyprwm/Hyprland
synced 2025-01-09 22:49:49 +01:00
snap: bias reserved area when its size is greater than zero (#8694)
This commit is contained in:
parent
aefaeedf5e
commit
61a51bb4ef
1 changed files with 13 additions and 8 deletions
|
@ -480,30 +480,35 @@ static void performSnap(Vector2D& sourcePos, Vector2D& sourceSize, PHLWINDOW DRA
|
||||||
|
|
||||||
if (*SNAPMONITORGAP) {
|
if (*SNAPMONITORGAP) {
|
||||||
const double GAPSIZE = *SNAPMONITORGAP;
|
const double GAPSIZE = *SNAPMONITORGAP;
|
||||||
const double BORDERSIZE = OVERLAP ? 0 : DRAGGINGBORDERSIZE;
|
const double BORDERDIFF = OVERLAP ? DRAGGINGBORDERSIZE : 0;
|
||||||
const double BORDERDIFF = DRAGGINGBORDERSIZE - BORDERSIZE;
|
|
||||||
const auto MON = DRAGGINGWINDOW->m_pMonitor.lock();
|
const auto MON = DRAGGINGWINDOW->m_pMonitor.lock();
|
||||||
|
|
||||||
SRange monX = {MON->vecPosition.x + BORDERSIZE, MON->vecPosition.x + MON->vecSize.x - BORDERSIZE};
|
SRange monX = {MON->vecPosition.x + MON->vecReservedTopLeft.x + DRAGGINGBORDERSIZE,
|
||||||
SRange monY = {MON->vecPosition.y + BORDERSIZE, MON->vecPosition.y + MON->vecSize.y - BORDERSIZE};
|
MON->vecPosition.x + MON->vecSize.x - MON->vecReservedBottomRight.x - DRAGGINGBORDERSIZE};
|
||||||
|
SRange monY = {MON->vecPosition.y + MON->vecReservedTopLeft.y + DRAGGINGBORDERSIZE,
|
||||||
|
MON->vecPosition.y + MON->vecSize.y - MON->vecReservedBottomRight.y - DRAGGINGBORDERSIZE};
|
||||||
|
|
||||||
if (CORNER & (CORNER_TOPLEFT | CORNER_BOTTOMLEFT) &&
|
if (CORNER & (CORNER_TOPLEFT | CORNER_BOTTOMLEFT) &&
|
||||||
(canSnap(sourceX.start, monX.start, GAPSIZE) || canSnap(sourceX.start, (monX.start += MON->vecReservedTopLeft.x + BORDERDIFF), GAPSIZE))) {
|
((MON->vecReservedTopLeft.x > 0 && canSnap(sourceX.start, monX.start, GAPSIZE)) ||
|
||||||
|
canSnap(sourceX.start, (monX.start -= MON->vecReservedTopLeft.x + BORDERDIFF), GAPSIZE))) {
|
||||||
SNAP(sourceX.start, sourceX.end, monX.start);
|
SNAP(sourceX.start, sourceX.end, monX.start);
|
||||||
snaps |= SNAP_LEFT;
|
snaps |= SNAP_LEFT;
|
||||||
}
|
}
|
||||||
if (CORNER & (CORNER_TOPRIGHT | CORNER_BOTTOMRIGHT) &&
|
if (CORNER & (CORNER_TOPRIGHT | CORNER_BOTTOMRIGHT) &&
|
||||||
(canSnap(sourceX.end, monX.end, GAPSIZE) || canSnap(sourceX.end, (monX.end -= MON->vecReservedBottomRight.x + BORDERDIFF), GAPSIZE))) {
|
((MON->vecReservedBottomRight.x > 0 && canSnap(sourceX.end, monX.end, GAPSIZE)) ||
|
||||||
|
canSnap(sourceX.end, (monX.end += MON->vecReservedBottomRight.x + BORDERDIFF), GAPSIZE))) {
|
||||||
SNAP(sourceX.end, sourceX.start, monX.end);
|
SNAP(sourceX.end, sourceX.start, monX.end);
|
||||||
snaps |= SNAP_RIGHT;
|
snaps |= SNAP_RIGHT;
|
||||||
}
|
}
|
||||||
if (CORNER & (CORNER_TOPLEFT | CORNER_TOPRIGHT) &&
|
if (CORNER & (CORNER_TOPLEFT | CORNER_TOPRIGHT) &&
|
||||||
(canSnap(sourceY.start, monY.start, GAPSIZE) || canSnap(sourceY.start, (monY.start += MON->vecReservedTopLeft.y + BORDERDIFF), GAPSIZE))) {
|
((MON->vecReservedTopLeft.y > 0 && canSnap(sourceY.start, monY.start, GAPSIZE)) ||
|
||||||
|
canSnap(sourceY.start, (monY.start -= MON->vecReservedTopLeft.y + BORDERDIFF), GAPSIZE))) {
|
||||||
SNAP(sourceY.start, sourceY.end, monY.start);
|
SNAP(sourceY.start, sourceY.end, monY.start);
|
||||||
snaps |= SNAP_UP;
|
snaps |= SNAP_UP;
|
||||||
}
|
}
|
||||||
if (CORNER & (CORNER_BOTTOMLEFT | CORNER_BOTTOMRIGHT) &&
|
if (CORNER & (CORNER_BOTTOMLEFT | CORNER_BOTTOMRIGHT) &&
|
||||||
(canSnap(sourceY.end, monY.end, GAPSIZE) || canSnap(sourceY.end, (monY.end -= MON->vecReservedBottomRight.y + BORDERDIFF), GAPSIZE))) {
|
((MON->vecReservedBottomRight.y > 0 && canSnap(sourceY.end, monY.end, GAPSIZE)) ||
|
||||||
|
canSnap(sourceY.end, (monY.end += MON->vecReservedBottomRight.y + BORDERDIFF), GAPSIZE))) {
|
||||||
SNAP(sourceY.end, sourceY.start, monY.end);
|
SNAP(sourceY.end, sourceY.start, monY.end);
|
||||||
snaps |= SNAP_DOWN;
|
snaps |= SNAP_DOWN;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue