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

Proposed by Sam Spilsbury
Status: Merged
Merge reported by: Sam Spilsbury
Merged at revision: not available
Proposed branch: lp:~smspillaz/compiz-grid-plugin/oneiric.fix_750316
Merge into: lp:compiz-grid-plugin
Diff against target: 379 lines (+135/-34)
3 files modified
grid.xml.in (+14/-14)
src/grid.cpp (+114/-20)
src/grid.h (+7/-0)
To merge this branch: bzr merge lp:~smspillaz/compiz-grid-plugin/oneiric.fix_750316
Reviewer Review Type Date Requested Status
Jason Smith (community) Approve
Review via email: mp+77336@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 'grid.xml.in'
2--- grid.xml.in 2010-09-28 22:30:57 +0000
3+++ grid.xml.in 2011-09-28 14:48:22 +0000
4@@ -84,7 +84,7 @@
5 <option name="top_left_corner_action" type="int">
6 <_short>Upper Left Corner</_short>
7 <_long>Action to be performed when window is dropped on the top left corner</_long>
8- <default>7</default>
9+ <default>4</default>
10 <min>0</min>
11 <max>10</max>
12 <desc>
13@@ -186,7 +186,7 @@
14 <option name="top_right_corner_action" type="int">
15 <_short>Upper Right Corner</_short>
16 <_long>Action to be performed when window is dropped on the top right corner</_long>
17- <default>9</default>
18+ <default>6</default>
19 <min>0</min>
20 <max>10</max>
21 <desc>
22@@ -339,7 +339,7 @@
23 <option name="bottom_left_corner_action" type="int">
24 <_short>Bottom Left Corner</_short>
25 <_long>Action to be performed when window is dropped on the bottom left corner</_long>
26- <default>1</default>
27+ <default>4</default>
28 <min>0</min>
29 <max>10</max>
30 <desc>
31@@ -390,7 +390,7 @@
32 <option name="bottom_edge_action" type="int">
33 <_short>Bottom Edge</_short>
34 <_long>Action to be performed when window is dropped on the bottom edge</_long>
35- <default>2</default>
36+ <default>0</default>
37 <min>0</min>
38 <max>10</max>
39 <desc>
40@@ -441,7 +441,7 @@
41 <option name="bottom_right_corner_action" type="int">
42 <_short>Bottom Right Corner</_short>
43 <_long>Action to be performed when window is dropped on the bottom right corner</_long>
44- <default>3</default>
45+ <default>6</default>
46 <min>0</min>
47 <max>10</max>
48 <desc>
49@@ -505,21 +505,21 @@
50 <option name="left_edge_threshold" type="int">
51 <_short>Left Edge</_short>
52 <_long>Maximum number of pixels from the left edge a window can be dropped</_long>
53- <default>5</default>
54+ <default>15</default>
55 <min>0</min>
56 <max>500</max>
57 </option>
58 <option name="right_edge_threshold" type="int">
59 <_short>Right Edge</_short>
60 <_long>Maximum number of pixels from the right edge a window can be dropped</_long>
61- <default>5</default>
62+ <default>15</default>
63 <min>0</min>
64 <max>500</max>
65 </option>
66 <option name="top_edge_threshold" type="int">
67 <_short>Top Edge</_short>
68 <_long>Maximum number of pixels from the top edge a window can be dropped</_long>
69- <default>5</default>
70+ <default>20</default>
71 <min>0</min>
72 <max>500</max>
73 </option>
74@@ -543,9 +543,9 @@
75 <_short>Outline Color</_short>
76 <_long>Color of the resize indicator outline</_long>
77 <default>
78- <red>0x2f2f</red>
79- <green>0x2f2f</green>
80- <blue>0x4f4f</blue>
81+ <red>0xfbfb</red>
82+ <green>0x8b8b</green>
83+ <blue>0x0</blue>
84 <alpha>0x9f9f</alpha>
85 </default>
86 </option>
87@@ -553,9 +553,9 @@
88 <_short>Fill Color</_short>
89 <_long>Fill color of the resize indicator</_long>
90 <default>
91- <red>0x2f2f</red>
92- <green>0x2f2f</green>
93- <blue>0x4f4f</blue>
94+ <red>0xfbfb</red>
95+ <green>0x8b8b</green>
96+ <blue>0x0</blue>
97 <alpha>0x4f4f</alpha>
98 </default>
99 </option>
100
101=== modified file 'src/grid.cpp'
102--- src/grid.cpp 2011-09-24 06:59:55 +0000
103+++ src/grid.cpp 2011-09-28 14:48:22 +0000
104@@ -43,6 +43,23 @@
105 {0,0, 1,1},
106 };
107
108+void
109+GridScreen::handleCompizEvent(const char* plugin,
110+ const char* event,
111+ CompOption::Vector& o)
112+{
113+ if (strcmp(event, "start_viewport_switch") == 0)
114+ {
115+ mSwitchingVp = true;
116+ }
117+ else if (strcmp(event, "end_viewport_switch") == 0)
118+ {
119+ mSwitchingVp = false;
120+ }
121+
122+ screen->handleCompizEvent(plugin, event, o);
123+}
124+
125 CompRect
126 GridScreen::slotToRect (CompWindow *w,
127 const CompRect& slot)
128@@ -128,13 +145,13 @@
129 xid = CompOption::getIntOptionNamed (option, "window");
130 cw = screen->findWindow (xid);
131
132- if (where == GridUnknown || screen->otherGrabExist ("move", NULL))
133- return false;
134-
135 if (cw)
136 {
137 XWindowChanges xwc;
138
139+ if (where == GridUnknown)
140+ return false;
141+
142 GRID_WINDOW (cw);
143
144 if (gw->lastTarget != where)
145@@ -322,12 +339,42 @@
146 /* TODO: animate move+resize */
147 if (resize)
148 {
149- cw->configureXWindow (CWX | CWY | CWWidth | CWHeight, &xwc);
150- gw->isGridResized = true;
151- gw->isGridMaximized = false;
152- for (unsigned int i = 0; i < animations.size (); i++)
153- animations.at (i).fadingOut = true;
154+ unsigned int valueMask = CWX | CWY | CWWidth | CWHeight;
155 gw->lastTarget = where;
156+ gw->currentSize = CompRect (wc.x, wc.y, wc.width, wc.height);
157+
158+ /* Special case for left and right, actually vertically maximize
159+ * the window */
160+ if (where == GridLeft || where == GridRight)
161+ {
162+ /* First restore the window to its original size */
163+ XWindowChanges rwc;
164+
165+ rwc.x = gw->originalSize.x ();
166+ rwc.y = gw->originalSize.y ();
167+ rwc.width = gw->originalSize.width ();
168+ rwc.height = gw->originalSize.height ();
169+
170+ cw->configureXWindow (CWX | CWY | CWWidth | CWHeight, &rwc);
171+
172+ gw->isGridMaximized = true;
173+ gw->isGridResized = false;
174+
175+ gw->lastBorder = cw->border ();
176+ /* Maximize the window */
177+ cw->maximize (CompWindowStateMaximizedVertMask);
178+ }
179+ else
180+ {
181+ gw->isGridResized = true;
182+ gw->isGridMaximized = false;
183+ }
184+
185+ /* Make window the size that we want */
186+ cw->configureXWindow (valueMask, &xwc);
187+
188+ for (unsigned int i = 0; i < animations.size (); i++)
189+ animations.at (i).fadingOut = true;
190 }
191
192 /* This centers a window if it could not be resized to the desired
193@@ -646,21 +693,22 @@
194 unsigned int state,
195 unsigned int mask)
196 {
197- if (screen->grabExist ("move"))
198+ if (mask & (CompWindowGrabMoveMask | CompWindowGrabButtonMask))
199 {
200 gScreen->o[0].value ().set ((int) window->id ());
201
202 screen->handleEventSetEnabled (gScreen, true);
203 gScreen->mGrabWindow = window;
204 pointerBufDx = pointerBufDy = 0;
205+ grabMask = mask;
206
207- if (!isGridResized && gScreen->optionGetSnapbackWindows ())
208+ if (!isGridResized && !isGridMaximized && gScreen->optionGetSnapbackWindows ())
209 /* Store size not including borders when grabbing with cursor */
210 originalSize = gScreen->slotToRect(window,
211 window->serverBorderRect ());
212 }
213
214- if (screen->grabExist ("resize"))
215+ if (mask & CompWindowGrabResizeMask)
216 {
217 isGridResized = false;
218 resizeCount = 0;
219@@ -679,6 +727,7 @@
220 gScreen->edge != gScreen->lastResizeEdge);
221
222 screen->handleEventSetEnabled (gScreen, false);
223+ grabMask = 0;
224 gScreen->mGrabWindow = NULL;
225 gScreen->o[0].value ().set (0);
226 gScreen->cScreen->damageRegion (gScreen->desiredSlot);
227@@ -695,17 +744,20 @@
228 {
229 window->moveNotify (dx, dy, immediate);
230
231- if (isGridResized)
232+ if (isGridResized && !isGridMaximized && !GridScreen::get (screen)->mSwitchingVp)
233 {
234- pointerBufDx += dx;
235- pointerBufDy += dy;
236+ if (window->grabbed () && (grabMask & CompWindowGrabMoveMask))
237+ {
238+ pointerBufDx += dx;
239+ pointerBufDy += dy;
240+ }
241
242 /* Do not allow the window to be moved while it
243 * is resized */
244+ dx = currentSize.x () - window->geometry ().x ();
245+ dy = currentSize.y () - window->geometry ().y ();
246
247- window->moveNotifySetEnabled (this, false);
248- window->move (-dx, -dy);
249- window->moveNotifySetEnabled (this, true);
250+ window->move (dx, dy);
251 }
252 }
253
254@@ -717,11 +769,49 @@
255 lastTarget = GridUnknown;
256 else if (!(lastState & MAXIMIZE_STATE) &&
257 window->state () & MAXIMIZE_STATE)
258+ {
259 lastTarget = GridMaximize;
260+ if (window->grabbed ())
261+ {
262+ originalSize = gScreen->slotToRect (window,
263+ window->serverBorderRect ());
264+ }
265+ }
266
267 window->stateChangeNotify (lastState);
268-}
269-
270+}
271+
272+void
273+GridWindow::windowNotify (CompWindowNotify n)
274+{
275+ if (n == CompWindowNotifyFrameUpdate)
276+ {
277+ if (isGridMaximized && !((window->state () & MAXIMIZE_STATE) == MAXIMIZE_STATE))
278+ {
279+ unsigned int valueMask = 0;
280+ XWindowChanges xwc;
281+
282+ int dw = (lastBorder.left + lastBorder.right) -
283+ (window->border ().left + window->border ().right);
284+
285+ int dh = (lastBorder.top + lastBorder.bottom) -
286+ (window->border ().top + window->border ().bottom);
287+
288+ if (dw != 0)
289+ valueMask |= CWWidth;
290+ if (dh != 0)
291+ valueMask |= CWHeight;
292+ xwc.width = window->serverGeometry ().width () + dw;
293+ xwc.height = window->serverGeometry ().height () + dh;
294+
295+ window->configureXWindow (valueMask, &xwc);
296+ }
297+
298+ lastBorder = window->border ();
299+ }
300+
301+ window->windowNotify (n);
302+}
303 bool
304 GridScreen::restoreWindow (CompAction *action,
305 CompAction::State state,
306@@ -755,6 +845,7 @@
307 xwc.width = gw->originalSize.width ();
308 xwc.height = gw->originalSize.height ();
309 cw->maximize (0);
310+ gw->currentSize = CompRect ();
311 cw->configureXWindow (CWX | CWY | CWWidth | CWHeight, &xwc);
312 gw->pointerBufDx = 0;
313 gw->pointerBufDy = 0;
314@@ -860,11 +951,13 @@
315 glScreen (GLScreen::get (screen)),
316 centerCheck (false),
317 mGrabWindow (NULL),
318- animating (false)
319+ animating (false),
320+ mSwitchingVp (false)
321 {
322 o.push_back (CompOption ("window", CompOption::TypeInt));
323
324 ScreenInterface::setHandler (screen, false);
325+ screen->handleCompizEventSetEnabled (this, true);
326 CompositeScreenInterface::setHandler (cScreen, false);
327 GLScreenInterface::setHandler (glScreen, false);
328
329@@ -903,6 +996,7 @@
330 PluginClassHandler <GridWindow, CompWindow> (window),
331 window (window),
332 gScreen (GridScreen::get (screen)),
333+ grabMask (0),
334 isGridResized (false),
335 isGridMaximized (false),
336 pointerBufDx (0),
337
338=== modified file 'src/grid.h'
339--- src/grid.h 2011-09-24 06:59:55 +0000
340+++ src/grid.h 2011-09-28 14:48:22 +0000
341@@ -106,6 +106,7 @@
342 bool centerCheck;
343 CompWindow *mGrabWindow;
344 bool animating;
345+ bool mSwitchingVp;
346
347 void getPaintRectangle (CompRect&);
348 void setCurrentRect (Animation&);
349@@ -128,6 +129,7 @@
350 GridType edgeToGridType ();
351
352 void handleEvent (XEvent *event);
353+ void handleCompizEvent (const char *plugin, const char *event, CompOption::Vector &options);
354
355 bool restoreWindow (CompAction*,
356 CompAction::State,
357@@ -158,10 +160,13 @@
358
359 bool isGridResized;
360 bool isGridMaximized;
361+ unsigned int grabMask;
362 int pointerBufDx;
363 int pointerBufDy;
364 int resizeCount;
365+ CompRect currentSize;
366 CompRect originalSize;
367+ CompWindowExtents lastBorder;
368 GridType lastTarget;
369
370 void grabNotify (int, int, unsigned int, unsigned int);
371@@ -171,6 +176,8 @@
372 void moveNotify (int, int, bool);
373
374 void stateChangeNotify (unsigned int);
375+
376+ void windowNotify (CompWindowNotify n);
377 };
378
379 #define GRID_WINDOW(w) \

Subscribers

People subscribed via source and target branches