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
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2009-12-17 12:22:47 +0000
+++ CMakeLists.txt 2012-01-18 07:48:23 +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-29 15:54:11 +0000
+++ src/grid.cpp 2012-01-18 07:48:23 +0000
@@ -24,24 +24,26 @@
2424
25#include "grid.h"25#include "grid.h"
2626
27static const GridProps gridProps[] =27using namespace GridWindowType;
28
29static std::map <unsigned int, GridProps> gridProps;
30
31void
32GridScreen::handleCompizEvent(const char* plugin,
33 const char* event,
34 CompOption::Vector& o)
28{35{
29 {0,1, 1,1},36 if (strcmp(event, "start_viewport_switch") == 0)
3037 {
31 {0,1, 2,2},38 mSwitchingVp = true;
32 {0,1, 1,2},39 }
33 {1,1, 2,2},40 else if (strcmp(event, "end_viewport_switch") == 0)
3441 {
35 {0,0, 2,1},42 mSwitchingVp = false;
36 {0,0, 1,1},43 }
37 {1,0, 2,1},44
3845 screen->handleCompizEvent(plugin, event, o);
39 {0,0, 2,2},46}
40 {0,0, 1,2},
41 {1,0, 2,2},
42
43 {0,0, 1,1},
44};
4547
46CompRect48CompRect
47GridScreen::slotToRect (CompWindow *w,49GridScreen::slotToRect (CompWindow *w,
@@ -83,7 +85,7 @@
83void85void
84GridScreen::getPaintRectangle (CompRect &cRect)86GridScreen::getPaintRectangle (CompRect &cRect)
85{87{
86 if (edgeToGridType () != GridUnknown && optionGetDrawIndicator ())88 if (typeToMask (edgeToGridType ()) != GridUnknown && optionGetDrawIndicator ())
87 cRect = desiredSlot;89 cRect = desiredSlot;
88 else90 else
89 cRect.setGeometry (0, 0, 0, 0);91 cRect.setGeometry (0, 0, 0, 0);
@@ -118,8 +120,9 @@
118GridScreen::initiateCommon (CompAction *action,120GridScreen::initiateCommon (CompAction *action,
119 CompAction::State state,121 CompAction::State state,
120 CompOption::Vector &option,122 CompOption::Vector &option,
121 GridType where,123 unsigned int where,
122 bool resize)124 bool resize,
125 bool key)
123{126{
124 Window xid;127 Window xid;
125 CompWindow *cw = 0;128 CompWindow *cw = 0;
@@ -127,17 +130,30 @@
127 xid = CompOption::getIntOptionNamed (option, "window");130 xid = CompOption::getIntOptionNamed (option, "window");
128 cw = screen->findWindow (xid);131 cw = screen->findWindow (xid);
129132
130 if (where == GridUnknown || screen->otherGrabExist ("move", NULL))
131 return false;
132
133 if (cw)133 if (cw)
134 {134 {
135 XWindowChanges xwc;135 XWindowChanges xwc;
136 bool maximizeH = where & (GridBottom | GridTop | GridMaximize);
137 bool maximizeV = where & (GridLeft | GridRight | GridMaximize);
138
139 if (!(cw->actions () & CompWindowActionResizeMask))
140 return false;
141
142 if (maximizeH && !(cw->actions () & CompWindowActionMaximizeHorzMask))
143 return false;
144
145 if (maximizeV && !(cw->actions () & CompWindowActionMaximizeVertMask))
146 return false;
147
148 if (where & GridUnknown)
149 return false;
136150
137 GRID_WINDOW (cw);151 GRID_WINDOW (cw);
138152
139 if (gw->lastTarget != where)153 if (gw->lastTarget & ~(where))
140 gw->resizeCount = 0;154 gw->resizeCount = 0;
155 else if (!key)
156 return false;
141157
142 props = gridProps[where];158 props = gridProps[where];
143159
@@ -164,7 +180,7 @@
164 cw->maximize (0);180 cw->maximize (0);
165 }181 }
166182
167 if (where == GridMaximize && resize)183 if ((where & GridMaximize) && resize)
168 {184 {
169 /* move the window to the correct output */185 /* move the window to the correct output */
170 if (cw == mGrabWindow)186 if (cw == mGrabWindow)
@@ -198,7 +214,13 @@
198 desiredSlot.setWidth (workarea.width () / props.numCellsX);214 desiredSlot.setWidth (workarea.width () / props.numCellsX);
199215
200 /* Adjust for constraints and decorations */216 /* Adjust for constraints and decorations */
201 desiredRect = constrainSize (cw, desiredSlot);217 if (where & ~(GridMaximize | GridLeft | GridRight))
218 {
219 desiredRect = constrainSize (cw, desiredSlot);
220 }
221 else
222 desiredRect = slotToRect (cw, desiredSlot);
223
202 /* Get current rect not including decorations */224 /* Get current rect not including decorations */
203 currentRect.setGeometry (cw->serverX (), cw->serverY (),225 currentRect.setGeometry (cw->serverX (), cw->serverY (),
204 cw->serverWidth (),226 cw->serverWidth (),
@@ -206,7 +228,7 @@
206228
207 if (desiredRect.y () == currentRect.y () &&229 if (desiredRect.y () == currentRect.y () &&
208 desiredRect.height () == currentRect.height () &&230 desiredRect.height () == currentRect.height () &&
209 where != GridMaximize && gw->lastTarget == where)231 where & ~(GridMaximize | GridLeft | GridRight) && gw->lastTarget & where)
210 {232 {
211 int slotWidth25 = workarea.width () / 4;233 int slotWidth25 = workarea.width () / 4;
212 int slotWidth33 = (workarea.width () / 3) + cw->border ().left;234 int slotWidth33 = (workarea.width () / 3) + cw->border ().left;
@@ -319,12 +341,61 @@
319 /* TODO: animate move+resize */341 /* TODO: animate move+resize */
320 if (resize)342 if (resize)
321 {343 {
322 cw->configureXWindow (CWX | CWY | CWWidth | CWHeight, &xwc);344 unsigned int valueMask = CWX | CWY | CWWidth | CWHeight;
323 gw->isGridResized = true;
324 gw->isGridMaximized = false;
325 for (unsigned int i = 0; i < animations.size (); i++)
326 animations.at (i).fadingOut = true;
327 gw->lastTarget = where;345 gw->lastTarget = where;
346 gw->currentSize = CompRect (wc.x, wc.y, wc.width, wc.height);
347 CompWindowExtents lastBorder = gw->window->border ();
348
349 gw->sizeHintsFlags = 0;
350
351 /* Special case for left and right, actually vertically maximize
352 * the window */
353 if (where & GridLeft || where & GridRight)
354 {
355 /* First restore the window to its original size */
356 XWindowChanges rwc;
357
358 rwc.x = gw->originalSize.x ();
359 rwc.y = gw->originalSize.y ();
360 rwc.width = gw->originalSize.width ();
361 rwc.height = gw->originalSize.height ();
362
363 cw->configureXWindow (CWX | CWY | CWWidth | CWHeight, &rwc);
364
365 gw->isGridMaximized = true;
366 gw->isGridResized = false;
367
368 /* Maximize the window */
369 cw->maximize (CompWindowStateMaximizedVertMask);
370 /* Be evil */
371 if (cw->sizeHints ().flags & PResizeInc)
372 {
373 gw->sizeHintsFlags |= PResizeInc;
374 gw->window->sizeHints ().flags &= ~(PResizeInc);
375 }
376 }
377 else
378 {
379 gw->isGridResized = true;
380 gw->isGridMaximized = false;
381 }
382
383 int dw = (lastBorder.left + lastBorder.right) -
384 (gw->window->border ().left +
385 gw->window->border ().right);
386
387 int dh = (lastBorder.top + lastBorder.bottom) -
388 (gw->window->border ().top +
389 gw->window->border ().bottom);
390
391 xwc.width += dw;
392 xwc.height += dh;
393
394 /* Make window the size that we want */
395 cw->configureXWindow (valueMask, &xwc);
396
397 for (unsigned int i = 0; i < animations.size (); i++)
398 animations.at (i).fadingOut = true;
328 }399 }
329400
330 /* This centers a window if it could not be resized to the desired401 /* This centers a window if it could not be resized to the desired
@@ -376,12 +447,14 @@
376447
377 for (iter = animations.begin (); iter != animations.end () && animating; iter++)448 for (iter = animations.begin (); iter != animations.end () && animating; iter++)
378 {449 {
379 GLushort *color;
380 Animation& anim = *iter;450 Animation& anim = *iter;
451 float alpha = ((float) optionGetFillColorAlpha () / 65535.0f) * anim.opacity;
381452
382 color = optionGetFillColor ();453 /* fill rectangle */
383 glColor4us (anim.opacity * color[0], anim.opacity * color[1],454 glColor4f (((float) optionGetFillColorRed () / 65535.0f) * alpha,
384 anim.opacity * color[2], anim.opacity * color[3]);455 ((float) optionGetFillColorGreen () / 65535.0f) * alpha,
456 ((float) optionGetFillColorBlue () / 65535.0f) * alpha,
457 alpha);
385458
386 /* fill rectangle */459 /* fill rectangle */
387 glRecti (anim.currentRect.x1 (), anim.currentRect.y2 (),460 glRecti (anim.currentRect.x1 (), anim.currentRect.y2 (),
@@ -389,14 +462,17 @@
389462
390 /* Set outline rect smaller to avoid damage issues */463 /* Set outline rect smaller to avoid damage issues */
391 anim.currentRect.setGeometry (anim.currentRect.x () + 1,464 anim.currentRect.setGeometry (anim.currentRect.x () + 1,
392 anim.currentRect.y () + 1,465 anim.currentRect.y () + 1,
393 anim.currentRect.width () - 2,466 anim.currentRect.width () - 2,
394 anim.currentRect.height () - 2);467 anim.currentRect.height () - 2);
468
469 alpha = (float) (optionGetOutlineColorAlpha () / 65535.0f) * anim.opacity;
395470
396 /* draw outline */471 /* draw outline */
397 color = optionGetOutlineColor ();472 glColor4f (((float) optionGetOutlineColorRed () / 65535.0f) * alpha,
398 glColor4us (anim.opacity * color[0], anim.opacity * color[1],473 ((float) optionGetOutlineColorGreen () / 65535.0f) * alpha,
399 anim.opacity * color[2], anim.opacity * color[3]);474 ((float) optionGetOutlineColorBlue () / 65535.0f) * alpha,
475 alpha);
400476
401 glLineWidth (2.0);477 glLineWidth (2.0);
402478
@@ -411,7 +487,13 @@
411 if (!animating)487 if (!animating)
412 {488 {
413 /* fill rectangle */489 /* fill rectangle */
414 glColor4usv (optionGetFillColor ());490 float alpha = (float) optionGetFillColorAlpha () / 65535.0f;
491
492 /* fill rectangle */
493 glColor4f (((float) optionGetFillColorRed () / 65535.0f) * alpha,
494 ((float) optionGetFillColorGreen () / 65535.0f) * alpha,
495 ((float) optionGetFillColorBlue () / 65535.0f) * alpha,
496 alpha);
415 glRecti (rect.x1 (), rect.y2 (), rect.x2 (), rect.y1 ());497 glRecti (rect.x1 (), rect.y2 (), rect.x2 (), rect.y1 ());
416498
417 /* Set outline rect smaller to avoid damage issues */499 /* Set outline rect smaller to avoid damage issues */
@@ -419,7 +501,14 @@
419 rect.width () - 2, rect.height () - 2);501 rect.width () - 2, rect.height () - 2);
420502
421 /* draw outline */503 /* draw outline */
422 glColor4usv (optionGetOutlineColor ());504 alpha = (float) optionGetOutlineColorAlpha () / 65535.0f;
505
506 /* draw outline */
507 glColor4f (((float) optionGetOutlineColorRed () / 65535.0f) * alpha,
508 ((float) optionGetOutlineColorGreen () / 65535.0f) * alpha,
509 ((float) optionGetOutlineColorBlue () / 65535.0f) * alpha,
510 alpha);
511
423 glLineWidth (2.0);512 glLineWidth (2.0);
424 glBegin (GL_LINE_LOOP);513 glBegin (GL_LINE_LOOP);
425 glVertex2i (rect.x1 (), rect.y1 ());514 glVertex2i (rect.x1 (), rect.y1 ());
@@ -452,39 +541,72 @@
452 return status;541 return status;
453}542}
454543
455GridType544unsigned int
545GridScreen::typeToMask (int t)
546{
547 typedef struct {
548 unsigned int mask;
549 int type;
550 } GridTypeMask;
551
552 std::vector <GridTypeMask> type =
553 {
554 { GridWindowType::GridUnknown, 0 },
555 { GridWindowType::GridBottomLeft, 1 },
556 { GridWindowType::GridBottom, 2 },
557 { GridWindowType::GridBottomRight, 3 },
558 { GridWindowType::GridLeft, 4 },
559 { GridWindowType::GridCenter, 5 },
560 { GridWindowType::GridRight, 6 },
561 { GridWindowType::GridTopLeft, 7 },
562 { GridWindowType::GridTop, 8 },
563 { GridWindowType::GridTopRight, 9 },
564 { GridWindowType::GridMaximize, 10 }
565 };
566
567 for (unsigned int i = 0; i < type.size (); i++)
568 {
569 GridTypeMask &tm = type[i];
570 if (tm.type == t)
571 return tm.mask;
572 }
573
574 return GridWindowType::GridUnknown;
575}
576
577int
456GridScreen::edgeToGridType ()578GridScreen::edgeToGridType ()
457{579{
458 GridType ret;580 int ret;
459581
460 switch (edge) {582 switch (edge) {
461 case Left:583 case Left:
462 ret = (GridType) optionGetLeftEdgeAction ();584 ret = (int) optionGetLeftEdgeAction ();
463 break;585 break;
464 case Right:586 case Right:
465 ret = (GridType) optionGetRightEdgeAction ();587 ret = (int) optionGetRightEdgeAction ();
466 break;588 break;
467 case Top:589 case Top:
468 ret = (GridType) optionGetTopEdgeAction ();590 ret = (int) optionGetTopEdgeAction ();
469 break;591 break;
470 case Bottom:592 case Bottom:
471 ret = (GridType) optionGetBottomEdgeAction ();593 ret = (int) optionGetBottomEdgeAction ();
472 break;594 break;
473 case TopLeft:595 case TopLeft:
474 ret = (GridType) optionGetTopLeftCornerAction ();596 ret = (int) optionGetTopLeftCornerAction ();
475 break;597 break;
476 case TopRight:598 case TopRight:
477 ret = (GridType) optionGetTopRightCornerAction ();599 ret = (int) optionGetTopRightCornerAction ();
478 break;600 break;
479 case BottomLeft:601 case BottomLeft:
480 ret = (GridType) optionGetBottomLeftCornerAction ();602 ret = (int) optionGetBottomLeftCornerAction ();
481 break;603 break;
482 case BottomRight:604 case BottomRight:
483 ret = (GridType) optionGetBottomRightCornerAction ();605 ret = (int) optionGetBottomRightCornerAction ();
484 break;606 break;
485 case NoEdge:607 case NoEdge:
486 default:608 default:
487 ret = GridUnknown;609 ret = -1;
488 break;610 break;
489 }611 }
490612
@@ -495,6 +617,8 @@
495GridScreen::handleEvent (XEvent *event)617GridScreen::handleEvent (XEvent *event)
496{618{
497 CompOutput out;619 CompOutput out;
620 CompWindow *w;
621 bool check = false;
498622
499 screen->handleEvent (event);623 screen->handleEvent (event);
500624
@@ -548,7 +672,7 @@
548 if (cScreen)672 if (cScreen)
549 cScreen->damageRegion (desiredSlot);673 cScreen->damageRegion (desiredSlot);
550674
551 initiateCommon (0, 0, o, edgeToGridType (), false);675 initiateCommon (0, 0, o, typeToMask (edgeToGridType ()), false, false);
552676
553 if (cScreen)677 if (cScreen)
554 cScreen->damageRegion (desiredSlot);678 cScreen->damageRegion (desiredSlot);
@@ -566,7 +690,7 @@
566 if (cScreen)690 if (cScreen)
567 cScreen->damageRegion (desiredSlot);691 cScreen->damageRegion (desiredSlot);
568692
569 initiateCommon (0, 0, o, edgeToGridType (), false);693 check = initiateCommon (NULL, 0, o, typeToMask (edgeToGridType ()), false, false);
570694
571 if (cScreen)695 if (cScreen)
572 cScreen->damageRegion (desiredSlot);696 cScreen->damageRegion (desiredSlot);
@@ -577,7 +701,7 @@
577 /* Begin fading previous animation instance */701 /* Begin fading previous animation instance */
578 animations.at (animations.size () - 1).fadingOut = true;702 animations.at (animations.size () - 1).fadingOut = true;
579703
580 if (edge != NoEdge)704 if (edge != NoEdge && check)
581 {705 {
582 CompWindow *cw = screen->findWindow (screen->activeWindow ());706 CompWindow *cw = screen->findWindow (screen->activeWindow ());
583 animations.push_back (Animation ());707 animations.push_back (Animation ());
@@ -601,16 +725,35 @@
601 lastEdge = edge;725 lastEdge = edge;
602 }726 }
603727
604 GRID_WINDOW (screen->findWindow728 w = screen->findWindow (CompOption::getIntOptionNamed (o, "window"));
605 (CompOption::getIntOptionNamed (o, "window")));729
606730 if (w)
607 if ((gw->pointerBufDx > SNAPOFF_THRESHOLD ||731 {
608 gw->pointerBufDy > SNAPOFF_THRESHOLD ||732 GRID_WINDOW (w);
609 gw->pointerBufDx < -SNAPOFF_THRESHOLD ||733
610 gw->pointerBufDy < -SNAPOFF_THRESHOLD) &&734 if ((gw->pointerBufDx > SNAPOFF_THRESHOLD ||
611 gw->isGridResized &&735 gw->pointerBufDy > SNAPOFF_THRESHOLD ||
612 optionGetSnapbackWindows ())736 gw->pointerBufDx < -SNAPOFF_THRESHOLD ||
613 restoreWindow (0, 0, o);737 gw->pointerBufDy < -SNAPOFF_THRESHOLD) &&
738 gw->isGridResized &&
739 optionGetSnapbackWindows ())
740 restoreWindow (0, 0, o);
741 }
742}
743
744void
745GridWindow::validateResizeRequest (unsigned int &xwcm,
746 XWindowChanges *xwc,
747 unsigned int source)
748{
749 window->validateResizeRequest (xwcm, xwc, source);
750
751 /* Don't allow non-pagers to change
752 * the size of the window, the user
753 * specified this size, thank-you */
754 if (isGridMaximized)
755 if (source != ClientTypePager)
756 xwcm = 0;
614}757}
615758
616void759void
@@ -619,22 +762,23 @@
619 unsigned int state,762 unsigned int state,
620 unsigned int mask)763 unsigned int mask)
621{764{
622 if (screen->grabExist ("move"))765 if ((mask & (CompWindowGrabMoveMask | CompWindowGrabButtonMask)) &&
766 !(mask & CompWindowGrabResizeMask))
623 {767 {
624 gScreen->o.push_back (CompOption ("window", CompOption::TypeInt));
625 gScreen->o[0].value ().set ((int) window->id ());768 gScreen->o[0].value ().set ((int) window->id ());
626769
627 screen->handleEventSetEnabled (gScreen, true);770 screen->handleEventSetEnabled (gScreen, true);
628 gScreen->mGrabWindow = window;771 gScreen->mGrabWindow = window;
629 pointerBufDx = pointerBufDy = 0;772 pointerBufDx = pointerBufDy = 0;
773 grabMask = mask;
630774
631 if (!isGridResized && gScreen->optionGetSnapbackWindows ())775 if (!isGridResized && !isGridMaximized && gScreen->optionGetSnapbackWindows ())
632 /* Store size not including borders when grabbing with cursor */776 /* Store size not including borders when grabbing with cursor */
633 originalSize = gScreen->slotToRect(window,777 originalSize = gScreen->slotToRect(window,
634 window->serverBorderRect ());778 window->serverBorderRect ());
635 }779 }
636780
637 if (screen->grabExist ("resize"))781 if (mask & CompWindowGrabResizeMask)
638 {782 {
639 isGridResized = false;783 isGridResized = false;
640 resizeCount = 0;784 resizeCount = 0;
@@ -649,13 +793,17 @@
649 if (window == gScreen->mGrabWindow)793 if (window == gScreen->mGrabWindow)
650 {794 {
651 gScreen->initiateCommon795 gScreen->initiateCommon
652 (0, 0, gScreen->o, gScreen->edgeToGridType (), true);796 (NULL, 0, gScreen->o, gScreen->typeToMask (gScreen->edgeToGridType ()), true,
797 gScreen->edge != gScreen->lastResizeEdge);
653798
654 screen->handleEventSetEnabled (gScreen, false);799 screen->handleEventSetEnabled (gScreen, false);
800 grabMask = 0;
655 gScreen->mGrabWindow = NULL;801 gScreen->mGrabWindow = NULL;
802 gScreen->o[0].value ().set (0);
656 gScreen->cScreen->damageRegion (gScreen->desiredSlot);803 gScreen->cScreen->damageRegion (gScreen->desiredSlot);
657 }804 }
658805
806 gScreen->lastResizeEdge = gScreen->edge;
659 gScreen->edge = NoEdge;807 gScreen->edge = NoEdge;
660808
661 window->ungrabNotify ();809 window->ungrabNotify ();
@@ -666,18 +814,41 @@
666{814{
667 window->moveNotify (dx, dy, immediate);815 window->moveNotify (dx, dy, immediate);
668816
669 if (isGridResized)817 if (isGridResized && !isGridMaximized && !GridScreen::get (screen)->mSwitchingVp)
670 {818 {
671 pointerBufDx += dx;819 if (window->grabbed () && (grabMask & CompWindowGrabMoveMask))
672 pointerBufDy += dy;820 {
821 pointerBufDx += dx;
822 pointerBufDy += dy;
823 }
673824
674 /* Do not allow the window to be moved while it825 /* Do not allow the window to be moved while it
675 * is resized */826 * is resized */
676827 dx = currentSize.x () - window->geometry ().x ();
677 window->moveNotifySetEnabled (this, false);828 dy = currentSize.y () - window->geometry ().y ();
678 window->move (-dx, -dy);829
679 window->moveNotifySetEnabled (this, true);830 window->move (dx, dy);
680 }831 }
832}
833
834void
835GridWindow::stateChangeNotify (unsigned int lastState)
836{
837 if (lastState & MAXIMIZE_STATE &&
838 !(window->state () & MAXIMIZE_STATE))
839 lastTarget = GridUnknown;
840 else if (!(lastState & MAXIMIZE_STATE) &&
841 window->state () & MAXIMIZE_STATE)
842 {
843 lastTarget = GridMaximize;
844 if (window->grabbed ())
845 {
846 originalSize = gScreen->slotToRect (window,
847 window->serverBorderRect ());
848 }
849 }
850
851 window->stateChangeNotify (lastState);
681}852}
682853
683bool854bool
@@ -697,7 +868,10 @@
697 return false;868 return false;
698869
699 if (gw->isGridMaximized & !(cw->state () & MAXIMIZE_STATE))870 if (gw->isGridMaximized & !(cw->state () & MAXIMIZE_STATE))
700 gw->isGridMaximized = false;871 {
872 gw->window->sizeHints ().flags |= gw->sizeHintsFlags;
873 gw->isGridMaximized = false;
874 }
701 else875 else
702 {876 {
703 if (cw == mGrabWindow)877 if (cw == mGrabWindow)
@@ -713,6 +887,7 @@
713 xwc.width = gw->originalSize.width ();887 xwc.width = gw->originalSize.width ();
714 xwc.height = gw->originalSize.height ();888 xwc.height = gw->originalSize.height ();
715 cw->maximize (0);889 cw->maximize (0);
890 gw->currentSize = CompRect ();
716 cw->configureXWindow (CWX | CWY | CWWidth | CWHeight, &xwc);891 cw->configureXWindow (CWX | CWY | CWWidth | CWHeight, &xwc);
717 gw->pointerBufDx = 0;892 gw->pointerBufDx = 0;
718 gw->pointerBufDy = 0;893 gw->pointerBufDy = 0;
@@ -818,33 +993,47 @@
818 glScreen (GLScreen::get (screen)),993 glScreen (GLScreen::get (screen)),
819 centerCheck (false),994 centerCheck (false),
820 mGrabWindow (NULL),995 mGrabWindow (NULL),
821 animating (false)996 animating (false),
997 mSwitchingVp (false)
822{998{
999 o.push_back (CompOption ("window", CompOption::TypeInt));
8231000
824 ScreenInterface::setHandler (screen, false);1001 ScreenInterface::setHandler (screen, false);
1002 screen->handleCompizEventSetEnabled (this, true);
825 CompositeScreenInterface::setHandler (cScreen, false);1003 CompositeScreenInterface::setHandler (cScreen, false);
826 GLScreenInterface::setHandler (glScreen, false);1004 GLScreenInterface::setHandler (glScreen, false);
8271005
828 edge = lastEdge = NoEdge;1006 edge = lastEdge = lastResizeEdge = NoEdge;
829 currentWorkarea = lastWorkarea = screen->getWorkareaForOutput1007 currentWorkarea = lastWorkarea = screen->getWorkareaForOutput
830 (screen->outputDeviceForPoint (pointerX, pointerY));1008 (screen->outputDeviceForPoint (pointerX, pointerY));
1009 gridProps[GridUnknown] = GridProps {0,1, 1,1};
1010 gridProps[GridBottomLeft] = GridProps {0,1, 2,2};
1011 gridProps[GridBottom] = GridProps {0,1, 1,2};
1012 gridProps[GridBottomRight] = GridProps {1,1, 2,2};
1013 gridProps[GridLeft] = GridProps {0,0, 2,1};
1014 gridProps[GridCenter] = GridProps{0,0, 1,1};
1015 gridProps[GridRight] = GridProps {1,0, 2,1};
1016 gridProps[GridTopLeft] = GridProps{0,0, 2,2};
1017 gridProps[GridTop] = GridProps {0,0, 1,2};
1018 gridProps[GridTopRight] = GridProps {1,0, 2,2};
1019 gridProps[GridMaximize] = GridProps {0,0, 1,1};
8311020
832 animations.clear ();1021 animations.clear ();
8331022
834#define GRIDSET(opt,where,resize) \1023#define GRIDSET(opt,where,resize,key) \
835 optionSet##opt##Initiate (boost::bind (&GridScreen::initiateCommon, this, \1024 optionSet##opt##Initiate (boost::bind (&GridScreen::initiateCommon, this, \
836 _1, _2, _3, where, resize))1025 _1, _2, _3, where, resize, key))
8371026
838 GRIDSET (PutCenterKey, GridCenter, true);1027 GRIDSET (PutCenterKey, GridWindowType::GridCenter, true, true);
839 GRIDSET (PutLeftKey, GridLeft, true);1028 GRIDSET (PutLeftKey, GridWindowType::GridLeft, true, true);
840 GRIDSET (PutRightKey, GridRight, true);1029 GRIDSET (PutRightKey, GridWindowType::GridRight, true, true);
841 GRIDSET (PutTopKey, GridTop, true);1030 GRIDSET (PutTopKey, GridWindowType::GridTop, true, true);
842 GRIDSET (PutBottomKey, GridBottom, true);1031 GRIDSET (PutBottomKey, GridWindowType::GridBottom, true, true);
843 GRIDSET (PutTopleftKey, GridTopLeft, true);1032 GRIDSET (PutTopleftKey, GridWindowType::GridTopLeft, true, true);
844 GRIDSET (PutToprightKey, GridTopRight, true);1033 GRIDSET (PutToprightKey, GridWindowType::GridTopRight, true, true);
845 GRIDSET (PutBottomleftKey, GridBottomLeft, true);1034 GRIDSET (PutBottomleftKey, GridWindowType::GridBottomLeft, true, true);
846 GRIDSET (PutBottomrightKey, GridBottomRight, true);1035 GRIDSET (PutBottomrightKey, GridWindowType::GridBottomRight, true, true);
847 GRIDSET (PutMaximizeKey, GridMaximize, true);1036 GRIDSET (PutMaximizeKey, GridWindowType::GridMaximize, true, true);
8481037
849#undef GRIDSET1038#undef GRIDSET
8501039
@@ -862,14 +1051,23 @@
862 gScreen (GridScreen::get (screen)),1051 gScreen (GridScreen::get (screen)),
863 isGridResized (false),1052 isGridResized (false),
864 isGridMaximized (false),1053 isGridMaximized (false),
1054 grabMask (0),
865 pointerBufDx (0),1055 pointerBufDx (0),
866 pointerBufDy (0),1056 pointerBufDy (0),
867 resizeCount (0),1057 resizeCount (0),
868 lastTarget (GridUnknown)1058 lastTarget (GridUnknown)
869{1059{
870 WindowInterface::setHandler (window);1060 WindowInterface::setHandler (window);
871}1061}
8721062
1063GridWindow::~GridWindow ()
1064{
1065 if (gScreen->mGrabWindow == window)
1066 gScreen->mGrabWindow = NULL;
1067
1068 gScreen->o[0].value ().set (0);
1069}
1070
873/* Initial plugin init function called. Checks to see if we are ABI1071/* Initial plugin init function called. Checks to see if we are ABI
874 * compatible with core, otherwise unload */1072 * compatible with core, otherwise unload */
8751073
8761074
=== modified file 'src/grid.h'
--- src/grid.h 2011-09-29 15:54:11 +0000
+++ src/grid.h 2012-01-18 07:48:23 +0000
@@ -32,20 +32,22 @@
3232
33#define SNAPOFF_THRESHOLD 5033#define SNAPOFF_THRESHOLD 50
3434
35typedef enum35namespace GridWindowType
36{36{
37 GridUnknown = 0,37 static const unsigned int GridUnknown = (1 << 0);
38 GridBottomLeft = 1,38 static const unsigned int GridBottomLeft = (1 << 1);
39 GridBottom = 2,39 static const unsigned int GridBottom = (1 << 2);
40 GridBottomRight = 3,40 static const unsigned int GridBottomRight = (1 << 3);
41 GridLeft = 4,41 static const unsigned int GridLeft = (1 << 4);
42 GridCenter = 5,42 static const unsigned int GridCenter = (1 << 5);
43 GridRight = 6,43 static const unsigned int GridRight = (1 << 6);
44 GridTopLeft = 7,44 static const unsigned int GridTopLeft = (1 << 7);
45 GridTop = 8,45 static const unsigned int GridTop = (1 << 8);
46 GridTopRight = 9,46 static const unsigned int GridTopRight = (1 << 9);
47 GridMaximize = 1047 static const unsigned int GridMaximize = (1 << 10);
48} GridType;48};
49
50typedef unsigned int GridType;
4951
50typedef struct _GridProps52typedef struct _GridProps
51{53{
@@ -101,17 +103,18 @@
101 CompRect workarea, currentRect, desiredSlot, lastSlot,103 CompRect workarea, currentRect, desiredSlot, lastSlot,
102 desiredRect, lastWorkarea, currentWorkarea;104 desiredRect, lastWorkarea, currentWorkarea;
103 GridProps props;105 GridProps props;
104 Edges edge, lastEdge;106 Edges edge, lastEdge, lastResizeEdge;
105 CompOption::Vector o;107 CompOption::Vector o;
106 bool centerCheck;108 bool centerCheck;
107 CompWindow *mGrabWindow;109 CompWindow *mGrabWindow;
108 bool animating;110 bool animating;
111 bool mSwitchingVp;
109112
110 void getPaintRectangle (CompRect&);113 void getPaintRectangle (CompRect&);
111 void setCurrentRect (Animation&);114 void setCurrentRect (Animation&);
112115
113 bool initiateCommon (CompAction*, CompAction::State,116 bool initiateCommon (CompAction*, CompAction::State,
114 CompOption::Vector&, GridType, bool);117 CompOption::Vector&, unsigned int, bool, bool);
115118
116 void glPaintRectangle (const GLScreenPaintAttrib&,119 void glPaintRectangle (const GLScreenPaintAttrib&,
117 const GLMatrix&, CompOutput *);120 const GLMatrix&, CompOutput *);
@@ -125,9 +128,11 @@
125128
126 std::vector <Animation> animations;129 std::vector <Animation> animations;
127130
128 GridType edgeToGridType ();131 int edgeToGridType ();
132 unsigned int typeToMask (int);
129133
130 void handleEvent (XEvent *event);134 void handleEvent (XEvent *event);
135 void handleCompizEvent (const char *plugin, const char *event, CompOption::Vector &options);
131136
132 bool restoreWindow (CompAction*,137 bool restoreWindow (CompAction*,
133 CompAction::State,138 CompAction::State,
@@ -152,22 +157,31 @@
152 public:157 public:
153158
154 GridWindow (CompWindow *);159 GridWindow (CompWindow *);
160 ~GridWindow ();
155 CompWindow *window;161 CompWindow *window;
156 GridScreen *gScreen;162 GridScreen *gScreen;
157163
158 bool isGridResized;164 bool isGridResized;
159 bool isGridMaximized;165 bool isGridMaximized;
166 unsigned int grabMask;
160 int pointerBufDx;167 int pointerBufDx;
161 int pointerBufDy;168 int pointerBufDy;
162 int resizeCount;169 int resizeCount;
170 CompRect currentSize;
163 CompRect originalSize;171 CompRect originalSize;
164 GridType lastTarget;172 GridType lastTarget;
173 unsigned int sizeHintsFlags;
165174
166 void grabNotify (int, int, unsigned int, unsigned int);175 void grabNotify (int, int, unsigned int, unsigned int);
167176
168 void ungrabNotify ();177 void ungrabNotify ();
169178
170 void moveNotify (int, int, bool);179 void moveNotify (int, int, bool);
180
181 void stateChangeNotify (unsigned int);
182 void validateResizeRequest (unsigned int &valueMask,
183 XWindowChanges *xwc,
184 unsigned int source);
171};185};
172186
173#define GRID_WINDOW(w) \187#define GRID_WINDOW(w) \

Subscribers

People subscribed via source and target branches