~compiz-team/compiz-snap-plugin/compiz-snap-plugin.fix_872161

« back to all changes in this revision

Viewing changes to src/snap.cpp

  • Committer: Sam Spilsbury
  • Date: 2011-09-27 15:54:10 UTC
  • mfrom: (53.1.2)
  • Revision ID: git-v1:a4b512999b0cfa5694ece709cef471dcf56bbb12
Merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
396
396
        // Update snapping data
397
397
        if (ss->optionGetSnapTypeMask () & SnapTypeEdgeResistanceMask)
398
398
        {
399
 
            snapped = true;
 
399
            snapGeometry = window->serverGeometry ();
400
400
            this->snapDirection |= snapDirection;
401
401
        }
402
402
        // Attract the window if needed, moving it of the correct dist
487
487
        // Update snapping data
488
488
        if (ss->optionGetSnapTypeMask () & SnapTypeEdgeResistanceMask)
489
489
        {
490
 
            snapped = true;
 
490
            snapGeometry = window->serverGeometry ();
491
491
            this->snapDirection |= snapDirection;
492
492
        }
493
493
        // FIXME : this needs resize-specific code.
591
591
        // If there's horizontal snapping, add dx to current buffered
592
592
        // dx and resist (move by -dx) or release the window and move
593
593
        // by buffered dx - dx, same for dh
594
 
        if (snapped && snapDirection & HorizontalSnap)
 
594
        if (!snapGeometry.isEmpty () && snapDirection & HorizontalSnap)
595
595
        {
596
596
            m_dx += dx;
597
597
            if (m_dx < ss->optionGetResistanceDistance ()
622
622
        }
623
623
 
624
624
        // Same for vertical snapping and dy/dh
625
 
        if (snapped && snapDirection & VerticalSnap)
 
625
        if (snapGeometry.isEmpty () && snapDirection & VerticalSnap)
626
626
        {
627
627
            m_dy += dy;
628
628
            if (m_dy < ss->optionGetResistanceDistance ()
652
652
            }
653
653
        }
654
654
        // If we are no longer snapping in any direction, reset snapped
655
 
        if (snapped && !snapDirection)
656
 
            snapped = false;
 
655
        if (!snapGeometry.isEmpty () && !snapDirection)
 
656
            snapGeometry = CompWindow::Geometry ();
657
657
    }
658
658
 
659
659
    // If we don't already snap vertically and horizontally,
691
691
        // If there's horizontal snapping, add dx to current buffered
692
692
        // dx and resist (move by -dx) or release the window and move
693
693
        // by buffered dx - dx
694
 
        if (snapped && snapDirection & HorizontalSnap)
 
694
        if (!snapGeometry.isEmpty () && snapDirection & HorizontalSnap)
695
695
        {
696
696
            m_dx += dx;
697
697
            if (m_dx < ss->optionGetResistanceDistance ()
698
698
                && m_dx > -ss->optionGetResistanceDistance ())
699
699
            {
700
 
                move (-dx, 0);
 
700
                dx = snapGeometry.x () - window->geometry ().x ();
 
701
                move (dx, 0);
701
702
            }
702
703
            else
703
704
            {
707
708
            }
708
709
        }
709
710
        // Same for vertical snapping and dy
710
 
        if (snapped && snapDirection & VerticalSnap)
 
711
        if (!snapGeometry.isEmpty () && snapDirection & VerticalSnap)
711
712
        {
712
713
            m_dy += dy;
713
714
            if (m_dy < ss->optionGetResistanceDistance ()
714
715
                && m_dy > -ss->optionGetResistanceDistance ())
715
716
            {
716
 
                move (0, -dy);
 
717
                dy = snapGeometry.y () - window->geometry ().y ();
 
718
                move (0, dy);
717
719
            }
718
720
            else
719
721
            {
723
725
            }
724
726
        }
725
727
        // If we are no longer snapping in any direction, reset snapped
726
 
        if (snapped && !snapDirection)
727
 
            snapped = false;
 
728
        if (!snapGeometry.isEmpty () && !snapDirection)
 
729
            snapGeometry = CompWindow::Geometry ();
728
730
    }
729
731
    // If we don't already snap vertically and horizontally,
730
732
    // check edges status
753
755
{
754
756
    edges.clear ();
755
757
 
756
 
    snapped = false;
 
758
    snapGeometry = CompWindow::Geometry ();
757
759
    snapDirection = 0;
758
760
    grabbed = 0;
759
761
    m_dx = m_dy = m_dwidth = m_dheight = 0;
809
811
    m_dy (0),
810
812
    m_dwidth (0),
811
813
    m_dheight (0),
812
 
    snapped (false),
 
814
    snapGeometry (0, 0, 0, 0, 0),
813
815
    grabbed (0),
814
816
    skipNotify (false)
815
817
{