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
1=== modified file 'src/snap.cpp'
2--- src/snap.cpp 2011-10-07 15:32:24 +0000
3+++ src/snap.cpp 2011-10-11 09:13:09 +0000
4@@ -46,11 +46,14 @@
5 * Wrapper functions to avoid infinite notify loops
6 */
7 void
8-SnapWindow::move (int dx, int dy)
9+SnapWindow::move (int dx, int dy, bool sync)
10 {
11 skipNotify = true;
12 window->move (dx, dy, true);
13- screen->warpPointer (dx, dy);
14+ /* warp the pointer in the case of
15+ * snap release */
16+ if (sync)
17+ window->syncPosition ();
18 skipNotify = false;
19 }
20
21@@ -406,16 +409,16 @@
22 switch (type)
23 {
24 case LeftEdge:
25- move (min, 0);
26+ move (min, 0, false);
27 break;
28 case RightEdge:
29- move (-min, 0);
30+ move (-min, 0, false);
31 break;
32 case TopEdge:
33- move (0, min);
34+ move (0, min, false);
35 break;
36 case BottomEdge:
37- move (0, -min);
38+ move (0, -min, false);
39 break;
40 default:
41 break;
42@@ -428,17 +431,17 @@
43 * Call the previous function for each of the 4 sides of the window
44 */
45 void
46-SnapWindow::moveCheckEdges ()
47+SnapWindow::moveCheckEdges (int snapDirection)
48 {
49 CompRect input (window->borderRect ());
50 moveCheckNearestEdge (input.left (), input.top (), input.bottom (),
51- true, RightEdge, HorizontalSnap);
52+ true, RightEdge, HorizontalSnap & snapDirection);
53 moveCheckNearestEdge (input.right (), input.top (), input.bottom (),
54- false, LeftEdge, HorizontalSnap);
55+ false, LeftEdge, HorizontalSnap & snapDirection);
56 moveCheckNearestEdge (input.top (), input.left (), input.right (),
57- true, BottomEdge, VerticalSnap);
58+ true, BottomEdge, VerticalSnap & snapDirection);
59 moveCheckNearestEdge (input.bottom (), input.left (), input.right (),
60- false, TopEdge, VerticalSnap);
61+ false, TopEdge, VerticalSnap & snapDirection);
62 }
63
64 // Edges checking functions (resize) -------------------------------------------
65@@ -663,8 +666,29 @@
66 }
67
68 void
69+SnapWindow::stateChangeNotify (unsigned int lastState)
70+{
71+ if (window->state () & CompWindowStateMaximizedHorzMask)
72+ {
73+ snapGeometry.setWidth (0);
74+ snapGeometry.setX (0);
75+ snapDirection &= VerticalSnap;
76+ }
77+
78+ if (window->state () & CompWindowStateMaximizedVertMask)
79+ {
80+ snapGeometry.setHeight (0);
81+ snapGeometry.setY (0);
82+ snapDirection &= HorizontalSnap;
83+ }
84+
85+ window->stateChangeNotify (lastState);
86+}
87+
88+void
89 SnapWindow::moveNotify (int dx, int dy, bool immediate)
90 {
91+ unsigned int allowedSnapDirection = VerticalSnap | HorizontalSnap;
92 SNAP_SCREEN (screen);
93
94 window->moveNotify (dx, dy, immediate);
95@@ -676,22 +700,31 @@
96 // we have to avoid snapping but there's still some buffered moving
97 if (!ss->snapping && (m_dx || m_dy))
98 {
99- move (m_dx, m_dy);
100+ move (m_dx, m_dy, false);
101 m_dx = m_dy = 0;
102 return;
103 }
104
105 // don't snap maximized windows
106 if (window->state () & CompWindowStateMaximizedHorzMask)
107+ {
108+ allowedSnapDirection &= ~(VerticalSnap);
109 dx = 0;
110+ }
111
112 if (window->state () & CompWindowStateMaximizedVertMask)
113+ {
114+ allowedSnapDirection &= ~(HorizontalSnap);
115 dy = 0;
116+ }
117
118 // avoiding snap, nothing buffered
119 if (!ss->snapping)
120 return;
121
122+ dx = snapGeometry.x () - window->geometry ().x ();
123+ dy = snapGeometry.y () - window->geometry ().y ();
124+
125 // apply edge resistance
126 if (ss->optionGetSnapTypeMask () & SnapTypeEdgeResistanceMask)
127 {
128@@ -700,16 +733,15 @@
129 // by buffered dx - dx
130 if (!snapGeometry.isEmpty () && snapDirection & HorizontalSnap)
131 {
132- m_dx += dx;
133+ m_dx += -dx;
134 if (m_dx < ss->optionGetResistanceDistance ()
135 && m_dx > -ss->optionGetResistanceDistance ())
136 {
137- dx = snapGeometry.x () - window->geometry ().x ();
138- move (dx, 0);
139+ move (dx, 0, false);
140 }
141 else
142 {
143- move (m_dx - dx, 0);
144+ move (m_dx - dx, 0, true);
145 m_dx = 0;
146 snapDirection &= VerticalSnap;
147 }
148@@ -717,16 +749,15 @@
149 // Same for vertical snapping and dy
150 if (!snapGeometry.isEmpty () && snapDirection & VerticalSnap)
151 {
152- m_dy += dy;
153+ m_dy += -dy;
154 if (m_dy < ss->optionGetResistanceDistance ()
155 && m_dy > -ss->optionGetResistanceDistance ())
156 {
157- dy = snapGeometry.y () - window->geometry ().y ();
158- move (0, dy);
159+ move (0, dy, false);
160 }
161 else
162 {
163- move (0, m_dy - dy);
164+ move (0, m_dy - dy, true);
165 m_dy = 0;
166 snapDirection &= HorizontalSnap;
167 }
168@@ -738,7 +769,7 @@
169 // If we don't already snap vertically and horizontally,
170 // check edges status
171 if (snapDirection != (VerticalSnap | HorizontalSnap))
172- moveCheckEdges ();
173+ moveCheckEdges (allowedSnapDirection);
174 }
175
176 /*
177
178=== modified file 'src/snap.h'
179--- src/snap.h 2011-09-29 08:12:59 +0000
180+++ src/snap.h 2011-10-11 09:13:09 +0000
181@@ -109,6 +109,7 @@
182 void resizeNotify (int dx, int dy, int dwidth, int dheight);
183 void moveNotify (int dx, int dy, bool immediate);
184 void grabNotify (int x, int y, unsigned int state, unsigned int mask);
185+ void stateChangeNotify (unsigned int lastState);
186 void ungrabNotify ();
187
188 private:
189@@ -134,7 +135,7 @@
190 bool skipNotify;
191
192
193- void move (int dx, int dy);
194+ void move (int dx, int dy, bool sync);
195 void resize (int dx, int dy, int dwidth, int dheight);
196
197 void addEdge (Window id, int position, int start, int end,
198@@ -146,7 +147,7 @@
199 void moveCheckNearestEdge (int position, int start, int end,
200 bool before, EdgeType type,
201 int snapDirection);
202- void moveCheckEdges ();
203+ void moveCheckEdges (int snapDirection);
204 void resizeCheckNearestEdge (int position, int start, int end,
205 bool before, EdgeType type,
206 int snapDirection);

Subscribers

People subscribed via source and target branches

to all changes: