1
=== modified file 'src/grid.cpp'
2
Index: compiz-plugins-main-0.9.6/grid/src/grid.cpp
3
===================================================================
4
--- compiz-plugins-main-0.9.6.orig/grid/src/grid.cpp 2011-09-28 16:58:20.000000000 +0800
5
+++ compiz-plugins-main-0.9.6/grid/src/grid.cpp 2011-10-08 00:01:34.156630446 +0800
10
+using namespace GridWindowType;
12
static const GridProps gridProps[] =
16
xid = CompOption::getIntOptionNamed (option, "window");
17
cw = screen->findWindow (xid);
19
- if (where == GridUnknown || screen->otherGrabExist ("move", NULL))
25
+ bool maximizeH = where & (GridBottom | GridTop | GridMaximize);
26
+ bool maximizeV = where & (GridLeft | GridRight | GridMaximize);
28
+ if (!(cw->actions () & CompWindowActionResizeMask))
31
+ if (maximizeH && !(cw->actions () & CompWindowActionMaximizeHorzMask))
34
+ if (maximizeV && !(cw->actions () & CompWindowActionMaximizeVertMask))
37
+ if (where == GridUnknown)
43
/* TODO: animate move+resize */
46
- cw->configureXWindow (CWX | CWY | CWWidth | CWHeight, &xwc);
47
- gw->isGridResized = true;
48
- gw->isGridMaximized = false;
49
- for (unsigned int i = 0; i < animations.size (); i++)
50
- animations.at (i).fadingOut = true;
51
+ unsigned int valueMask = CWX | CWY | CWWidth | CWHeight;
52
gw->lastTarget = where;
53
gw->currentSize = CompRect (wc.x, wc.y, wc.width, wc.height);
55
+ /* Special case for left and right, actually vertically maximize
57
+ if (where == GridLeft || where == GridRight)
59
+ /* First restore the window to its original size */
62
+ rwc.x = gw->originalSize.x ();
63
+ rwc.y = gw->originalSize.y ();
64
+ rwc.width = gw->originalSize.width ();
65
+ rwc.height = gw->originalSize.height ();
67
+ cw->configureXWindow (CWX | CWY | CWWidth | CWHeight, &rwc);
69
+ gw->isGridMaximized = true;
70
+ gw->isGridResized = false;
72
+ gw->lastBorder = cw->border ();
73
+ /* Maximize the window */
74
+ cw->maximize (CompWindowStateMaximizedVertMask);
78
+ gw->isGridResized = true;
79
+ gw->isGridMaximized = false;
82
+ /* Make window the size that we want */
83
+ cw->configureXWindow (valueMask, &xwc);
85
+ for (unsigned int i = 0; i < animations.size (); i++)
86
+ animations.at (i).fadingOut = true;
89
/* This centers a window if it could not be resized to the desired
91
if (edge != NoEdge && check)
93
CompWindow *cw = screen->findWindow (screen->activeWindow ());
94
- animations.push_back (Animation ());
95
- int current = animations.size () - 1;
96
- animations.at (current).fromRect = cw->serverBorderRect ();
97
- animations.at (current).currentRect = cw->serverBorderRect ();
98
- animations.at (current).timer = animations.at (current).duration;
99
- animations.at (current).targetRect = desiredSlot;
101
- if (lastEdge == NoEdge || !animating)
104
+ animations.push_back (Animation ());
105
+ int current = animations.size () - 1;
106
+ animations.at (current).fromRect = cw->serverBorderRect ();
107
+ animations.at (current).currentRect = cw->serverBorderRect ();
108
+ animations.at (current).timer = animations.at (current).duration;
109
+ animations.at (current).targetRect = desiredSlot;
111
+ if (lastEdge == NoEdge || !animating)
113
/* Cursor has entered edge region from non-edge region */
115
glScreen->glPaintOutputSetEnabled (this, true);
116
cScreen->preparePaintSetEnabled (this, true);
117
cScreen->donePaintSetEnabled (this, true);
122
@@ -664,21 +709,22 @@
126
- if (screen->grabExist ("move"))
127
+ if (mask & (CompWindowGrabMoveMask | CompWindowGrabButtonMask))
129
gScreen->o[0].value ().set ((int) window->id ());
131
screen->handleEventSetEnabled (gScreen, true);
132
gScreen->mGrabWindow = window;
133
pointerBufDx = pointerBufDy = 0;
136
- if (!isGridResized && gScreen->optionGetSnapbackWindows ())
137
+ if (!isGridResized && !isGridMaximized && gScreen->optionGetSnapbackWindows ())
138
/* Store size not including borders when grabbing with cursor */
139
originalSize = gScreen->slotToRect(window,
140
window->serverBorderRect ());
143
- if (screen->grabExist ("resize"))
144
+ if (mask & CompWindowGrabResizeMask)
146
isGridResized = false;
149
gScreen->edge != gScreen->lastResizeEdge);
151
screen->handleEventSetEnabled (gScreen, false);
153
gScreen->mGrabWindow = NULL;
154
gScreen->o[0].value ().set (0);
155
gScreen->cScreen->damageRegion (gScreen->desiredSlot);
158
if (isGridResized && !isGridMaximized && !GridScreen::get (screen)->mSwitchingVp)
160
- if (window->grabbed ())
161
+ if (window->grabbed () && (grabMask & CompWindowGrabMoveMask))
165
@@ -738,11 +785,49 @@
166
lastTarget = GridUnknown;
167
else if (!(lastState & MAXIMIZE_STATE) &&
168
window->state () & MAXIMIZE_STATE)
170
lastTarget = GridMaximize;
171
+ if (window->grabbed ())
173
+ originalSize = gScreen->slotToRect (window,
174
+ window->serverBorderRect ());
178
window->stateChangeNotify (lastState);
183
+GridWindow::windowNotify (CompWindowNotify n)
185
+ if (n == CompWindowNotifyFrameUpdate)
187
+ if (isGridMaximized && !((window->state () & MAXIMIZE_STATE) == MAXIMIZE_STATE))
189
+ unsigned int valueMask = 0;
190
+ XWindowChanges xwc;
192
+ int dw = (lastBorder.left + lastBorder.right) -
193
+ (window->border ().left + window->border ().right);
195
+ int dh = (lastBorder.top + lastBorder.bottom) -
196
+ (window->border ().top + window->border ().bottom);
199
+ valueMask |= CWWidth;
201
+ valueMask |= CWHeight;
202
+ xwc.width = window->serverGeometry ().width () + dw;
203
+ xwc.height = window->serverGeometry ().height () + dh;
205
+ window->configureXWindow (valueMask, &xwc);
208
+ lastBorder = window->border ();
211
+ window->windowNotify (n);
214
GridScreen::restoreWindow (CompAction *action,
215
CompAction::State state,
217
gScreen (GridScreen::get (screen)),
218
isGridResized (false),
219
isGridMaximized (false),
224
Index: compiz-plugins-main-0.9.6/grid/src/grid.h
225
===================================================================
226
--- compiz-plugins-main-0.9.6.orig/grid/src/grid.h 2011-09-28 16:58:20.000000000 +0800
227
+++ compiz-plugins-main-0.9.6/grid/src/grid.h 2011-10-08 00:01:00.668464373 +0800
230
#define SNAPOFF_THRESHOLD 50
233
+namespace GridWindowType
236
- GridBottomLeft = 1,
238
- GridBottomRight = 3,
247
+ static const unsigned int GridUnknown = (1 << 0);
248
+ static const unsigned int GridBottomLeft = (1 << 1);
249
+ static const unsigned int GridBottom = (1 << 2);
250
+ static const unsigned int GridBottomRight = (1 << 3);
251
+ static const unsigned int GridLeft = (1 << 4);
252
+ static const unsigned int GridCenter = (1 << 5);
253
+ static const unsigned int GridRight = (1 << 6);
254
+ static const unsigned int GridTopLeft = (1 << 7);
255
+ static const unsigned int GridTop = (1 << 8);
256
+ static const unsigned int GridTopRight = (1 << 9);
257
+ static const unsigned int GridMaximize = (1 << 10);
260
+typedef unsigned int GridType;
262
typedef struct _GridProps
264
@@ -160,11 +162,13 @@
267
bool isGridMaximized;
268
+ unsigned int grabMask;
272
CompRect currentSize;
273
CompRect originalSize;
274
+ CompWindowExtents lastBorder;
277
void grabNotify (int, int, unsigned int, unsigned int);
279
void moveNotify (int, int, bool);
281
void stateChangeNotify (unsigned int);
283
+ void windowNotify (CompWindowNotify n);
286
#define GRID_WINDOW(w) \