@@ -417,6 +417,7 @@ static void performSnap(Vector2D& sourcePos, Vector2D& sourceSize, PHLWINDOW DRA
417
417
static auto SNAPWINDOWGAP = CConfigValue<Hyprlang::INT>(" general:snap:window_gap" );
418
418
static auto SNAPMONITORGAP = CConfigValue<Hyprlang::INT>(" general:snap:monitor_gap" );
419
419
static auto SNAPBORDEROVERLAP = CConfigValue<Hyprlang::INT>(" general:snap:border_overlap" );
420
+ static auto SNAPRESPECTGAPS = CConfigValue<Hyprlang::INT>(" general:snap:respect_gaps" );
420
421
421
422
const SnapFn SNAP = (MODE == MBIND_MOVE) ? snapMove : snapResize;
422
423
int snaps = 0 ;
@@ -444,9 +445,15 @@ static void performSnap(Vector2D& sourcePos, Vector2D& sourceSize, PHLWINDOW DRA
444
445
const int OTHERBORDERSIZE = other->getRealBorderSize ();
445
446
const double BORDERSIZE = OVERLAP ? std::max (DRAGGINGBORDERSIZE, OTHERBORDERSIZE) : (DRAGGINGBORDERSIZE + OTHERBORDERSIZE);
446
447
447
- const CBox SURF = other->getWindowMainSurfaceBox ();
448
- const SRange SURFBX = {SURF.x - BORDERSIZE, SURF.x + SURF.w + BORDERSIZE};
449
- const SRange SURFBY = {SURF.y - BORDERSIZE, SURF.y + SURF.h + BORDERSIZE};
448
+ const CBox SURF = other->getWindowMainSurfaceBox ();
449
+ double gapOffset = 0 ;
450
+ if (*SNAPRESPECTGAPS) {
451
+ static auto PGAPSINDATA = CConfigValue<Hyprlang::CUSTOMTYPE>(" general:gaps_in" );
452
+ auto * PGAPSINPTR = (CCssGapData*)(PGAPSINDATA.ptr ())->getData ();
453
+ gapOffset = std::max ({PGAPSINPTR->m_left , PGAPSINPTR->m_right , PGAPSINPTR->m_top , PGAPSINPTR->m_bottom });
454
+ }
455
+ const SRange SURFBX = {SURF.x - BORDERSIZE - gapOffset, SURF.x + SURF.w + BORDERSIZE + gapOffset};
456
+ const SRange SURFBY = {SURF.y - BORDERSIZE - gapOffset, SURF.y + SURF.h + BORDERSIZE + gapOffset};
450
457
451
458
// only snap windows if their ranges overlap in the opposite axis
452
459
if (sourceY.start <= SURFBY.end && SURFBY.start <= sourceY.end ) {
@@ -497,32 +504,37 @@ static void performSnap(Vector2D& sourcePos, Vector2D& sourceSize, PHLWINDOW DRA
497
504
const double GAPSIZE = *SNAPMONITORGAP;
498
505
const double BORDERDIFF = OVERLAP ? DRAGGINGBORDERSIZE : 0 ;
499
506
const auto MON = DRAGGINGWINDOW->m_monitor .lock ();
500
-
501
- SRange monX = {MON->m_position .x + MON->m_reservedTopLeft .x + DRAGGINGBORDERSIZE, MON->m_position .x + MON->m_size .x - MON->m_reservedBottomRight .x - DRAGGINGBORDERSIZE};
502
- SRange monY = {MON->m_position .y + MON->m_reservedTopLeft .y + DRAGGINGBORDERSIZE, MON->m_position .y + MON->m_size .y - MON->m_reservedBottomRight .y - DRAGGINGBORDERSIZE};
507
+ double gapOffset = 0 ;
508
+ if (*SNAPRESPECTGAPS) {
509
+ static auto PGAPSOUTDATA = CConfigValue<Hyprlang::CUSTOMTYPE>(" general:gaps_out" );
510
+ auto * PGAPSOUTPTR = (CCssGapData*)(PGAPSOUTDATA.ptr ())->getData ();
511
+ gapOffset = std::max ({PGAPSOUTPTR->m_left , PGAPSOUTPTR->m_right , PGAPSOUTPTR->m_top , PGAPSOUTPTR->m_bottom });
512
+ }
503
513
504
514
if (CORNER & (CORNER_TOPLEFT | CORNER_BOTTOMLEFT) &&
505
- ((MON->m_reservedTopLeft .x > 0 && canSnap (sourceX.start , monX. start , GAPSIZE)) ||
506
- canSnap (sourceX.start , (monX. start -= MON->m_reservedTopLeft .x + BORDERDIFF) , GAPSIZE))) {
507
- SNAP (sourceX.start , sourceX.end , monX. start );
515
+ ((MON->m_reservedTopLeft .x > 0 && canSnap (sourceX.start , MON-> m_position . x + MON-> m_reservedTopLeft . x + DRAGGINGBORDERSIZE + gapOffset , GAPSIZE)) ||
516
+ canSnap (sourceX.start , MON-> m_position . x + MON->m_reservedTopLeft .x - BORDERDIFF + gapOffset , GAPSIZE))) {
517
+ SNAP (sourceX.start , sourceX.end , MON-> m_position . x + MON-> m_reservedTopLeft . x + DRAGGINGBORDERSIZE + gapOffset );
508
518
snaps |= SNAP_LEFT;
509
519
}
510
520
if (CORNER & (CORNER_TOPRIGHT | CORNER_BOTTOMRIGHT) &&
511
- ((MON->m_reservedBottomRight .x > 0 && canSnap (sourceX.end , monX.end , GAPSIZE)) ||
512
- canSnap (sourceX.end , (monX.end += MON->m_reservedBottomRight .x + BORDERDIFF), GAPSIZE))) {
513
- SNAP (sourceX.end , sourceX.start , monX.end );
521
+ ((MON->m_reservedBottomRight .x > 0 &&
522
+ canSnap (sourceX.end , MON->m_position .x + MON->m_size .x - MON->m_reservedBottomRight .x - DRAGGINGBORDERSIZE - gapOffset, GAPSIZE)) ||
523
+ canSnap (sourceX.end , MON->m_position .x + MON->m_size .x - MON->m_reservedBottomRight .x + BORDERDIFF - gapOffset, GAPSIZE))) {
524
+ SNAP (sourceX.end , sourceX.start , MON->m_position .x + MON->m_size .x - MON->m_reservedBottomRight .x - DRAGGINGBORDERSIZE - gapOffset);
514
525
snaps |= SNAP_RIGHT;
515
526
}
516
527
if (CORNER & (CORNER_TOPLEFT | CORNER_TOPRIGHT) &&
517
- ((MON->m_reservedTopLeft .y > 0 && canSnap (sourceY.start , monY. start , GAPSIZE)) ||
518
- canSnap (sourceY.start , (monY. start -= MON->m_reservedTopLeft .y + BORDERDIFF) , GAPSIZE))) {
519
- SNAP (sourceY.start , sourceY.end , monY. start );
528
+ ((MON->m_reservedTopLeft .y > 0 && canSnap (sourceY.start , MON-> m_position . y + MON-> m_reservedTopLeft . y + DRAGGINGBORDERSIZE + gapOffset , GAPSIZE)) ||
529
+ canSnap (sourceY.start , MON-> m_position . y + MON->m_reservedTopLeft .y - BORDERDIFF + gapOffset , GAPSIZE))) {
530
+ SNAP (sourceY.start , sourceY.end , MON-> m_position . y + MON-> m_reservedTopLeft . y + DRAGGINGBORDERSIZE + gapOffset );
520
531
snaps |= SNAP_UP;
521
532
}
522
533
if (CORNER & (CORNER_BOTTOMLEFT | CORNER_BOTTOMRIGHT) &&
523
- ((MON->m_reservedBottomRight .y > 0 && canSnap (sourceY.end , monY.end , GAPSIZE)) ||
524
- canSnap (sourceY.end , (monY.end += MON->m_reservedBottomRight .y + BORDERDIFF), GAPSIZE))) {
525
- SNAP (sourceY.end , sourceY.start , monY.end );
534
+ ((MON->m_reservedBottomRight .y > 0 &&
535
+ canSnap (sourceY.end , MON->m_position .y + MON->m_size .y - MON->m_reservedBottomRight .y - DRAGGINGBORDERSIZE - gapOffset, GAPSIZE)) ||
536
+ canSnap (sourceY.end , MON->m_position .y + MON->m_size .y - MON->m_reservedBottomRight .y + BORDERDIFF - gapOffset, GAPSIZE))) {
537
+ SNAP (sourceY.end , sourceY.start , MON->m_position .y + MON->m_size .y - MON->m_reservedBottomRight .y - DRAGGINGBORDERSIZE - gapOffset);
526
538
snaps |= SNAP_DOWN;
527
539
}
528
540
}
0 commit comments