Merge lp:~compiz-team/compiz-snap-plugin/compiz-snap-plugin.fix_872161 into lp:compiz-snap-plugin

Proposed by Sam Spilsbury
Status: Merged
Merged at revision: 62
Proposed branch: lp:~compiz-team/compiz-snap-plugin/compiz-snap-plugin.fix_872161
Merge into: lp:compiz-snap-plugin
Diff against target: 206 lines (+55/-23)
2 files modified
src/snap.cpp (+52/-21)
src/snap.h (+3/-2)
To merge this branch: bzr merge lp:~compiz-team/compiz-snap-plugin/compiz-snap-plugin.fix_872161
Reviewer Review Type Date Requested Status
Jason Smith (community) Approve
Review via email: mp+78927@code.launchpad.net

Description of the change

To post a comment you must log in.
Revision history for this message
Jason Smith (jassmith) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/snap.cpp'
--- src/snap.cpp 2011-10-07 15:32:24 +0000
+++ src/snap.cpp 2011-10-11 09:13:09 +0000
@@ -46,11 +46,14 @@
46 * Wrapper functions to avoid infinite notify loops46 * Wrapper functions to avoid infinite notify loops
47 */47 */
48void48void
49SnapWindow::move (int dx, int dy)49SnapWindow::move (int dx, int dy, bool sync)
50{50{
51 skipNotify = true;51 skipNotify = true;
52 window->move (dx, dy, true);52 window->move (dx, dy, true);
53 screen->warpPointer (dx, dy);53 /* warp the pointer in the case of
54 * snap release */
55 if (sync)
56 window->syncPosition ();
54 skipNotify = false;57 skipNotify = false;
55}58}
5659
@@ -406,16 +409,16 @@
406 switch (type)409 switch (type)
407 {410 {
408 case LeftEdge:411 case LeftEdge:
409 move (min, 0);412 move (min, 0, false);
410 break;413 break;
411 case RightEdge:414 case RightEdge:
412 move (-min, 0);415 move (-min, 0, false);
413 break;416 break;
414 case TopEdge:417 case TopEdge:
415 move (0, min);418 move (0, min, false);
416 break;419 break;
417 case BottomEdge:420 case BottomEdge:
418 move (0, -min);421 move (0, -min, false);
419 break;422 break;
420 default:423 default:
421 break;424 break;
@@ -428,17 +431,17 @@
428 * Call the previous function for each of the 4 sides of the window431 * Call the previous function for each of the 4 sides of the window
429 */432 */
430void433void
431SnapWindow::moveCheckEdges ()434SnapWindow::moveCheckEdges (int snapDirection)
432{435{
433 CompRect input (window->borderRect ());436 CompRect input (window->borderRect ());
434 moveCheckNearestEdge (input.left (), input.top (), input.bottom (),437 moveCheckNearestEdge (input.left (), input.top (), input.bottom (),
435 true, RightEdge, HorizontalSnap);438 true, RightEdge, HorizontalSnap & snapDirection);
436 moveCheckNearestEdge (input.right (), input.top (), input.bottom (),439 moveCheckNearestEdge (input.right (), input.top (), input.bottom (),
437 false, LeftEdge, HorizontalSnap);440 false, LeftEdge, HorizontalSnap & snapDirection);
438 moveCheckNearestEdge (input.top (), input.left (), input.right (),441 moveCheckNearestEdge (input.top (), input.left (), input.right (),
439 true, BottomEdge, VerticalSnap);442 true, BottomEdge, VerticalSnap & snapDirection);
440 moveCheckNearestEdge (input.bottom (), input.left (), input.right (),443 moveCheckNearestEdge (input.bottom (), input.left (), input.right (),
441 false, TopEdge, VerticalSnap);444 false, TopEdge, VerticalSnap & snapDirection);
442}445}
443446
444// Edges checking functions (resize) -------------------------------------------447// Edges checking functions (resize) -------------------------------------------
@@ -663,8 +666,29 @@
663}666}
664667
665void668void
669SnapWindow::stateChangeNotify (unsigned int lastState)
670{
671 if (window->state () & CompWindowStateMaximizedHorzMask)
672 {
673 snapGeometry.setWidth (0);
674 snapGeometry.setX (0);
675 snapDirection &= VerticalSnap;
676 }
677
678 if (window->state () & CompWindowStateMaximizedVertMask)
679 {
680 snapGeometry.setHeight (0);
681 snapGeometry.setY (0);
682 snapDirection &= HorizontalSnap;
683 }
684
685 window->stateChangeNotify (lastState);
686}
687
688void
666SnapWindow::moveNotify (int dx, int dy, bool immediate)689SnapWindow::moveNotify (int dx, int dy, bool immediate)
667{690{
691 unsigned int allowedSnapDirection = VerticalSnap | HorizontalSnap;
668 SNAP_SCREEN (screen);692 SNAP_SCREEN (screen);
669693
670 window->moveNotify (dx, dy, immediate);694 window->moveNotify (dx, dy, immediate);
@@ -676,22 +700,31 @@
676 // we have to avoid snapping but there's still some buffered moving700 // we have to avoid snapping but there's still some buffered moving
677 if (!ss->snapping && (m_dx || m_dy))701 if (!ss->snapping && (m_dx || m_dy))
678 {702 {
679 move (m_dx, m_dy);703 move (m_dx, m_dy, false);
680 m_dx = m_dy = 0;704 m_dx = m_dy = 0;
681 return;705 return;
682 }706 }
683707
684 // don't snap maximized windows708 // don't snap maximized windows
685 if (window->state () & CompWindowStateMaximizedHorzMask)709 if (window->state () & CompWindowStateMaximizedHorzMask)
710 {
711 allowedSnapDirection &= ~(VerticalSnap);
686 dx = 0;712 dx = 0;
713 }
687714
688 if (window->state () & CompWindowStateMaximizedVertMask)715 if (window->state () & CompWindowStateMaximizedVertMask)
716 {
717 allowedSnapDirection &= ~(HorizontalSnap);
689 dy = 0;718 dy = 0;
719 }
690720
691 // avoiding snap, nothing buffered721 // avoiding snap, nothing buffered
692 if (!ss->snapping)722 if (!ss->snapping)
693 return;723 return;
694724
725 dx = snapGeometry.x () - window->geometry ().x ();
726 dy = snapGeometry.y () - window->geometry ().y ();
727
695 // apply edge resistance728 // apply edge resistance
696 if (ss->optionGetSnapTypeMask () & SnapTypeEdgeResistanceMask)729 if (ss->optionGetSnapTypeMask () & SnapTypeEdgeResistanceMask)
697 {730 {
@@ -700,16 +733,15 @@
700 // by buffered dx - dx733 // by buffered dx - dx
701 if (!snapGeometry.isEmpty () && snapDirection & HorizontalSnap)734 if (!snapGeometry.isEmpty () && snapDirection & HorizontalSnap)
702 {735 {
703 m_dx += dx;736 m_dx += -dx;
704 if (m_dx < ss->optionGetResistanceDistance ()737 if (m_dx < ss->optionGetResistanceDistance ()
705 && m_dx > -ss->optionGetResistanceDistance ())738 && m_dx > -ss->optionGetResistanceDistance ())
706 {739 {
707 dx = snapGeometry.x () - window->geometry ().x ();740 move (dx, 0, false);
708 move (dx, 0);
709 }741 }
710 else742 else
711 {743 {
712 move (m_dx - dx, 0);744 move (m_dx - dx, 0, true);
713 m_dx = 0;745 m_dx = 0;
714 snapDirection &= VerticalSnap;746 snapDirection &= VerticalSnap;
715 }747 }
@@ -717,16 +749,15 @@
717 // Same for vertical snapping and dy749 // Same for vertical snapping and dy
718 if (!snapGeometry.isEmpty () && snapDirection & VerticalSnap)750 if (!snapGeometry.isEmpty () && snapDirection & VerticalSnap)
719 {751 {
720 m_dy += dy;752 m_dy += -dy;
721 if (m_dy < ss->optionGetResistanceDistance ()753 if (m_dy < ss->optionGetResistanceDistance ()
722 && m_dy > -ss->optionGetResistanceDistance ())754 && m_dy > -ss->optionGetResistanceDistance ())
723 {755 {
724 dy = snapGeometry.y () - window->geometry ().y ();756 move (0, dy, false);
725 move (0, dy);
726 }757 }
727 else758 else
728 {759 {
729 move (0, m_dy - dy);760 move (0, m_dy - dy, true);
730 m_dy = 0;761 m_dy = 0;
731 snapDirection &= HorizontalSnap;762 snapDirection &= HorizontalSnap;
732 }763 }
@@ -738,7 +769,7 @@
738 // If we don't already snap vertically and horizontally,769 // If we don't already snap vertically and horizontally,
739 // check edges status770 // check edges status
740 if (snapDirection != (VerticalSnap | HorizontalSnap))771 if (snapDirection != (VerticalSnap | HorizontalSnap))
741 moveCheckEdges ();772 moveCheckEdges (allowedSnapDirection);
742}773}
743774
744/*775/*
745776
=== modified file 'src/snap.h'
--- src/snap.h 2011-09-29 08:12:59 +0000
+++ src/snap.h 2011-10-11 09:13:09 +0000
@@ -109,6 +109,7 @@
109 void resizeNotify (int dx, int dy, int dwidth, int dheight);109 void resizeNotify (int dx, int dy, int dwidth, int dheight);
110 void moveNotify (int dx, int dy, bool immediate);110 void moveNotify (int dx, int dy, bool immediate);
111 void grabNotify (int x, int y, unsigned int state, unsigned int mask);111 void grabNotify (int x, int y, unsigned int state, unsigned int mask);
112 void stateChangeNotify (unsigned int lastState);
112 void ungrabNotify ();113 void ungrabNotify ();
113114
114 private:115 private:
@@ -134,7 +135,7 @@
134 bool skipNotify;135 bool skipNotify;
135136
136137
137 void move (int dx, int dy);138 void move (int dx, int dy, bool sync);
138 void resize (int dx, int dy, int dwidth, int dheight);139 void resize (int dx, int dy, int dwidth, int dheight);
139140
140 void addEdge (Window id, int position, int start, int end,141 void addEdge (Window id, int position, int start, int end,
@@ -146,7 +147,7 @@
146 void moveCheckNearestEdge (int position, int start, int end,147 void moveCheckNearestEdge (int position, int start, int end,
147 bool before, EdgeType type,148 bool before, EdgeType type,
148 int snapDirection);149 int snapDirection);
149 void moveCheckEdges ();150 void moveCheckEdges (int snapDirection);
150 void resizeCheckNearestEdge (int position, int start, int end,151 void resizeCheckNearestEdge (int position, int start, int end,
151 bool before, EdgeType type,152 bool before, EdgeType type,
152 int snapDirection);153 int snapDirection);

Subscribers

People subscribed via source and target branches

to all changes: