2
* Compiz Fusion Grid plugin
4
* Copyright (c) 2008 Stephen Kennedy <suasol@gmail.com>
5
* Copyright (c) 2010 Scott Moreau <oreaus@gmail.com>
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 2
10
* of the License, or (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
19
* Plugin to act like winsplit revolution (http://www.winsplit-revolution.com/)
20
* use <Control><Alt>NUMPAD_KEY to move and tile your windows.
22
* Press the tiling keys several times to cycle through some tiling options.
27
bool compositingActive;
29
static const GridProps gridProps[] =
49
GridRectangle::subtractBorders (CompWindow *w) const
51
return CompRect (x () + w->border ().left,
52
y () + w->border ().top,
53
width () - (w->border ().left + w->border ().right),
54
height () - (w->border ().top + w->border ().bottom));
58
GridRectangle::addBorders (CompWindow *w) const
60
return CompRect (x () - w->border ().left,
61
y () - w->border ().top,
62
width () + (w->border ().left + w->border ().right),
63
height () + (w->border ().top + w->border ().bottom));
67
GridWindow::constrainSize (const GridRectangle& slot)
69
GridRectangle result = slot.subtractBorders (window);
70
CompRect wa = screen->outputDevs ().at (screen->outputDeviceForGeometry (window->serverGeometry ())).workArea ();
73
if (window->constrainNewWindowSize (result.width (), result.height (), &cw, &ch))
75
/* constrained size may put window offscreen, adjust for that case */
76
int dx = result.x () + cw - wa.right () + window->border ().right;
77
int dy = result.y () + ch - wa.bottom () + window->border ().bottom;
80
result.setX (result.x () - dx);
82
result.setY (result.y () - dy);
84
/* constrainment may leave gaps between the edges of the screen
85
* and the window borders ... in that case center the window so
86
* that these gaps are even */
88
if (result.width () != cw)
89
result.setX (result.x () + ((result.width () - cw) / 2));
91
if (result.height () != ch)
92
result.setY (result.y () + ((result.height () - ch) / 2));
95
result.setHeight (ch);
98
return result.addBorders (window);
102
GridWindow::allowGrid (GridType where)
104
/* Don't grid windows that can't be resized */
105
if (!(window->actions () & CompWindowActionResizeMask))
108
if (where == GridMaximize)
110
if (!(window->actions () & (CompWindowActionMaximizeHorzMask | CompWindowActionMaximizeVertMask)))
113
/* Don't maximize windows twice */
114
if (window->state () & (MAXIMIZE_STATE))
123
GridScreen::initiateCommon (CompAction *action,
124
CompAction::State state,
125
CompOption::Vector &option,
132
xid = CompOption::getIntOptionNamed (option, "window");
133
cw = screen->findWindow (xid);
135
if (where == GridUnknown)
145
else if (screen->otherGrabExist ("move", NULL))
154
if (!gw->allowGrid (where))
157
if (gw->lastTarget != where)
160
props = gridProps[where];
162
/* get current available area */
163
if (cw == mGrabWindow)
164
workarea = screen->getWorkareaForOutput
165
(screen->outputDeviceForPoint (pointerX, pointerY));
168
workarea = screen->getWorkareaForOutput (cw->outputDevice ());
170
if (!gw->isGridResized)
171
/* Store size not including borders when using a keybinding */
172
gw->originalSize = (CompRect &) cw->serverGeometry ();
175
if ((cw->state () & MAXIMIZE_STATE) &&
176
(resize || optionGetSnapoffMaximized ()))
178
/* maximized state interferes with us, clear it */
182
if (where == GridMaximize && resize)
184
/* move the window to the correct output */
185
if (cw == mGrabWindow)
187
xwc.x = workarea.x () + 50;
188
xwc.y = workarea.y () + 50;
189
xwc.width = workarea.width ();
190
xwc.height = workarea.height ();
191
cw->configureXWindow (CWX | CWY, &xwc);
194
cw->maximize (MAXIMIZE_STATE);
195
gw->isGridResized = true;
196
gw->isGridMaximized = true;
201
/* Should really be three different types here, but not enough time
202
* to implement that one FIXME */
207
desiredSlot = new PaintableAnimatedGridRectangle ();
214
CompRect sbr = cw->serverBorderRect ();
215
if (compositingActive)
217
CompRect sbr = cw->serverBorderRect ();
218
desiredSlot = new PaintableAnimatedGridRectangle ();
225
desiredSlot = new PaintableAnimatedGridRectangle ();
231
((AnimatedGridRectangle *) desiredSlot)->setFrom (sbr);
236
* xxxSlot include decorations (it's the screen area occupied)
237
* xxxRect are undecorated (it's the constrained position
241
/* slice and dice to get desired slot - including decorations */
242
desiredSlot->setY (workarea.y () + props.gravityDown *
243
(workarea.height () / props.numCellsY));
244
desiredSlot->setHeight (workarea.height () / props.numCellsY);
245
desiredSlot->setX (workarea.x () + props.gravityRight *
246
(workarea.width () / props.numCellsX));
247
desiredSlot->setWidth (workarea.width () / props.numCellsX);
249
/* Adjust for constraints and decorations */
250
desiredRect = gw->constrainSize (*desiredSlot).subtractBorders (cw);
251
/* Get current rect not including decorations */
252
currentRect.setGeometry (cw->serverX (), cw->serverY (),
254
cw->serverHeight ());
256
if (desiredRect.y () == currentRect.y () &&
257
desiredRect.height () == currentRect.height () &&
258
where != GridMaximize && gw->lastTarget == where)
260
int slotWidth25 = workarea.width () / 4;
261
int slotWidth33 = (workarea.width () / 3) + cw->border ().left;
262
int slotWidth17 = slotWidth33 - slotWidth25;
263
int slotWidth66 = workarea.width () - slotWidth33;
264
int slotWidth75 = workarea.width () - slotWidth25;
266
if (props.numCellsX == 2) /* keys (1, 4, 7, 3, 6, 9) */
268
if ((currentRect.width () == desiredRect.width () &&
269
currentRect.x () == desiredRect.x ()) ||
270
(gw->resizeCount < 1) || (gw->resizeCount > 5))
273
/* tricky, have to allow for window constraints when
274
* computing what the 33% and 66% offsets would be
276
switch (gw->resizeCount)
279
desiredSlot->setWidth (slotWidth66);
280
desiredSlot->setX (workarea.x () +
281
props.gravityRight * slotWidth33);
288
desiredSlot->setWidth (slotWidth33);
289
desiredSlot->setX (workarea.x () +
290
props.gravityRight * slotWidth66);
294
desiredSlot->setWidth (slotWidth25);
295
desiredSlot->setX (workarea.x () +
296
props.gravityRight * slotWidth75);
300
desiredSlot->setWidth (slotWidth75);
301
desiredSlot->setX (workarea.x () +
302
props.gravityRight * slotWidth25);
309
else /* keys (2, 5, 8) */
312
if ((currentRect.width () == desiredRect.width () &&
313
currentRect.x () == desiredRect.x ()) ||
314
(gw->resizeCount < 1) || (gw->resizeCount > 5))
317
switch (gw->resizeCount)
320
desiredSlot->setWidth (workarea.width () -
322
desiredSlot->setX (workarea.x () + slotWidth17);
326
desiredSlot->setWidth ((slotWidth25 * 2) +
328
desiredSlot->setX (workarea.x () +
329
(slotWidth25 - slotWidth17));
333
desiredSlot->setWidth ((slotWidth25 * 2));
334
desiredSlot->setX (workarea.x () + slotWidth25);
338
desiredSlot->setWidth (slotWidth33 -
339
(cw->border ().left + cw->border ().right));
340
desiredSlot->setX (workarea.x () + slotWidth33);
351
if (gw->resizeCount == 6)
354
desiredRect = gw->constrainSize (*desiredSlot).subtractBorders (cw);
357
/* TODO: animate move+resize */
360
xwc.x = desiredRect.x ();
361
xwc.y = desiredRect.y ();
362
xwc.width = desiredRect.width ();
363
xwc.height = desiredRect.height ();
365
/* Store a copy of xwc since configureXWindow changes it's values */
366
XWindowChanges wc = xwc;
367
unsigned int flags = (CWX | CWY | CWWidth | CWHeight);
370
cw->sendSyncRequest ();
375
cw->configureXWindow (flags, &xwc);
376
gw->isGridResized = true;
377
gw->isGridMaximized = false;
380
gw->lastTarget = where;
387
AnimatedGridRectangle::current ()
389
/* Expand edges out to destination rect based on progress */
391
CompRect ret = mFrom;
393
ret.setTop (floor (mFrom.top () + (top () - mFrom.top ()) * mProgress));
394
ret.setLeft (floor (mFrom.left () + (left () - mFrom.left ()) * mProgress));
395
ret.setRight (floor (mFrom.right () + (right () - mFrom.right ()) * mProgress));
396
ret.setBottom (floor (mFrom.bottom () + (bottom () - mFrom.bottom ()) * mProgress));
402
AnimatedGridRectangle::progress ()
408
AnimatedGridRectangle::setTime (unsigned int t)
414
AnimatedGridRectangle::setFrom (CompRect &f)
420
AnimatedGridRectangle::setProgress (float p)
424
if (mProgress >= 1.0f)
426
else if (mProgress <= 0.0f)
431
AnimatedGridRectangle::reset ()
437
PaintableAnimatedGridRectangle::paint (const GLMatrix &mat)
440
CompRect fill = current ();
441
GridScreen *gScreen = GridScreen::get (screen);
443
if (gScreen->optionGetIndicatorType () == GridOptions::IndicatorTypeOutline)
445
GLint origSrc, origDst;
446
CompOutput *o = &screen->outputDevs ().at (screen->outputDeviceForPoint (CompPoint (pointerX, pointerY)));
447
float alpha = (float) gScreen->optionGetFillColorAlpha () / 65535.0f * progress ();
449
glGetIntegerv (GL_BLEND_SRC, &origSrc);
450
glGetIntegerv (GL_BLEND_DST, &origDst);
454
glLoadMatrixf (mat.getMatrix ());
456
glDisableClientState (GL_TEXTURE_COORD_ARRAY);
458
glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
460
glScissor (o->x (), screen->height () - o->y (), o->width (), o->height ());
463
glColor4f (((float) gScreen->optionGetFillColorRed () / 65535.0f) * alpha,
464
((float) gScreen->optionGetFillColorGreen () / 65535.0f) * alpha,
465
((float) gScreen->optionGetFillColorBlue () / 65535.0f) * alpha,
467
glRecti (fill.x1 (), fill.y2 (), fill.x2 (), fill.y1 ());
469
/* Set outline rect smaller to avoid damage issues */
470
outline.setGeometry (fill.x () + 1, fill.y () + 1,
471
fill.width () - 2,fill. height () - 2);
474
glColor4f ((float) gScreen->optionGetOutlineColorRed () / 65535.0f,
475
(float) gScreen->optionGetOutlineColorGreen () / 65535.0f,
476
(float) gScreen->optionGetOutlineColorBlue () / 65535.0f,
477
((float) gScreen->optionGetOutlineColorAlpha () / 65535.0f) * progress ());
479
glBegin (GL_LINE_LOOP);
480
glVertex2i (outline.x1 (), outline.y1 ());
481
glVertex2i (outline.x2 (), outline.y1 ());
482
glVertex2i (outline.x2 (), outline.y2 ());
483
glVertex2i (outline.x1 (), outline.y2 ());
487
glColor4usv (defaultColor);
488
glBlendFunc (origSrc, origDst);
489
glDisable (GL_BLEND);
490
glEnableClientState (GL_TEXTURE_COORD_ARRAY);
496
GridScreen::glPaintOutput (const GLScreenPaintAttrib &attrib,
497
const GLMatrix &matrix,
498
const CompRegion ®ion,
504
mAllowPaint = ((unsigned int) output->id () ==
505
(unsigned int) screen->outputDeviceForPoint (pointerX, pointerY));
507
if (desiredSlot && optionGetDrawIndicator () &&
508
!optionGetBehindWindow () && mAllowPaint)
510
GLMatrix sTransform (matrix);
511
status = glScreen->glPaintOutput (attrib, matrix, region, output, mask);
513
sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
514
((PaintableAnimatedGridRectangle *) desiredSlot)->paint (sTransform);
517
status = glScreen->glPaintOutput (attrib, matrix, region, output, mask);
523
GridScreen::edgeToGridType ()
529
ret = (GridType) optionGetLeftEdgeAction ();
532
ret = (GridType) optionGetRightEdgeAction ();
535
ret = (GridType) optionGetTopEdgeAction ();
538
ret = (GridType) optionGetBottomEdgeAction ();
541
ret = (GridType) optionGetTopLeftCornerAction ();
544
ret = (GridType) optionGetTopRightCornerAction ();
547
ret = (GridType) optionGetBottomLeftCornerAction ();
550
ret = (GridType) optionGetBottomRightCornerAction ();
562
GridScreen::handleEvent (XEvent *event)
565
CompOption::Vector opts;
566
CompOption::Value v = CompOption::Value ((int) mGrabWindow->id ());
567
CompRect *edgeBox = NULL;
568
float edgeDist; /* interpolated 0.0f -> 1.0f based on distance */
570
screen->handleEvent (event);
572
if (event->type != MotionNotify || !mGrabWindow)
576
opts.at (0).setName ("window", CompOption::TypeInt);
579
out = screen->outputDevs ().at (
580
screen->outputDeviceForPoint (CompPoint (pointerX, pointerY)));
582
/* Detect corners first */
584
if (pointerY > (out.y () + out.height () - optionGetBottomEdgeThreshold() - 1) &&
585
pointerX < out.x () + optionGetLeftEdgeThreshold())
588
unsigned int xptr = pointerX - out.x ();
589
unsigned int yptr = (out.y () + out.height ()) - pointerY;
592
xd = MIN (((float) xptr / (float) optionGetLeftEdgeThreshold ()), 1.0f);
597
yd = MIN (((float) yptr / (float) (optionGetBottomEdgeThreshold () - 1)), 1.0f);
601
if (optionGetIndicatorDirection () == GridOptions::IndicatorDirectionFromEdge)
602
edgeBox = new CompRect (out.x (), out.y () + (out.height () - mGrabWindow->height ()),
603
mGrabWindow->width (), mGrabWindow->height ());
605
edgeDist = (xd + yd) / 2.0f;
609
else if (pointerY > (out.y () + out.height () - optionGetBottomEdgeThreshold() - 1) &&
610
pointerX > (out.x () + out.width () - optionGetRightEdgeThreshold() - 1))
613
unsigned int xptr = (out.x () + out.width ()) - pointerX;
614
unsigned int yptr = (out.y () + out.height ()) - pointerY;
617
xd = MIN (((float) xptr / (float) (optionGetRightEdgeThreshold () - 1)), 1.0f);
622
yd = MIN (((float) yptr / (float) (optionGetBottomEdgeThreshold () - 1)), 1.0f);
626
if (optionGetIndicatorDirection () == GridOptions::IndicatorDirectionFromEdge)
627
edgeBox = new CompRect (out.x () + (out.width () - mGrabWindow->width ()),
628
out.y () + (out.height () - mGrabWindow->height ()),
629
mGrabWindow->width (), mGrabWindow->height ());
631
edgeDist = (xd + yd) / 2.0f;
635
else if (pointerY < optionGetTopEdgeThreshold() &&
636
pointerX < optionGetLeftEdgeThreshold())
639
unsigned int xptr = pointerX - out.x ();
640
unsigned int yptr = pointerY - out.y ();
643
xd = MIN (((float) xptr / (float) optionGetLeftEdgeThreshold ()), 1.0f);
648
yd = MIN (((float) yptr / (float) optionGetTopEdgeThreshold ()), 1.0f);
652
if (optionGetIndicatorDirection () == GridOptions::IndicatorDirectionFromEdge)
653
edgeBox = new CompRect (out.x (),
655
mGrabWindow->width (), mGrabWindow->height ());
657
edgeDist = (xd + yd) / 2.0f;
661
else if (pointerY < out.y () + optionGetTopEdgeThreshold() &&
662
pointerX > (out.x () + out.width () - optionGetRightEdgeThreshold() - 1))
665
unsigned int xptr = (out.x () + out.width ()) - pointerX;
666
unsigned int yptr = pointerY - out.y ();
669
xd = MIN (((float) xptr / (float) (optionGetRightEdgeThreshold () - 1)), 1.0f);
674
yd = MIN (((float) yptr / (float) optionGetTopEdgeThreshold ()), 1.0f);
678
if (optionGetIndicatorDirection () == GridOptions::IndicatorDirectionFromEdge)
679
edgeBox = new CompRect (out.x () + (out.width () - mGrabWindow->width ()),
681
mGrabWindow->width (), mGrabWindow->height ());
683
edgeDist = (xd + yd) / 2.0f;
687
else if (pointerX < out.x () + optionGetLeftEdgeThreshold())
690
unsigned int xptr = pointerX - out.x ();
693
xd = MIN (((float) xptr / (float) optionGetLeftEdgeThreshold ()), 1.0f);
697
if (optionGetIndicatorDirection () == GridOptions::IndicatorDirectionFromEdge)
698
edgeBox = new CompRect (out.x (),
699
out.y () + (out.height () / 2.0f) - mGrabWindow->height () / 2.0f,
700
mGrabWindow->width (), mGrabWindow->height ());
706
else if (pointerX > (out.x () + out.width () - optionGetRightEdgeThreshold() - 1))
709
unsigned int xptr = (out.x () + out.width ()) - pointerX;
712
xd = MIN (((float) xptr / (float) (optionGetRightEdgeThreshold () - 1)), 1.0f);
716
if (optionGetIndicatorDirection () == GridOptions::IndicatorDirectionFromEdge)
717
edgeBox = new CompRect (out.x () + (out.width () - mGrabWindow->width ()),
718
out.y () + (out.height () / 2.0f) - mGrabWindow->height () / 2.0f,
719
mGrabWindow->width (), mGrabWindow->height ());
725
else if (pointerY < out.y () + optionGetTopEdgeThreshold())
728
unsigned int yptr = pointerY - out.y ();
731
yd = MIN (((float) yptr / (float) optionGetTopEdgeThreshold ()), 1.0f);
735
if (optionGetIndicatorDirection () == GridOptions::IndicatorDirectionFromEdge)
736
edgeBox = new CompRect (out.x () + (out.width () / 2.0f) - mGrabWindow->width () / 2.0f,
738
mGrabWindow->width (), mGrabWindow->height ());
744
else if (pointerY > (out.y () + out.height () - optionGetBottomEdgeThreshold() - 1))
747
unsigned int yptr = (out.y () + out.height ()) - pointerY;
750
yd = MIN (((float) yptr / (float) (optionGetBottomEdgeThreshold () - 1)), 1.0f);
754
if (optionGetIndicatorDirection () == GridOptions::IndicatorDirectionFromEdge)
755
edgeBox = new CompRect (out.x () + (out.width () / 2.0f) - mGrabWindow->width () / 2.0f,
756
out.y () + (out.height () - mGrabWindow->height ()),
757
mGrabWindow->width (), mGrabWindow->height ());
766
/* Detect when cursor enters another output */
768
currentWorkarea = screen->getWorkareaForOutput
769
(screen->outputDeviceForPoint (pointerX, pointerY));
770
if (lastWorkarea != currentWorkarea)
777
lastWorkarea = currentWorkarea;
779
if (compositingActive && cScreen)
780
cScreen->damageRegion (old);
782
initiateCommon (0, 0, opts, edgeToGridType (), false);
784
if (edgeBox && desiredSlot)
786
desiredSlot->setFrom (*edgeBox);
790
if (compositingActive && cScreen)
791
cScreen->damageRegion (desiredSlot ? *desiredSlot : old);
794
/* Detect edge region change */
795
if (lastEdge != edge)
801
((AnimatedGridRectangle *) desiredSlot)->reset ();
807
if (compositingActive && cScreen)
808
cScreen->damageRegion (old);
810
initiateCommon (0, 0, opts, edgeToGridType (), false);
812
if (edgeBox && desiredSlot)
814
desiredSlot->setFrom (*edgeBox);
818
if (compositingActive && cScreen)
819
cScreen->damageRegion (desiredSlot ? *desiredSlot : old);
822
/* The closer the user gets to the edge, the more progress should go up */
826
CompRect sbr = mGrabWindow->serverBorderRect ();
828
damage = ((AnimatedGridRectangle *) desiredSlot)->current ();
829
cScreen->damageRegion (damage);
831
if (optionGetIndicatorDirection () == GridOptions::IndicatorDirectionFromWindow)
832
((AnimatedGridRectangle *) desiredSlot)->setFrom (sbr);
833
((AnimatedGridRectangle *) desiredSlot)->setProgress (1.0f - edgeDist);
835
damage = ((AnimatedGridRectangle *) desiredSlot)->current ();
836
cScreen->damageRegion (damage);
839
GRID_WINDOW (mGrabWindow);
841
if ((gw->pointerBufDx > SNAPOFF_THRESHOLD ||
842
gw->pointerBufDy > SNAPOFF_THRESHOLD ||
843
gw->pointerBufDx < -SNAPOFF_THRESHOLD ||
844
gw->pointerBufDy < -SNAPOFF_THRESHOLD) &&
846
optionGetSnapbackWindows ())
847
restoreWindow (0, 0, opts);
851
GridWindow::glDraw (const GLMatrix &transform,
852
GLFragment::Attrib &fragment,
853
const CompRegion ®ion,
856
CompRegion nRegion = region;
858
if (gScreen->desiredSlot && gScreen->mAllowPaint)
860
nRegion = nRegion.united (gScreen->desiredSlot->current ());
862
gScreen->desiredSlot->paint (transform);
865
return glWindow->glDraw (transform, fragment, nRegion, mask);
869
GridWindow::grabNotify (int x,
874
if (screen->grabExist ("move"))
876
screen->handleEventSetEnabled (gScreen, true);
877
if (compositingActive)
879
if (gScreen->optionGetBehindWindow ())
880
glWindow->glDrawSetEnabled (this, true);
881
gScreen->glScreen->glPaintOutputSetEnabled (gScreen, true);
882
gScreen->mAllowPaint = false;
884
gScreen->mGrabWindow = window;
885
pointerBufDx = pointerBufDy = 0;
887
if (!isGridResized && gScreen->optionGetSnapbackWindows ())
888
/* Store size not including borders when grabbing with cursor */
889
originalSize = window->serverGeometry ();
892
if (screen->grabExist ("resize"))
894
isGridResized = false;
898
window->grabNotify (x, y, state, mask);
902
GridWindow::ungrabNotify ()
904
if (window == gScreen->mGrabWindow)
906
CompOption::Vector opts;
907
CompRect damage = gScreen->desiredSlot ? *gScreen->desiredSlot : CompRect (0, 0, 0, 0);
908
CompOption::Value v = CompOption::Value ((int) gScreen->mGrabWindow->id ());
911
opts.at (0).setName ("window", CompOption::TypeInt);
914
gScreen->initiateCommon
915
(0, 0, opts, gScreen->edgeToGridType (), true);
917
screen->handleEventSetEnabled (gScreen, false);
919
if (compositingActive)
921
if (gScreen->optionGetBehindWindow ())
922
glWindow->glDrawSetEnabled (this, false);
923
gScreen->glScreen->glPaintOutputSetEnabled (gScreen, false);
924
gScreen->mAllowPaint = false;
925
gScreen->cScreen->damageRegion (damage);
928
gScreen->mGrabWindow = NULL;
932
gScreen->edge = NoEdge;
934
window->ungrabNotify ();
938
GridWindow::moveNotify (int dx, int dy, bool immediate)
940
window->moveNotify (dx, dy, immediate);
947
GridScreen::restoreWindow (CompAction *action,
948
CompAction::State state,
949
CompOption::Vector &option)
952
CompWindow *cw = screen->findWindow (screen->activeWindow ());
959
if (!gw->isGridResized)
962
if (gw->isGridMaximized & !(cw->state () & MAXIMIZE_STATE))
963
gw->isGridMaximized = false;
966
if (cw == mGrabWindow)
968
xwc.x = pointerX - (gw->originalSize.width () >> 1);
969
xwc.y = pointerY + (cw->border ().top >> 1);
973
xwc.x = gw->originalSize.x ();
974
xwc.y = gw->originalSize.y ();
976
xwc.width = gw->originalSize.width ();
977
xwc.height = gw->originalSize.height ();
979
cw->configureXWindow (CWX | CWY | CWWidth | CWHeight, &xwc);
980
gw->pointerBufDx = 0;
981
gw->pointerBufDy = 0;
983
gw->isGridResized = false;
989
GridScreen::GridScreen (CompScreen *screen) :
990
PluginClassHandler<GridScreen, CompScreen> (screen),
995
if (compositingActive)
997
cScreen = CompositeScreen::get (screen);
998
glScreen = GLScreen::get (screen);
1000
CompositeScreenInterface::setHandler (cScreen, false);
1001
GLScreenInterface::setHandler (glScreen, false);
1004
ScreenInterface::setHandler (screen, false);
1006
edge = lastEdge = NoEdge;
1007
currentWorkarea = lastWorkarea = screen->getWorkareaForOutput
1008
(screen->outputDeviceForPoint (pointerX, pointerY));
1010
#define GRIDSET(opt,where,resize) \
1011
optionSet##opt##Initiate (boost::bind (&GridScreen::initiateCommon, this, \
1012
_1, _2, _3, where, resize))
1014
GRIDSET (PutCenterKey, GridCenter, true);
1015
GRIDSET (PutLeftKey, GridLeft, true);
1016
GRIDSET (PutRightKey, GridRight, true);
1017
GRIDSET (PutTopKey, GridTop, true);
1018
GRIDSET (PutBottomKey, GridBottom, true);
1019
GRIDSET (PutTopleftKey, GridTopLeft, true);
1020
GRIDSET (PutToprightKey, GridTopRight, true);
1021
GRIDSET (PutBottomleftKey, GridBottomLeft, true);
1022
GRIDSET (PutBottomrightKey, GridBottomRight, true);
1023
GRIDSET (PutMaximizeKey, GridMaximize, true);
1027
optionSetPutRestoreKeyInitiate (boost::bind (&GridScreen::
1028
restoreWindow, this, _1, _2, _3));
1032
GridWindow::GridWindow (CompWindow *window) :
1033
PluginClassHandler <GridWindow, CompWindow> (window),
1035
glWindow (GLWindow::get (window)),
1036
gScreen (GridScreen::get (screen)),
1037
isGridResized (false),
1038
isGridMaximized (false),
1042
lastTarget (GridUnknown)
1044
WindowInterface::setHandler (window);
1045
GLWindowInterface::setHandler (glWindow, false);
1048
/* Initial plugin init function called. Checks to see if we are ABI
1049
* compatible with core, otherwise unload */
1052
GridPluginVTable::init ()
1054
if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION))
1057
if (!CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI) ||
1058
!CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI))
1059
compositingActive = false;
1061
compositingActive = true;