@@ -393,6 +393,7 @@ static void performSnap(Vector2D& sourcePos, Vector2D& sourceSize, PHLWINDOW DRA
393
393
static auto SNAPWINDOWGAP = CConfigValue<Hyprlang::INT>(" general:snap:window_gap" );
394
394
static auto SNAPMONITORGAP = CConfigValue<Hyprlang::INT>(" general:snap:monitor_gap" );
395
395
static auto SNAPBORDEROVERLAP = CConfigValue<Hyprlang::INT>(" general:snap:border_overlap" );
396
+ static auto SNAPRESPECTGAPS = CConfigValue<Hyprlang::INT>(" general:snap:respect_gaps" );
396
397
397
398
const SnapFn SNAP = (MODE == MBIND_MOVE) ? snapMove : snapResize;
398
399
int snaps = 0 ;
@@ -420,9 +421,15 @@ static void performSnap(Vector2D& sourcePos, Vector2D& sourceSize, PHLWINDOW DRA
420
421
const int OTHERBORDERSIZE = other->getRealBorderSize ();
421
422
const double BORDERSIZE = OVERLAP ? std::max (DRAGGINGBORDERSIZE, OTHERBORDERSIZE) : (DRAGGINGBORDERSIZE + OTHERBORDERSIZE);
422
423
423
- const CBox SURF = other->getWindowMainSurfaceBox ();
424
- const SRange SURFBX = {SURF.x - BORDERSIZE, SURF.x + SURF.w + BORDERSIZE};
425
- const SRange SURFBY = {SURF.y - BORDERSIZE, SURF.y + SURF.h + BORDERSIZE};
424
+ const CBox SURF = other->getWindowMainSurfaceBox ();
425
+ double GAP_OFFSET = 0 ;
426
+ if (*SNAPRESPECTGAPS) {
427
+ static auto PGAPSINDATA = CConfigValue<Hyprlang::CUSTOMTYPE>(" general:gaps_in" );
428
+ auto * PGAPSINPTR = (CCssGapData*)(PGAPSINDATA.ptr ())->getData ();
429
+ GAP_OFFSET = std::max ({PGAPSINPTR->m_left , PGAPSINPTR->m_right , PGAPSINPTR->m_top , PGAPSINPTR->m_bottom });
430
+ }
431
+ const SRange SURFBX = {SURF.x - BORDERSIZE - GAP_OFFSET, SURF.x + SURF.w + BORDERSIZE + GAP_OFFSET};
432
+ const SRange SURFBY = {SURF.y - BORDERSIZE - GAP_OFFSET, SURF.y + SURF.h + BORDERSIZE + GAP_OFFSET};
426
433
427
434
// only snap windows if their ranges overlap in the opposite axis
428
435
if (sourceY.start <= SURFBY.end && SURFBY.start <= sourceY.end ) {
@@ -473,32 +480,35 @@ static void performSnap(Vector2D& sourcePos, Vector2D& sourceSize, PHLWINDOW DRA
473
480
const double GAPSIZE = *SNAPMONITORGAP;
474
481
const double BORDERDIFF = OVERLAP ? DRAGGINGBORDERSIZE : 0 ;
475
482
const auto MON = DRAGGINGWINDOW->m_monitor .lock ();
476
-
477
- SRange monX = {MON->m_position .x + MON->m_reservedTopLeft .x + DRAGGINGBORDERSIZE, MON->m_position .x + MON->m_size .x - MON->m_reservedBottomRight .x - DRAGGINGBORDERSIZE};
478
- SRange monY = {MON->m_position .y + MON->m_reservedTopLeft .y + DRAGGINGBORDERSIZE, MON->m_position .y + MON->m_size .y - MON->m_reservedBottomRight .y - DRAGGINGBORDERSIZE};
483
+ double GAP_OFFSET = 0 ;
484
+ if (*SNAPRESPECTGAPS) {
485
+ static auto PGAPSOUTDATA = CConfigValue<Hyprlang::CUSTOMTYPE>(" general:gaps_out" );
486
+ auto * PGAPSOUTPTR = (CCssGapData*)(PGAPSOUTDATA.ptr ())->getData ();
487
+ GAP_OFFSET = std::max ({PGAPSOUTPTR->m_left , PGAPSOUTPTR->m_right , PGAPSOUTPTR->m_top , PGAPSOUTPTR->m_bottom });
488
+ }
479
489
480
490
if (CORNER & (CORNER_TOPLEFT | CORNER_BOTTOMLEFT) &&
481
- ((MON->m_reservedTopLeft .x > 0 && canSnap (sourceX.start , monX. start , GAPSIZE)) ||
482
- canSnap (sourceX.start , (monX. start -= MON->m_reservedTopLeft .x + BORDERDIFF) , GAPSIZE))) {
483
- SNAP (sourceX.start , sourceX.end , monX. start );
491
+ ((MON->m_reservedTopLeft .x > 0 && canSnap (sourceX.start , MON-> m_position . x + MON-> m_reservedTopLeft . x + DRAGGINGBORDERSIZE + GAP_OFFSET , GAPSIZE)) ||
492
+ canSnap (sourceX.start , MON-> m_position . x + MON->m_reservedTopLeft .x - BORDERDIFF + GAP_OFFSET , GAPSIZE))) {
493
+ SNAP (sourceX.start , sourceX.end , MON-> m_position . x + MON-> m_reservedTopLeft . x + DRAGGINGBORDERSIZE + GAP_OFFSET );
484
494
snaps |= SNAP_LEFT;
485
495
}
486
496
if (CORNER & (CORNER_TOPRIGHT | CORNER_BOTTOMRIGHT) &&
487
- ((MON->m_reservedBottomRight .x > 0 && canSnap (sourceX.end , monX. end , GAPSIZE)) ||
488
- canSnap (sourceX.end , (monX. end += MON->m_reservedBottomRight .x + BORDERDIFF) , GAPSIZE))) {
489
- SNAP (sourceX.end , sourceX.start , monX. end );
497
+ ((MON->m_reservedBottomRight .x > 0 && canSnap (sourceX.end , MON-> m_position . x + MON-> m_size . x - MON-> m_reservedBottomRight . x - DRAGGINGBORDERSIZE - GAP_OFFSET , GAPSIZE)) ||
498
+ canSnap (sourceX.end , MON-> m_position . x + MON->m_size . x - MON-> m_reservedBottomRight .x + BORDERDIFF - GAP_OFFSET , GAPSIZE))) {
499
+ SNAP (sourceX.end , sourceX.start , MON-> m_position . x + MON-> m_size . x - MON-> m_reservedBottomRight . x - DRAGGINGBORDERSIZE - GAP_OFFSET );
490
500
snaps |= SNAP_RIGHT;
491
501
}
492
502
if (CORNER & (CORNER_TOPLEFT | CORNER_TOPRIGHT) &&
493
- ((MON->m_reservedTopLeft .y > 0 && canSnap (sourceY.start , monY. start , GAPSIZE)) ||
494
- canSnap (sourceY.start , (monY. start -= MON->m_reservedTopLeft .y + BORDERDIFF) , GAPSIZE))) {
495
- SNAP (sourceY.start , sourceY.end , monY. start );
503
+ ((MON->m_reservedTopLeft .y > 0 && canSnap (sourceY.start , MON-> m_position . y + MON-> m_reservedTopLeft . y + DRAGGINGBORDERSIZE + GAP_OFFSET , GAPSIZE)) ||
504
+ canSnap (sourceY.start , MON-> m_position . y + MON->m_reservedTopLeft .y - BORDERDIFF + GAP_OFFSET , GAPSIZE))) {
505
+ SNAP (sourceY.start , sourceY.end , MON-> m_position . y + MON-> m_reservedTopLeft . y + DRAGGINGBORDERSIZE + GAP_OFFSET );
496
506
snaps |= SNAP_UP;
497
507
}
498
508
if (CORNER & (CORNER_BOTTOMLEFT | CORNER_BOTTOMRIGHT) &&
499
- ((MON->m_reservedBottomRight .y > 0 && canSnap (sourceY.end , monY. end , GAPSIZE)) ||
500
- canSnap (sourceY.end , (monY. end += MON->m_reservedBottomRight .y + BORDERDIFF) , GAPSIZE))) {
501
- SNAP (sourceY.end , sourceY.start , monY. end );
509
+ ((MON->m_reservedBottomRight .y > 0 && canSnap (sourceY.end , MON-> m_position . y + MON-> m_size . y - MON-> m_reservedBottomRight . y - DRAGGINGBORDERSIZE - GAP_OFFSET , GAPSIZE)) ||
510
+ canSnap (sourceY.end , MON-> m_position . y + MON->m_size . y - MON-> m_reservedBottomRight .y + BORDERDIFF - GAP_OFFSET , GAPSIZE))) {
511
+ SNAP (sourceY.end , sourceY.start , MON-> m_position . y + MON-> m_size . y - MON-> m_reservedBottomRight . y - DRAGGINGBORDERSIZE - GAP_OFFSET );
502
512
snaps |= SNAP_DOWN;
503
513
}
504
514
}
0 commit comments