46
46
* Wrapper functions to avoid infinite notify loops
49
SnapWindow::move (int dx, int dy)
49
SnapWindow::move (int dx, int dy, bool sync)
52
52
window->move (dx, dy, true);
53
screen->warpPointer (dx, dy);
53
/* warp the pointer in the case of
56
window->syncPosition ();
54
57
skipNotify = false;
428
431
* Call the previous function for each of the 4 sides of the window
431
SnapWindow::moveCheckEdges ()
434
SnapWindow::moveCheckEdges (int snapDirection)
433
436
CompRect input (window->borderRect ());
434
437
moveCheckNearestEdge (input.left (), input.top (), input.bottom (),
435
true, RightEdge, HorizontalSnap);
438
true, RightEdge, HorizontalSnap & snapDirection);
436
439
moveCheckNearestEdge (input.right (), input.top (), input.bottom (),
437
false, LeftEdge, HorizontalSnap);
440
false, LeftEdge, HorizontalSnap & snapDirection);
438
441
moveCheckNearestEdge (input.top (), input.left (), input.right (),
439
true, BottomEdge, VerticalSnap);
442
true, BottomEdge, VerticalSnap & snapDirection);
440
443
moveCheckNearestEdge (input.bottom (), input.left (), input.right (),
441
false, TopEdge, VerticalSnap);
444
false, TopEdge, VerticalSnap & snapDirection);
444
447
// Edges checking functions (resize) -------------------------------------------
676
SnapWindow::stateChangeNotify (unsigned int lastState)
678
if (window->state () & CompWindowStateMaximizedHorzMask)
680
snapGeometry.setWidth (0);
681
snapGeometry.setX (0);
682
snapDirection &= VerticalSnap;
685
if (window->state () & CompWindowStateMaximizedVertMask)
687
snapGeometry.setHeight (0);
688
snapGeometry.setY (0);
689
snapDirection &= HorizontalSnap;
692
window->stateChangeNotify (lastState);
673
696
SnapWindow::moveNotify (int dx, int dy, bool immediate)
698
unsigned int allowedSnapDirection = VerticalSnap | HorizontalSnap;
675
699
SNAP_SCREEN (screen);
677
701
window->moveNotify (dx, dy, immediate);
683
707
// we have to avoid snapping but there's still some buffered moving
684
708
if (!ss->snapping && (m_dx || m_dy))
710
move (m_dx, m_dy, false);
691
715
// don't snap maximized windows
692
716
if (window->state () & CompWindowStateMaximizedHorzMask)
718
allowedSnapDirection &= ~(VerticalSnap);
695
722
if (window->state () & CompWindowStateMaximizedVertMask)
724
allowedSnapDirection &= ~(HorizontalSnap);
698
728
// avoiding snap, nothing buffered
699
729
if (!ss->snapping)
732
dx = snapGeometry.x () - window->geometry ().x ();
733
dy = snapGeometry.y () - window->geometry ().y ();
702
735
// apply edge resistance
703
736
if (ss->optionGetSnapTypeMask () & SnapTypeEdgeResistanceMask)
707
740
// by buffered dx - dx
708
741
if (!snapGeometry.isEmpty () && snapDirection & HorizontalSnap)
711
744
if (m_dx < ss->optionGetResistanceDistance ()
712
745
&& m_dx > -ss->optionGetResistanceDistance ())
714
dx = snapGeometry.x () - window->geometry ().x ();
751
move (m_dx - dx, 0, true);
721
753
snapDirection &= VerticalSnap;
724
756
// Same for vertical snapping and dy
725
757
if (!snapGeometry.isEmpty () && snapDirection & VerticalSnap)
728
760
if (m_dy < ss->optionGetResistanceDistance ()
729
761
&& m_dy > -ss->optionGetResistanceDistance ())
731
dy = snapGeometry.y () - window->geometry ().y ();
767
move (0, m_dy - dy, true);
738
769
snapDirection &= HorizontalSnap;