~gloob/compiz/texttracking

« back to all changes in this revision

Viewing changes to plugins/snap/src/snap.cpp

  • Committer: Alejandro Leiva
  • Date: 2014-06-21 12:37:53 UTC
  • mfrom: (3249.1.625 texttracking)
  • Revision ID: gloob@litio.org-20140621123753-3v74nz5khe672xah
Merged with lp:compiz branch into texttracking.

Show diffs side-by-side

added added

removed removed

Lines of Context:
587
587
    if (!ss->snapping)
588
588
        return;
589
589
 
590
 
    // apply edge resistance
591
 
    if (ss->optionGetSnapTypeMask () & SnapTypeEdgeResistanceMask)
592
 
    {
593
 
        // If there's horizontal snapping, add dx to current buffered
594
 
        // dx and resist (move by -dx) or release the window and move
595
 
        // by buffered dx - dx, same for dh
596
 
        if (!snapGeometry.isEmpty () && snapDirection & HorizontalSnap)
597
 
        {
598
 
            m_dx += dx;
599
 
            if (m_dx < ss->optionGetResistanceDistance ()
600
 
                && m_dx > -ss->optionGetResistanceDistance ())
601
 
            {
602
 
                resize (-dx, 0, 0, 0);
603
 
            }
604
 
            else
605
 
            {
606
 
                resize (m_dx - dx, 0, 0, 0);
607
 
                m_dx = 0;
608
 
                if (!m_dwidth)
609
 
                    snapDirection &= VerticalSnap;
610
 
            }
611
 
            m_dwidth += dwidth;
612
 
            if (m_dwidth < ss->optionGetResistanceDistance ()
613
 
                && m_dwidth > -ss->optionGetResistanceDistance ())
614
 
            {
615
 
                resize (0, 0, -dwidth, 0);
616
 
            }
617
 
            else
618
 
            {
619
 
                resize (0, 0, m_dwidth - dwidth, 0);
620
 
                m_dwidth = 0;
621
 
                if (!m_dx)
622
 
                    snapDirection &= VerticalSnap;
623
 
            }
624
 
        }
625
 
 
626
 
        // Same for vertical snapping and dy/dh
627
 
        if (snapGeometry.isEmpty () && snapDirection & VerticalSnap)
628
 
        {
629
 
            m_dy += dy;
630
 
            if (m_dy < ss->optionGetResistanceDistance ()
631
 
                && m_dy > -ss->optionGetResistanceDistance ())
632
 
            {
633
 
                resize (0, -dy, 0, 0);
634
 
            }
635
 
            else
636
 
            {
637
 
                resize (0, m_dy - dy, 0, 0);
638
 
                m_dy = 0;
639
 
                if (!m_dheight)
640
 
                    snapDirection &= HorizontalSnap;
641
 
            }
642
 
            m_dheight += dheight;
643
 
            if (m_dheight < ss->optionGetResistanceDistance ()
644
 
                && m_dheight > -ss->optionGetResistanceDistance ())
645
 
            {
646
 
                resize (0, 0, 0, -dheight);
647
 
            }
648
 
            else
649
 
            {
650
 
                resize (0, 0, 0, m_dheight - dheight);
651
 
                m_dheight = 0;
652
 
                if (!m_dy)
653
 
                    snapDirection &= HorizontalSnap;
654
 
            }
655
 
        }
656
 
        // If we are no longer snapping in any direction, reset snapped
657
 
        if (!snapGeometry.isEmpty () && !snapDirection)
658
 
            snapGeometry = CompWindow::Geometry ();
659
 
    }
660
 
 
661
590
    // If we don't already snap vertically and horizontally,
662
591
    // check edges status
663
592
    if (snapDirection != (VerticalSnap | HorizontalSnap))