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

Proposed by Sam Spilsbury
Status: Merged
Merged at revision: 90
Proposed branch: lp:~compiz-team/compiz-grid-plugin/compiz-grid-plugin-oneiric.fix_862260
Merge into: lp:~compiz-team/compiz-grid-plugin/oneiric
Diff against target: 304 lines (+85/-51)
3 files modified
CMakeLists.txt (+2/-0)
src/grid.cpp (+80/-49)
src/grid.h (+3/-2)
To merge this branch: bzr merge lp:~compiz-team/compiz-grid-plugin/compiz-grid-plugin-oneiric.fix_862260
Reviewer Review Type Date Requested Status
Neil J. Patel (community) Approve
Review via email: mp+77505@code.launchpad.net

Description of the change

Fix LP Bug 862260

To post a comment you must log in.
Revision history for this message
Neil J. Patel (njpatel) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2009-12-17 12:22:47 +0000
+++ CMakeLists.txt 2011-09-29 11:23:07 +0000
@@ -2,4 +2,6 @@
22
3include (CompizPlugin)3include (CompizPlugin)
44
5set (CMAKE_CXX_FLAGS -std=c++0x)
6
5compiz_plugin(grid PLUGINDEPS composite opengl)7compiz_plugin(grid PLUGINDEPS composite opengl)
68
=== modified file 'src/grid.cpp'
--- src/grid.cpp 2011-09-28 16:58:29 +0000
+++ src/grid.cpp 2011-09-29 11:23:07 +0000
@@ -26,24 +26,7 @@
2626
27using namespace GridWindowType;27using namespace GridWindowType;
2828
29static const GridProps gridProps[] =29static std::map <unsigned int, GridProps> gridProps;
30{
31 {0,1, 1,1},
32
33 {0,1, 2,2},
34 {0,1, 1,2},
35 {1,1, 2,2},
36
37 {0,0, 2,1},
38 {0,0, 1,1},
39 {1,0, 2,1},
40
41 {0,0, 2,2},
42 {0,0, 1,2},
43 {1,0, 2,2},
44
45 {0,0, 1,1},
46};
4730
48void31void
49GridScreen::handleCompizEvent(const char* plugin,32GridScreen::handleCompizEvent(const char* plugin,
@@ -102,7 +85,7 @@
102void85void
103GridScreen::getPaintRectangle (CompRect &cRect)86GridScreen::getPaintRectangle (CompRect &cRect)
104{87{
105 if (edgeToGridType () != GridUnknown && optionGetDrawIndicator ())88 if (typeToMask (edgeToGridType ()) != GridUnknown && optionGetDrawIndicator ())
106 cRect = desiredSlot;89 cRect = desiredSlot;
107 else90 else
108 cRect.setGeometry (0, 0, 0, 0);91 cRect.setGeometry (0, 0, 0, 0);
@@ -137,7 +120,7 @@
137GridScreen::initiateCommon (CompAction *action,120GridScreen::initiateCommon (CompAction *action,
138 CompAction::State state,121 CompAction::State state,
139 CompOption::Vector &option,122 CompOption::Vector &option,
140 GridType where,123 unsigned int where,
141 bool resize,124 bool resize,
142 bool key)125 bool key)
143{126{
@@ -162,12 +145,12 @@
162 if (maximizeV && !(cw->actions () & CompWindowActionMaximizeVertMask))145 if (maximizeV && !(cw->actions () & CompWindowActionMaximizeVertMask))
163 return false;146 return false;
164147
165 if (where == GridUnknown)148 if (where & GridUnknown)
166 return false;149 return false;
167150
168 GRID_WINDOW (cw);151 GRID_WINDOW (cw);
169152
170 if (gw->lastTarget != where)153 if (gw->lastTarget & ~(where))
171 gw->resizeCount = 0;154 gw->resizeCount = 0;
172 else if (!key)155 else if (!key)
173 return false;156 return false;
@@ -197,7 +180,7 @@
197 cw->maximize (0);180 cw->maximize (0);
198 }181 }
199182
200 if (where == GridMaximize && resize)183 if ((where & GridMaximize) && resize)
201 {184 {
202 /* move the window to the correct output */185 /* move the window to the correct output */
203 if (cw == mGrabWindow)186 if (cw == mGrabWindow)
@@ -239,7 +222,7 @@
239222
240 if (desiredRect.y () == currentRect.y () &&223 if (desiredRect.y () == currentRect.y () &&
241 desiredRect.height () == currentRect.height () &&224 desiredRect.height () == currentRect.height () &&
242 where != GridMaximize && gw->lastTarget == where)225 where & ~(GridMaximize) && gw->lastTarget & where)
243 {226 {
244 int slotWidth25 = workarea.width () / 4;227 int slotWidth25 = workarea.width () / 4;
245 int slotWidth33 = (workarea.width () / 3) + cw->border ().left;228 int slotWidth33 = (workarea.width () / 3) + cw->border ().left;
@@ -358,7 +341,7 @@
358341
359 /* Special case for left and right, actually vertically maximize342 /* Special case for left and right, actually vertically maximize
360 * the window */343 * the window */
361 if (where == GridLeft || where == GridRight)344 if (where & GridLeft || where & GridRight)
362 {345 {
363 /* First restore the window to its original size */346 /* First restore the window to its original size */
364 XWindowChanges rwc;347 XWindowChanges rwc;
@@ -375,6 +358,7 @@
375358
376 gw->lastBorder = cw->border ();359 gw->lastBorder = cw->border ();
377 /* Maximize the window */360 /* Maximize the window */
361 printf ("maximizing window\n");
378 cw->maximize (CompWindowStateMaximizedVertMask);362 cw->maximize (CompWindowStateMaximizedVertMask);
379 }363 }
380 else364 else
@@ -533,39 +517,72 @@
533 return status;517 return status;
534}518}
535519
536GridType520unsigned int
521GridScreen::typeToMask (int t)
522{
523 typedef struct {
524 unsigned int mask;
525 int type;
526 } GridTypeMask;
527
528 std::vector <GridTypeMask> type =
529 {
530 { GridWindowType::GridUnknown, 0 },
531 { GridWindowType::GridBottomLeft, 1 },
532 { GridWindowType::GridBottom, 2 },
533 { GridWindowType::GridBottomRight, 3 },
534 { GridWindowType::GridLeft, 4 },
535 { GridWindowType::GridCenter, 5 },
536 { GridWindowType::GridRight, 6 },
537 { GridWindowType::GridTopLeft, 7 },
538 { GridWindowType::GridTop, 8 },
539 { GridWindowType::GridTopRight, 9 },
540 { GridWindowType::GridMaximize, 10 }
541 };
542
543 for (unsigned int i = 0; i < type.size (); i++)
544 {
545 GridTypeMask &tm = type[i];
546 if (tm.type == t)
547 return tm.mask;
548 }
549
550 return GridWindowType::GridUnknown;
551}
552
553int
537GridScreen::edgeToGridType ()554GridScreen::edgeToGridType ()
538{555{
539 GridType ret;556 int ret;
540557
541 switch (edge) {558 switch (edge) {
542 case Left:559 case Left:
543 ret = (GridType) optionGetLeftEdgeAction ();560 ret = (int) optionGetLeftEdgeAction ();
544 break;561 break;
545 case Right:562 case Right:
546 ret = (GridType) optionGetRightEdgeAction ();563 ret = (int) optionGetRightEdgeAction ();
547 break;564 break;
548 case Top:565 case Top:
549 ret = (GridType) optionGetTopEdgeAction ();566 ret = (int) optionGetTopEdgeAction ();
550 break;567 break;
551 case Bottom:568 case Bottom:
552 ret = (GridType) optionGetBottomEdgeAction ();569 ret = (int) optionGetBottomEdgeAction ();
553 break;570 break;
554 case TopLeft:571 case TopLeft:
555 ret = (GridType) optionGetTopLeftCornerAction ();572 ret = (int) optionGetTopLeftCornerAction ();
556 break;573 break;
557 case TopRight:574 case TopRight:
558 ret = (GridType) optionGetTopRightCornerAction ();575 ret = (int) optionGetTopRightCornerAction ();
559 break;576 break;
560 case BottomLeft:577 case BottomLeft:
561 ret = (GridType) optionGetBottomLeftCornerAction ();578 ret = (int) optionGetBottomLeftCornerAction ();
562 break;579 break;
563 case BottomRight:580 case BottomRight:
564 ret = (GridType) optionGetBottomRightCornerAction ();581 ret = (int) optionGetBottomRightCornerAction ();
565 break;582 break;
566 case NoEdge:583 case NoEdge:
567 default:584 default:
568 ret = GridUnknown;585 ret = -1;
569 break;586 break;
570 }587 }
571588
@@ -631,7 +648,7 @@
631 if (cScreen)648 if (cScreen)
632 cScreen->damageRegion (desiredSlot);649 cScreen->damageRegion (desiredSlot);
633650
634 initiateCommon (0, 0, o, edgeToGridType (), false, false);651 initiateCommon (0, 0, o, typeToMask (edgeToGridType ()), false, false);
635652
636 if (cScreen)653 if (cScreen)
637 cScreen->damageRegion (desiredSlot);654 cScreen->damageRegion (desiredSlot);
@@ -649,7 +666,7 @@
649 if (cScreen)666 if (cScreen)
650 cScreen->damageRegion (desiredSlot);667 cScreen->damageRegion (desiredSlot);
651668
652 check = initiateCommon (0, 0, o, edgeToGridType (), false, false);669 check = initiateCommon (NULL, 0, o, typeToMask (edgeToGridType ()), false, false);
653670
654 if (cScreen)671 if (cScreen)
655 cScreen->damageRegion (desiredSlot);672 cScreen->damageRegion (desiredSlot);
@@ -736,7 +753,7 @@
736 if (window == gScreen->mGrabWindow)753 if (window == gScreen->mGrabWindow)
737 {754 {
738 gScreen->initiateCommon755 gScreen->initiateCommon
739 (0, 0, gScreen->o, gScreen->edgeToGridType (), true,756 (NULL, 0, gScreen->o, gScreen->typeToMask (gScreen->edgeToGridType ()), true,
740 gScreen->edge != gScreen->lastResizeEdge);757 gScreen->edge != gScreen->lastResizeEdge);
741758
742 screen->handleEventSetEnabled (gScreen, false);759 screen->handleEventSetEnabled (gScreen, false);
@@ -770,6 +787,8 @@
770 dx = currentSize.x () - window->geometry ().x ();787 dx = currentSize.x () - window->geometry ().x ();
771 dy = currentSize.y () - window->geometry ().y ();788 dy = currentSize.y () - window->geometry ().y ();
772789
790 printf ("offset move\n");
791
773 window->move (dx, dy);792 window->move (dx, dy);
774 }793 }
775}794}
@@ -859,6 +878,7 @@
859 xwc.height = gw->originalSize.height ();878 xwc.height = gw->originalSize.height ();
860 cw->maximize (0);879 cw->maximize (0);
861 gw->currentSize = CompRect ();880 gw->currentSize = CompRect ();
881 printf ("attempting snapBack\n");
862 cw->configureXWindow (CWX | CWY | CWWidth | CWHeight, &xwc);882 cw->configureXWindow (CWX | CWY | CWWidth | CWHeight, &xwc);
863 gw->pointerBufDx = 0;883 gw->pointerBufDx = 0;
864 gw->pointerBufDy = 0;884 gw->pointerBufDy = 0;
@@ -977,6 +997,17 @@
977 edge = lastEdge = lastResizeEdge = NoEdge;997 edge = lastEdge = lastResizeEdge = NoEdge;
978 currentWorkarea = lastWorkarea = screen->getWorkareaForOutput998 currentWorkarea = lastWorkarea = screen->getWorkareaForOutput
979 (screen->outputDeviceForPoint (pointerX, pointerY));999 (screen->outputDeviceForPoint (pointerX, pointerY));
1000 gridProps[GridUnknown] = GridProps {0,1, 1,1};
1001 gridProps[GridBottomLeft] = GridProps {0,1, 2,2};
1002 gridProps[GridBottom] = GridProps {0,1, 1,2};
1003 gridProps[GridBottomRight] = GridProps {1,1, 2,2};
1004 gridProps[GridLeft] = GridProps {0,0, 2,1};
1005 gridProps[GridCenter] = GridProps{0,0, 1,1};
1006 gridProps[GridRight] = GridProps {1,0, 2,1};
1007 gridProps[GridTopLeft] = GridProps{0,0, 2,2};
1008 gridProps[GridTop] = GridProps {0,0, 1,2};
1009 gridProps[GridTopRight] = GridProps {0,0, 1,2};
1010 gridProps[GridMaximize] = GridProps {0,0, 1,1};
9801011
981 animations.clear ();1012 animations.clear ();
9821013
@@ -984,16 +1015,16 @@
984 optionSet##opt##Initiate (boost::bind (&GridScreen::initiateCommon, this, \1015 optionSet##opt##Initiate (boost::bind (&GridScreen::initiateCommon, this, \
985 _1, _2, _3, where, resize, key))1016 _1, _2, _3, where, resize, key))
9861017
987 GRIDSET (PutCenterKey, GridCenter, true, true);1018 GRIDSET (PutCenterKey, GridWindowType::GridCenter, true, true);
988 GRIDSET (PutLeftKey, GridLeft, true, true);1019 GRIDSET (PutLeftKey, GridWindowType::GridLeft, true, true);
989 GRIDSET (PutRightKey, GridRight, true, true);1020 GRIDSET (PutRightKey, GridWindowType::GridRight, true, true);
990 GRIDSET (PutTopKey, GridTop, true, true);1021 GRIDSET (PutTopKey, GridWindowType::GridTop, true, true);
991 GRIDSET (PutBottomKey, GridBottom, true, true);1022 GRIDSET (PutBottomKey, GridWindowType::GridBottom, true, true);
992 GRIDSET (PutTopleftKey, GridTopLeft, true, true);1023 GRIDSET (PutTopleftKey, GridWindowType::GridTopLeft, true, true);
993 GRIDSET (PutToprightKey, GridTopRight, true, true);1024 GRIDSET (PutToprightKey, GridWindowType::GridTopRight, true, true);
994 GRIDSET (PutBottomleftKey, GridBottomLeft, true, true);1025 GRIDSET (PutBottomleftKey, GridWindowType::GridBottomLeft, true, true);
995 GRIDSET (PutBottomrightKey, GridBottomRight, true, true);1026 GRIDSET (PutBottomrightKey, GridWindowType::GridBottomRight, true, true);
996 GRIDSET (PutMaximizeKey, GridMaximize, true, true);1027 GRIDSET (PutMaximizeKey, GridWindowType::GridMaximize, true, true);
9971028
998#undef GRIDSET1029#undef GRIDSET
9991030
10001031
=== modified file 'src/grid.h'
--- src/grid.h 2011-09-28 16:58:29 +0000
+++ src/grid.h 2011-09-29 11:23:07 +0000
@@ -114,7 +114,7 @@
114 void setCurrentRect (Animation&);114 void setCurrentRect (Animation&);
115115
116 bool initiateCommon (CompAction*, CompAction::State,116 bool initiateCommon (CompAction*, CompAction::State,
117 CompOption::Vector&, GridType, bool, bool);117 CompOption::Vector&, unsigned int, bool, bool);
118118
119 void glPaintRectangle (const GLScreenPaintAttrib&,119 void glPaintRectangle (const GLScreenPaintAttrib&,
120 const GLMatrix&, CompOutput *);120 const GLMatrix&, CompOutput *);
@@ -128,7 +128,8 @@
128128
129 std::vector <Animation> animations;129 std::vector <Animation> animations;
130130
131 GridType edgeToGridType ();131 int edgeToGridType ();
132 unsigned int typeToMask (int);
132133
133 void handleEvent (XEvent *event);134 void handleEvent (XEvent *event);
134 void handleCompizEvent (const char *plugin, const char *event, CompOption::Vector &options);135 void handleCompizEvent (const char *plugin, const char *event, CompOption::Vector &options);

Subscribers

People subscribed via source and target branches

to all changes: