Merge lp:~smspillaz/compiz-grid-plugin/oneiric.fix_827560 into lp:~compiz-team/compiz-grid-plugin/oneiric

Proposed by Sam Spilsbury
Status: Merged
Merged at revision: 89
Proposed branch: lp:~smspillaz/compiz-grid-plugin/oneiric.fix_827560
Merge into: lp:~compiz-team/compiz-grid-plugin/oneiric
Diff against target: 253 lines (+116/-27)
2 files modified
src/grid.cpp (+97/-14)
src/grid.h (+19/-13)
To merge this branch: bzr merge lp:~smspillaz/compiz-grid-plugin/oneiric.fix_827560
Reviewer Review Type Date Requested Status
Jason Smith (community) Approve
Review via email: mp+77367@code.launchpad.net

Description of the change

Fix lp bug 827560

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/grid.cpp'
2--- src/grid.cpp 2011-09-27 15:50:51 +0000
3+++ src/grid.cpp 2011-09-28 17:06:23 +0000
4@@ -24,6 +24,8 @@
5
6 #include "grid.h"
7
8+using namespace GridWindowType;
9+
10 static const GridProps gridProps[] =
11 {
12 {0,1, 1,1},
13@@ -145,12 +147,23 @@
14 xid = CompOption::getIntOptionNamed (option, "window");
15 cw = screen->findWindow (xid);
16
17- if (where == GridUnknown || screen->otherGrabExist ("move", NULL))
18- return false;
19-
20 if (cw)
21 {
22 XWindowChanges xwc;
23+ bool maximizeH = where & (GridBottom | GridTop | GridMaximize);
24+ bool maximizeV = where & (GridLeft | GridRight | GridMaximize);
25+
26+ if (!(cw->actions () & CompWindowActionResizeMask))
27+ return false;
28+
29+ if (maximizeH && !(cw->actions () & CompWindowActionMaximizeHorzMask))
30+ return false;
31+
32+ if (maximizeV && !(cw->actions () & CompWindowActionMaximizeVertMask))
33+ return false;
34+
35+ if (where == GridUnknown)
36+ return false;
37
38 GRID_WINDOW (cw);
39
40@@ -339,13 +352,42 @@
41 /* TODO: animate move+resize */
42 if (resize)
43 {
44- cw->configureXWindow (CWX | CWY | CWWidth | CWHeight, &xwc);
45- gw->isGridResized = true;
46- gw->isGridMaximized = false;
47- for (unsigned int i = 0; i < animations.size (); i++)
48- animations.at (i).fadingOut = true;
49+ unsigned int valueMask = CWX | CWY | CWWidth | CWHeight;
50 gw->lastTarget = where;
51 gw->currentSize = CompRect (wc.x, wc.y, wc.width, wc.height);
52+
53+ /* Special case for left and right, actually vertically maximize
54+ * the window */
55+ if (where == GridLeft || where == GridRight)
56+ {
57+ /* First restore the window to its original size */
58+ XWindowChanges rwc;
59+
60+ rwc.x = gw->originalSize.x ();
61+ rwc.y = gw->originalSize.y ();
62+ rwc.width = gw->originalSize.width ();
63+ rwc.height = gw->originalSize.height ();
64+
65+ cw->configureXWindow (CWX | CWY | CWWidth | CWHeight, &rwc);
66+
67+ gw->isGridMaximized = true;
68+ gw->isGridResized = false;
69+
70+ gw->lastBorder = cw->border ();
71+ /* Maximize the window */
72+ cw->maximize (CompWindowStateMaximizedVertMask);
73+ }
74+ else
75+ {
76+ gw->isGridResized = true;
77+ gw->isGridMaximized = false;
78+ }
79+
80+ /* Make window the size that we want */
81+ cw->configureXWindow (valueMask, &xwc);
82+
83+ for (unsigned int i = 0; i < animations.size (); i++)
84+ animations.at (i).fadingOut = true;
85 }
86
87 /* This centers a window if it could not be resized to the desired
88@@ -664,21 +706,22 @@
89 unsigned int state,
90 unsigned int mask)
91 {
92- if (screen->grabExist ("move"))
93+ if (mask & (CompWindowGrabMoveMask | CompWindowGrabButtonMask))
94 {
95 gScreen->o[0].value ().set ((int) window->id ());
96
97 screen->handleEventSetEnabled (gScreen, true);
98 gScreen->mGrabWindow = window;
99 pointerBufDx = pointerBufDy = 0;
100+ grabMask = mask;
101
102- if (!isGridResized && gScreen->optionGetSnapbackWindows ())
103+ if (!isGridResized && !isGridMaximized && gScreen->optionGetSnapbackWindows ())
104 /* Store size not including borders when grabbing with cursor */
105 originalSize = gScreen->slotToRect(window,
106 window->serverBorderRect ());
107 }
108
109- if (screen->grabExist ("resize"))
110+ if (mask & CompWindowGrabResizeMask)
111 {
112 isGridResized = false;
113 resizeCount = 0;
114@@ -697,6 +740,7 @@
115 gScreen->edge != gScreen->lastResizeEdge);
116
117 screen->handleEventSetEnabled (gScreen, false);
118+ grabMask = 0;
119 gScreen->mGrabWindow = NULL;
120 gScreen->o[0].value ().set (0);
121 gScreen->cScreen->damageRegion (gScreen->desiredSlot);
122@@ -715,7 +759,7 @@
123
124 if (isGridResized && !isGridMaximized && !GridScreen::get (screen)->mSwitchingVp)
125 {
126- if (window->grabbed ())
127+ if (window->grabbed () && (grabMask & CompWindowGrabMoveMask))
128 {
129 pointerBufDx += dx;
130 pointerBufDy += dy;
131@@ -738,11 +782,49 @@
132 lastTarget = GridUnknown;
133 else if (!(lastState & MAXIMIZE_STATE) &&
134 window->state () & MAXIMIZE_STATE)
135+ {
136 lastTarget = GridMaximize;
137+ if (window->grabbed ())
138+ {
139+ originalSize = gScreen->slotToRect (window,
140+ window->serverBorderRect ());
141+ }
142+ }
143
144 window->stateChangeNotify (lastState);
145-}
146-
147+}
148+
149+void
150+GridWindow::windowNotify (CompWindowNotify n)
151+{
152+ if (n == CompWindowNotifyFrameUpdate)
153+ {
154+ if (isGridMaximized && !((window->state () & MAXIMIZE_STATE) == MAXIMIZE_STATE))
155+ {
156+ unsigned int valueMask = 0;
157+ XWindowChanges xwc;
158+
159+ int dw = (lastBorder.left + lastBorder.right) -
160+ (window->border ().left + window->border ().right);
161+
162+ int dh = (lastBorder.top + lastBorder.bottom) -
163+ (window->border ().top + window->border ().bottom);
164+
165+ if (dw != 0)
166+ valueMask |= CWWidth;
167+ if (dh != 0)
168+ valueMask |= CWHeight;
169+ xwc.width = window->serverGeometry ().width () + dw;
170+ xwc.height = window->serverGeometry ().height () + dh;
171+
172+ window->configureXWindow (valueMask, &xwc);
173+ }
174+
175+ lastBorder = window->border ();
176+ }
177+
178+ window->windowNotify (n);
179+}
180 bool
181 GridScreen::restoreWindow (CompAction *action,
182 CompAction::State state,
183@@ -929,6 +1011,7 @@
184 gScreen (GridScreen::get (screen)),
185 isGridResized (false),
186 isGridMaximized (false),
187+ grabMask (0),
188 pointerBufDx (0),
189 pointerBufDy (0),
190 resizeCount (0),
191
192=== modified file 'src/grid.h'
193--- src/grid.h 2011-09-27 15:50:51 +0000
194+++ src/grid.h 2011-09-28 17:06:23 +0000
195@@ -32,20 +32,22 @@
196
197 #define SNAPOFF_THRESHOLD 50
198
199-typedef enum
200+namespace GridWindowType
201 {
202- GridUnknown = 0,
203- GridBottomLeft = 1,
204- GridBottom = 2,
205- GridBottomRight = 3,
206- GridLeft = 4,
207- GridCenter = 5,
208- GridRight = 6,
209- GridTopLeft = 7,
210- GridTop = 8,
211- GridTopRight = 9,
212- GridMaximize = 10
213-} GridType;
214+ static const unsigned int GridUnknown = (1 << 0);
215+ static const unsigned int GridBottomLeft = (1 << 1);
216+ static const unsigned int GridBottom = (1 << 2);
217+ static const unsigned int GridBottomRight = (1 << 3);
218+ static const unsigned int GridLeft = (1 << 4);
219+ static const unsigned int GridCenter = (1 << 5);
220+ static const unsigned int GridRight = (1 << 6);
221+ static const unsigned int GridTopLeft = (1 << 7);
222+ static const unsigned int GridTop = (1 << 8);
223+ static const unsigned int GridTopRight = (1 << 9);
224+ static const unsigned int GridMaximize = (1 << 10);
225+};
226+
227+typedef unsigned int GridType;
228
229 typedef struct _GridProps
230 {
231@@ -160,11 +162,13 @@
232
233 bool isGridResized;
234 bool isGridMaximized;
235+ unsigned int grabMask;
236 int pointerBufDx;
237 int pointerBufDy;
238 int resizeCount;
239 CompRect currentSize;
240 CompRect originalSize;
241+ CompWindowExtents lastBorder;
242 GridType lastTarget;
243
244 void grabNotify (int, int, unsigned int, unsigned int);
245@@ -174,6 +178,8 @@
246 void moveNotify (int, int, bool);
247
248 void stateChangeNotify (unsigned int);
249+
250+ void windowNotify (CompWindowNotify n);
251 };
252
253 #define GRID_WINDOW(w) \

Subscribers

People subscribed via source and target branches