Merge lp:~vanvugt/compiz-grid-plugin/fix-910698 into lp:compiz-grid-plugin

Proposed by Daniel van Vugt
Status: Merged
Merged at revision: 100
Proposed branch: lp:~vanvugt/compiz-grid-plugin/fix-910698
Merge into: lp:compiz-grid-plugin
Diff against target: 764 lines (+327/-113)
3 files modified
CMakeLists.txt (+2/-0)
src/grid.cpp (+295/-97)
src/grid.h (+30/-16)
To merge this branch: bzr merge lp:~vanvugt/compiz-grid-plugin/fix-910698
Reviewer Review Type Date Requested Status
Compiz Maintainers Pending
Review via email: mp+88984@code.launchpad.net

Description of the change

Copy grid fixes from oneiric-proposed, which apparently never made it upstream yet (LP: #910698)

They are fixes for:
(LP: #860257) (LP: #827560) (LP: #865177) (LP: #865179) (LP: #862260) (LP: #875557) (LP: #891886) (LP: #876591) (LP: #834585)

These changes don't need to be reviewed again, because they already got reviewed when they went into oneiric (and precise). This is just a straight file copy. And I have confirmed it builds and runs correctly.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2009-12-17 12:22:47 +0000
3+++ CMakeLists.txt 2012-01-18 07:48:23 +0000
4@@ -2,4 +2,6 @@
5
6 include (CompizPlugin)
7
8+set (CMAKE_CXX_FLAGS --std=c++0x)
9+
10 compiz_plugin(grid PLUGINDEPS composite opengl)
11
12=== modified file 'src/grid.cpp'
13--- src/grid.cpp 2011-09-29 15:54:11 +0000
14+++ src/grid.cpp 2012-01-18 07:48:23 +0000
15@@ -24,24 +24,26 @@
16
17 #include "grid.h"
18
19-static const GridProps gridProps[] =
20+using namespace GridWindowType;
21+
22+static std::map <unsigned int, GridProps> gridProps;
23+
24+void
25+GridScreen::handleCompizEvent(const char* plugin,
26+ const char* event,
27+ CompOption::Vector& o)
28 {
29- {0,1, 1,1},
30-
31- {0,1, 2,2},
32- {0,1, 1,2},
33- {1,1, 2,2},
34-
35- {0,0, 2,1},
36- {0,0, 1,1},
37- {1,0, 2,1},
38-
39- {0,0, 2,2},
40- {0,0, 1,2},
41- {1,0, 2,2},
42-
43- {0,0, 1,1},
44-};
45+ if (strcmp(event, "start_viewport_switch") == 0)
46+ {
47+ mSwitchingVp = true;
48+ }
49+ else if (strcmp(event, "end_viewport_switch") == 0)
50+ {
51+ mSwitchingVp = false;
52+ }
53+
54+ screen->handleCompizEvent(plugin, event, o);
55+}
56
57 CompRect
58 GridScreen::slotToRect (CompWindow *w,
59@@ -83,7 +85,7 @@
60 void
61 GridScreen::getPaintRectangle (CompRect &cRect)
62 {
63- if (edgeToGridType () != GridUnknown && optionGetDrawIndicator ())
64+ if (typeToMask (edgeToGridType ()) != GridUnknown && optionGetDrawIndicator ())
65 cRect = desiredSlot;
66 else
67 cRect.setGeometry (0, 0, 0, 0);
68@@ -118,8 +120,9 @@
69 GridScreen::initiateCommon (CompAction *action,
70 CompAction::State state,
71 CompOption::Vector &option,
72- GridType where,
73- bool resize)
74+ unsigned int where,
75+ bool resize,
76+ bool key)
77 {
78 Window xid;
79 CompWindow *cw = 0;
80@@ -127,17 +130,30 @@
81 xid = CompOption::getIntOptionNamed (option, "window");
82 cw = screen->findWindow (xid);
83
84- if (where == GridUnknown || screen->otherGrabExist ("move", NULL))
85- return false;
86-
87 if (cw)
88 {
89 XWindowChanges xwc;
90+ bool maximizeH = where & (GridBottom | GridTop | GridMaximize);
91+ bool maximizeV = where & (GridLeft | GridRight | GridMaximize);
92+
93+ if (!(cw->actions () & CompWindowActionResizeMask))
94+ return false;
95+
96+ if (maximizeH && !(cw->actions () & CompWindowActionMaximizeHorzMask))
97+ return false;
98+
99+ if (maximizeV && !(cw->actions () & CompWindowActionMaximizeVertMask))
100+ return false;
101+
102+ if (where & GridUnknown)
103+ return false;
104
105 GRID_WINDOW (cw);
106
107- if (gw->lastTarget != where)
108+ if (gw->lastTarget & ~(where))
109 gw->resizeCount = 0;
110+ else if (!key)
111+ return false;
112
113 props = gridProps[where];
114
115@@ -164,7 +180,7 @@
116 cw->maximize (0);
117 }
118
119- if (where == GridMaximize && resize)
120+ if ((where & GridMaximize) && resize)
121 {
122 /* move the window to the correct output */
123 if (cw == mGrabWindow)
124@@ -198,7 +214,13 @@
125 desiredSlot.setWidth (workarea.width () / props.numCellsX);
126
127 /* Adjust for constraints and decorations */
128- desiredRect = constrainSize (cw, desiredSlot);
129+ if (where & ~(GridMaximize | GridLeft | GridRight))
130+ {
131+ desiredRect = constrainSize (cw, desiredSlot);
132+ }
133+ else
134+ desiredRect = slotToRect (cw, desiredSlot);
135+
136 /* Get current rect not including decorations */
137 currentRect.setGeometry (cw->serverX (), cw->serverY (),
138 cw->serverWidth (),
139@@ -206,7 +228,7 @@
140
141 if (desiredRect.y () == currentRect.y () &&
142 desiredRect.height () == currentRect.height () &&
143- where != GridMaximize && gw->lastTarget == where)
144+ where & ~(GridMaximize | GridLeft | GridRight) && gw->lastTarget & where)
145 {
146 int slotWidth25 = workarea.width () / 4;
147 int slotWidth33 = (workarea.width () / 3) + cw->border ().left;
148@@ -319,12 +341,61 @@
149 /* TODO: animate move+resize */
150 if (resize)
151 {
152- cw->configureXWindow (CWX | CWY | CWWidth | CWHeight, &xwc);
153- gw->isGridResized = true;
154- gw->isGridMaximized = false;
155- for (unsigned int i = 0; i < animations.size (); i++)
156- animations.at (i).fadingOut = true;
157+ unsigned int valueMask = CWX | CWY | CWWidth | CWHeight;
158 gw->lastTarget = where;
159+ gw->currentSize = CompRect (wc.x, wc.y, wc.width, wc.height);
160+ CompWindowExtents lastBorder = gw->window->border ();
161+
162+ gw->sizeHintsFlags = 0;
163+
164+ /* Special case for left and right, actually vertically maximize
165+ * the window */
166+ if (where & GridLeft || where & GridRight)
167+ {
168+ /* First restore the window to its original size */
169+ XWindowChanges rwc;
170+
171+ rwc.x = gw->originalSize.x ();
172+ rwc.y = gw->originalSize.y ();
173+ rwc.width = gw->originalSize.width ();
174+ rwc.height = gw->originalSize.height ();
175+
176+ cw->configureXWindow (CWX | CWY | CWWidth | CWHeight, &rwc);
177+
178+ gw->isGridMaximized = true;
179+ gw->isGridResized = false;
180+
181+ /* Maximize the window */
182+ cw->maximize (CompWindowStateMaximizedVertMask);
183+ /* Be evil */
184+ if (cw->sizeHints ().flags & PResizeInc)
185+ {
186+ gw->sizeHintsFlags |= PResizeInc;
187+ gw->window->sizeHints ().flags &= ~(PResizeInc);
188+ }
189+ }
190+ else
191+ {
192+ gw->isGridResized = true;
193+ gw->isGridMaximized = false;
194+ }
195+
196+ int dw = (lastBorder.left + lastBorder.right) -
197+ (gw->window->border ().left +
198+ gw->window->border ().right);
199+
200+ int dh = (lastBorder.top + lastBorder.bottom) -
201+ (gw->window->border ().top +
202+ gw->window->border ().bottom);
203+
204+ xwc.width += dw;
205+ xwc.height += dh;
206+
207+ /* Make window the size that we want */
208+ cw->configureXWindow (valueMask, &xwc);
209+
210+ for (unsigned int i = 0; i < animations.size (); i++)
211+ animations.at (i).fadingOut = true;
212 }
213
214 /* This centers a window if it could not be resized to the desired
215@@ -376,12 +447,14 @@
216
217 for (iter = animations.begin (); iter != animations.end () && animating; iter++)
218 {
219- GLushort *color;
220 Animation& anim = *iter;
221+ float alpha = ((float) optionGetFillColorAlpha () / 65535.0f) * anim.opacity;
222
223- color = optionGetFillColor ();
224- glColor4us (anim.opacity * color[0], anim.opacity * color[1],
225- anim.opacity * color[2], anim.opacity * color[3]);
226+ /* fill rectangle */
227+ glColor4f (((float) optionGetFillColorRed () / 65535.0f) * alpha,
228+ ((float) optionGetFillColorGreen () / 65535.0f) * alpha,
229+ ((float) optionGetFillColorBlue () / 65535.0f) * alpha,
230+ alpha);
231
232 /* fill rectangle */
233 glRecti (anim.currentRect.x1 (), anim.currentRect.y2 (),
234@@ -389,14 +462,17 @@
235
236 /* Set outline rect smaller to avoid damage issues */
237 anim.currentRect.setGeometry (anim.currentRect.x () + 1,
238- anim.currentRect.y () + 1,
239- anim.currentRect.width () - 2,
240- anim.currentRect.height () - 2);
241+ anim.currentRect.y () + 1,
242+ anim.currentRect.width () - 2,
243+ anim.currentRect.height () - 2);
244+
245+ alpha = (float) (optionGetOutlineColorAlpha () / 65535.0f) * anim.opacity;
246
247 /* draw outline */
248- color = optionGetOutlineColor ();
249- glColor4us (anim.opacity * color[0], anim.opacity * color[1],
250- anim.opacity * color[2], anim.opacity * color[3]);
251+ glColor4f (((float) optionGetOutlineColorRed () / 65535.0f) * alpha,
252+ ((float) optionGetOutlineColorGreen () / 65535.0f) * alpha,
253+ ((float) optionGetOutlineColorBlue () / 65535.0f) * alpha,
254+ alpha);
255
256 glLineWidth (2.0);
257
258@@ -411,7 +487,13 @@
259 if (!animating)
260 {
261 /* fill rectangle */
262- glColor4usv (optionGetFillColor ());
263+ float alpha = (float) optionGetFillColorAlpha () / 65535.0f;
264+
265+ /* fill rectangle */
266+ glColor4f (((float) optionGetFillColorRed () / 65535.0f) * alpha,
267+ ((float) optionGetFillColorGreen () / 65535.0f) * alpha,
268+ ((float) optionGetFillColorBlue () / 65535.0f) * alpha,
269+ alpha);
270 glRecti (rect.x1 (), rect.y2 (), rect.x2 (), rect.y1 ());
271
272 /* Set outline rect smaller to avoid damage issues */
273@@ -419,7 +501,14 @@
274 rect.width () - 2, rect.height () - 2);
275
276 /* draw outline */
277- glColor4usv (optionGetOutlineColor ());
278+ alpha = (float) optionGetOutlineColorAlpha () / 65535.0f;
279+
280+ /* draw outline */
281+ glColor4f (((float) optionGetOutlineColorRed () / 65535.0f) * alpha,
282+ ((float) optionGetOutlineColorGreen () / 65535.0f) * alpha,
283+ ((float) optionGetOutlineColorBlue () / 65535.0f) * alpha,
284+ alpha);
285+
286 glLineWidth (2.0);
287 glBegin (GL_LINE_LOOP);
288 glVertex2i (rect.x1 (), rect.y1 ());
289@@ -452,39 +541,72 @@
290 return status;
291 }
292
293-GridType
294+unsigned int
295+GridScreen::typeToMask (int t)
296+{
297+ typedef struct {
298+ unsigned int mask;
299+ int type;
300+ } GridTypeMask;
301+
302+ std::vector <GridTypeMask> type =
303+ {
304+ { GridWindowType::GridUnknown, 0 },
305+ { GridWindowType::GridBottomLeft, 1 },
306+ { GridWindowType::GridBottom, 2 },
307+ { GridWindowType::GridBottomRight, 3 },
308+ { GridWindowType::GridLeft, 4 },
309+ { GridWindowType::GridCenter, 5 },
310+ { GridWindowType::GridRight, 6 },
311+ { GridWindowType::GridTopLeft, 7 },
312+ { GridWindowType::GridTop, 8 },
313+ { GridWindowType::GridTopRight, 9 },
314+ { GridWindowType::GridMaximize, 10 }
315+ };
316+
317+ for (unsigned int i = 0; i < type.size (); i++)
318+ {
319+ GridTypeMask &tm = type[i];
320+ if (tm.type == t)
321+ return tm.mask;
322+ }
323+
324+ return GridWindowType::GridUnknown;
325+}
326+
327+int
328 GridScreen::edgeToGridType ()
329 {
330- GridType ret;
331+ int ret;
332
333 switch (edge) {
334 case Left:
335- ret = (GridType) optionGetLeftEdgeAction ();
336+ ret = (int) optionGetLeftEdgeAction ();
337 break;
338 case Right:
339- ret = (GridType) optionGetRightEdgeAction ();
340+ ret = (int) optionGetRightEdgeAction ();
341 break;
342 case Top:
343- ret = (GridType) optionGetTopEdgeAction ();
344+ ret = (int) optionGetTopEdgeAction ();
345 break;
346 case Bottom:
347- ret = (GridType) optionGetBottomEdgeAction ();
348+ ret = (int) optionGetBottomEdgeAction ();
349 break;
350 case TopLeft:
351- ret = (GridType) optionGetTopLeftCornerAction ();
352+ ret = (int) optionGetTopLeftCornerAction ();
353 break;
354 case TopRight:
355- ret = (GridType) optionGetTopRightCornerAction ();
356+ ret = (int) optionGetTopRightCornerAction ();
357 break;
358 case BottomLeft:
359- ret = (GridType) optionGetBottomLeftCornerAction ();
360+ ret = (int) optionGetBottomLeftCornerAction ();
361 break;
362 case BottomRight:
363- ret = (GridType) optionGetBottomRightCornerAction ();
364+ ret = (int) optionGetBottomRightCornerAction ();
365 break;
366 case NoEdge:
367 default:
368- ret = GridUnknown;
369+ ret = -1;
370 break;
371 }
372
373@@ -495,6 +617,8 @@
374 GridScreen::handleEvent (XEvent *event)
375 {
376 CompOutput out;
377+ CompWindow *w;
378+ bool check = false;
379
380 screen->handleEvent (event);
381
382@@ -548,7 +672,7 @@
383 if (cScreen)
384 cScreen->damageRegion (desiredSlot);
385
386- initiateCommon (0, 0, o, edgeToGridType (), false);
387+ initiateCommon (0, 0, o, typeToMask (edgeToGridType ()), false, false);
388
389 if (cScreen)
390 cScreen->damageRegion (desiredSlot);
391@@ -566,7 +690,7 @@
392 if (cScreen)
393 cScreen->damageRegion (desiredSlot);
394
395- initiateCommon (0, 0, o, edgeToGridType (), false);
396+ check = initiateCommon (NULL, 0, o, typeToMask (edgeToGridType ()), false, false);
397
398 if (cScreen)
399 cScreen->damageRegion (desiredSlot);
400@@ -577,7 +701,7 @@
401 /* Begin fading previous animation instance */
402 animations.at (animations.size () - 1).fadingOut = true;
403
404- if (edge != NoEdge)
405+ if (edge != NoEdge && check)
406 {
407 CompWindow *cw = screen->findWindow (screen->activeWindow ());
408 animations.push_back (Animation ());
409@@ -601,16 +725,35 @@
410 lastEdge = edge;
411 }
412
413- GRID_WINDOW (screen->findWindow
414- (CompOption::getIntOptionNamed (o, "window")));
415-
416- if ((gw->pointerBufDx > SNAPOFF_THRESHOLD ||
417- gw->pointerBufDy > SNAPOFF_THRESHOLD ||
418- gw->pointerBufDx < -SNAPOFF_THRESHOLD ||
419- gw->pointerBufDy < -SNAPOFF_THRESHOLD) &&
420- gw->isGridResized &&
421- optionGetSnapbackWindows ())
422- restoreWindow (0, 0, o);
423+ w = screen->findWindow (CompOption::getIntOptionNamed (o, "window"));
424+
425+ if (w)
426+ {
427+ GRID_WINDOW (w);
428+
429+ if ((gw->pointerBufDx > SNAPOFF_THRESHOLD ||
430+ gw->pointerBufDy > SNAPOFF_THRESHOLD ||
431+ gw->pointerBufDx < -SNAPOFF_THRESHOLD ||
432+ gw->pointerBufDy < -SNAPOFF_THRESHOLD) &&
433+ gw->isGridResized &&
434+ optionGetSnapbackWindows ())
435+ restoreWindow (0, 0, o);
436+ }
437+}
438+
439+void
440+GridWindow::validateResizeRequest (unsigned int &xwcm,
441+ XWindowChanges *xwc,
442+ unsigned int source)
443+{
444+ window->validateResizeRequest (xwcm, xwc, source);
445+
446+ /* Don't allow non-pagers to change
447+ * the size of the window, the user
448+ * specified this size, thank-you */
449+ if (isGridMaximized)
450+ if (source != ClientTypePager)
451+ xwcm = 0;
452 }
453
454 void
455@@ -619,22 +762,23 @@
456 unsigned int state,
457 unsigned int mask)
458 {
459- if (screen->grabExist ("move"))
460+ if ((mask & (CompWindowGrabMoveMask | CompWindowGrabButtonMask)) &&
461+ !(mask & CompWindowGrabResizeMask))
462 {
463- gScreen->o.push_back (CompOption ("window", CompOption::TypeInt));
464 gScreen->o[0].value ().set ((int) window->id ());
465
466 screen->handleEventSetEnabled (gScreen, true);
467 gScreen->mGrabWindow = window;
468 pointerBufDx = pointerBufDy = 0;
469+ grabMask = mask;
470
471- if (!isGridResized && gScreen->optionGetSnapbackWindows ())
472+ if (!isGridResized && !isGridMaximized && gScreen->optionGetSnapbackWindows ())
473 /* Store size not including borders when grabbing with cursor */
474 originalSize = gScreen->slotToRect(window,
475 window->serverBorderRect ());
476 }
477
478- if (screen->grabExist ("resize"))
479+ if (mask & CompWindowGrabResizeMask)
480 {
481 isGridResized = false;
482 resizeCount = 0;
483@@ -649,13 +793,17 @@
484 if (window == gScreen->mGrabWindow)
485 {
486 gScreen->initiateCommon
487- (0, 0, gScreen->o, gScreen->edgeToGridType (), true);
488+ (NULL, 0, gScreen->o, gScreen->typeToMask (gScreen->edgeToGridType ()), true,
489+ gScreen->edge != gScreen->lastResizeEdge);
490
491 screen->handleEventSetEnabled (gScreen, false);
492+ grabMask = 0;
493 gScreen->mGrabWindow = NULL;
494+ gScreen->o[0].value ().set (0);
495 gScreen->cScreen->damageRegion (gScreen->desiredSlot);
496 }
497
498+ gScreen->lastResizeEdge = gScreen->edge;
499 gScreen->edge = NoEdge;
500
501 window->ungrabNotify ();
502@@ -666,18 +814,41 @@
503 {
504 window->moveNotify (dx, dy, immediate);
505
506- if (isGridResized)
507+ if (isGridResized && !isGridMaximized && !GridScreen::get (screen)->mSwitchingVp)
508 {
509- pointerBufDx += dx;
510- pointerBufDy += dy;
511+ if (window->grabbed () && (grabMask & CompWindowGrabMoveMask))
512+ {
513+ pointerBufDx += dx;
514+ pointerBufDy += dy;
515+ }
516
517 /* Do not allow the window to be moved while it
518 * is resized */
519-
520- window->moveNotifySetEnabled (this, false);
521- window->move (-dx, -dy);
522- window->moveNotifySetEnabled (this, true);
523- }
524+ dx = currentSize.x () - window->geometry ().x ();
525+ dy = currentSize.y () - window->geometry ().y ();
526+
527+ window->move (dx, dy);
528+ }
529+}
530+
531+void
532+GridWindow::stateChangeNotify (unsigned int lastState)
533+{
534+ if (lastState & MAXIMIZE_STATE &&
535+ !(window->state () & MAXIMIZE_STATE))
536+ lastTarget = GridUnknown;
537+ else if (!(lastState & MAXIMIZE_STATE) &&
538+ window->state () & MAXIMIZE_STATE)
539+ {
540+ lastTarget = GridMaximize;
541+ if (window->grabbed ())
542+ {
543+ originalSize = gScreen->slotToRect (window,
544+ window->serverBorderRect ());
545+ }
546+ }
547+
548+ window->stateChangeNotify (lastState);
549 }
550
551 bool
552@@ -697,7 +868,10 @@
553 return false;
554
555 if (gw->isGridMaximized & !(cw->state () & MAXIMIZE_STATE))
556- gw->isGridMaximized = false;
557+ {
558+ gw->window->sizeHints ().flags |= gw->sizeHintsFlags;
559+ gw->isGridMaximized = false;
560+ }
561 else
562 {
563 if (cw == mGrabWindow)
564@@ -713,6 +887,7 @@
565 xwc.width = gw->originalSize.width ();
566 xwc.height = gw->originalSize.height ();
567 cw->maximize (0);
568+ gw->currentSize = CompRect ();
569 cw->configureXWindow (CWX | CWY | CWWidth | CWHeight, &xwc);
570 gw->pointerBufDx = 0;
571 gw->pointerBufDy = 0;
572@@ -818,33 +993,47 @@
573 glScreen (GLScreen::get (screen)),
574 centerCheck (false),
575 mGrabWindow (NULL),
576- animating (false)
577+ animating (false),
578+ mSwitchingVp (false)
579 {
580+ o.push_back (CompOption ("window", CompOption::TypeInt));
581
582 ScreenInterface::setHandler (screen, false);
583+ screen->handleCompizEventSetEnabled (this, true);
584 CompositeScreenInterface::setHandler (cScreen, false);
585 GLScreenInterface::setHandler (glScreen, false);
586
587- edge = lastEdge = NoEdge;
588+ edge = lastEdge = lastResizeEdge = NoEdge;
589 currentWorkarea = lastWorkarea = screen->getWorkareaForOutput
590 (screen->outputDeviceForPoint (pointerX, pointerY));
591+ gridProps[GridUnknown] = GridProps {0,1, 1,1};
592+ gridProps[GridBottomLeft] = GridProps {0,1, 2,2};
593+ gridProps[GridBottom] = GridProps {0,1, 1,2};
594+ gridProps[GridBottomRight] = GridProps {1,1, 2,2};
595+ gridProps[GridLeft] = GridProps {0,0, 2,1};
596+ gridProps[GridCenter] = GridProps{0,0, 1,1};
597+ gridProps[GridRight] = GridProps {1,0, 2,1};
598+ gridProps[GridTopLeft] = GridProps{0,0, 2,2};
599+ gridProps[GridTop] = GridProps {0,0, 1,2};
600+ gridProps[GridTopRight] = GridProps {1,0, 2,2};
601+ gridProps[GridMaximize] = GridProps {0,0, 1,1};
602
603 animations.clear ();
604
605-#define GRIDSET(opt,where,resize) \
606+#define GRIDSET(opt,where,resize,key) \
607 optionSet##opt##Initiate (boost::bind (&GridScreen::initiateCommon, this, \
608- _1, _2, _3, where, resize))
609+ _1, _2, _3, where, resize, key))
610
611- GRIDSET (PutCenterKey, GridCenter, true);
612- GRIDSET (PutLeftKey, GridLeft, true);
613- GRIDSET (PutRightKey, GridRight, true);
614- GRIDSET (PutTopKey, GridTop, true);
615- GRIDSET (PutBottomKey, GridBottom, true);
616- GRIDSET (PutTopleftKey, GridTopLeft, true);
617- GRIDSET (PutToprightKey, GridTopRight, true);
618- GRIDSET (PutBottomleftKey, GridBottomLeft, true);
619- GRIDSET (PutBottomrightKey, GridBottomRight, true);
620- GRIDSET (PutMaximizeKey, GridMaximize, true);
621+ GRIDSET (PutCenterKey, GridWindowType::GridCenter, true, true);
622+ GRIDSET (PutLeftKey, GridWindowType::GridLeft, true, true);
623+ GRIDSET (PutRightKey, GridWindowType::GridRight, true, true);
624+ GRIDSET (PutTopKey, GridWindowType::GridTop, true, true);
625+ GRIDSET (PutBottomKey, GridWindowType::GridBottom, true, true);
626+ GRIDSET (PutTopleftKey, GridWindowType::GridTopLeft, true, true);
627+ GRIDSET (PutToprightKey, GridWindowType::GridTopRight, true, true);
628+ GRIDSET (PutBottomleftKey, GridWindowType::GridBottomLeft, true, true);
629+ GRIDSET (PutBottomrightKey, GridWindowType::GridBottomRight, true, true);
630+ GRIDSET (PutMaximizeKey, GridWindowType::GridMaximize, true, true);
631
632 #undef GRIDSET
633
634@@ -862,14 +1051,23 @@
635 gScreen (GridScreen::get (screen)),
636 isGridResized (false),
637 isGridMaximized (false),
638+ grabMask (0),
639 pointerBufDx (0),
640 pointerBufDy (0),
641- resizeCount (0),
642+ resizeCount (0),
643 lastTarget (GridUnknown)
644 {
645 WindowInterface::setHandler (window);
646 }
647
648+GridWindow::~GridWindow ()
649+{
650+ if (gScreen->mGrabWindow == window)
651+ gScreen->mGrabWindow = NULL;
652+
653+ gScreen->o[0].value ().set (0);
654+}
655+
656 /* Initial plugin init function called. Checks to see if we are ABI
657 * compatible with core, otherwise unload */
658
659
660=== modified file 'src/grid.h'
661--- src/grid.h 2011-09-29 15:54:11 +0000
662+++ src/grid.h 2012-01-18 07:48:23 +0000
663@@ -32,20 +32,22 @@
664
665 #define SNAPOFF_THRESHOLD 50
666
667-typedef enum
668+namespace GridWindowType
669 {
670- GridUnknown = 0,
671- GridBottomLeft = 1,
672- GridBottom = 2,
673- GridBottomRight = 3,
674- GridLeft = 4,
675- GridCenter = 5,
676- GridRight = 6,
677- GridTopLeft = 7,
678- GridTop = 8,
679- GridTopRight = 9,
680- GridMaximize = 10
681-} GridType;
682+ static const unsigned int GridUnknown = (1 << 0);
683+ static const unsigned int GridBottomLeft = (1 << 1);
684+ static const unsigned int GridBottom = (1 << 2);
685+ static const unsigned int GridBottomRight = (1 << 3);
686+ static const unsigned int GridLeft = (1 << 4);
687+ static const unsigned int GridCenter = (1 << 5);
688+ static const unsigned int GridRight = (1 << 6);
689+ static const unsigned int GridTopLeft = (1 << 7);
690+ static const unsigned int GridTop = (1 << 8);
691+ static const unsigned int GridTopRight = (1 << 9);
692+ static const unsigned int GridMaximize = (1 << 10);
693+};
694+
695+typedef unsigned int GridType;
696
697 typedef struct _GridProps
698 {
699@@ -101,17 +103,18 @@
700 CompRect workarea, currentRect, desiredSlot, lastSlot,
701 desiredRect, lastWorkarea, currentWorkarea;
702 GridProps props;
703- Edges edge, lastEdge;
704+ Edges edge, lastEdge, lastResizeEdge;
705 CompOption::Vector o;
706 bool centerCheck;
707 CompWindow *mGrabWindow;
708 bool animating;
709+ bool mSwitchingVp;
710
711 void getPaintRectangle (CompRect&);
712 void setCurrentRect (Animation&);
713
714 bool initiateCommon (CompAction*, CompAction::State,
715- CompOption::Vector&, GridType, bool);
716+ CompOption::Vector&, unsigned int, bool, bool);
717
718 void glPaintRectangle (const GLScreenPaintAttrib&,
719 const GLMatrix&, CompOutput *);
720@@ -125,9 +128,11 @@
721
722 std::vector <Animation> animations;
723
724- GridType edgeToGridType ();
725+ int edgeToGridType ();
726+ unsigned int typeToMask (int);
727
728 void handleEvent (XEvent *event);
729+ void handleCompizEvent (const char *plugin, const char *event, CompOption::Vector &options);
730
731 bool restoreWindow (CompAction*,
732 CompAction::State,
733@@ -152,22 +157,31 @@
734 public:
735
736 GridWindow (CompWindow *);
737+ ~GridWindow ();
738 CompWindow *window;
739 GridScreen *gScreen;
740
741 bool isGridResized;
742 bool isGridMaximized;
743+ unsigned int grabMask;
744 int pointerBufDx;
745 int pointerBufDy;
746 int resizeCount;
747+ CompRect currentSize;
748 CompRect originalSize;
749 GridType lastTarget;
750+ unsigned int sizeHintsFlags;
751
752 void grabNotify (int, int, unsigned int, unsigned int);
753
754 void ungrabNotify ();
755
756 void moveNotify (int, int, bool);
757+
758+ void stateChangeNotify (unsigned int);
759+ void validateResizeRequest (unsigned int &valueMask,
760+ XWindowChanges *xwc,
761+ unsigned int source);
762 };
763
764 #define GRID_WINDOW(w) \

Subscribers

People subscribed via source and target branches