3
* Compiz application switcher plugin
7
* Copyright : (C) 2008 by Danny Baumann
8
* E-mail : maniac@compiz-fusion.org
10
* Based on switcher.c:
11
* Copyright : (C) 2007 David Reveman
12
* E-mail : davidr@novell.com
14
* This program is free software; you can redistribute it and/or
15
* modify it under the terms of the GNU General Public License
16
* as published by the Free Software Foundation; either version 2
17
* of the License, or (at your option) any later version.
19
* This program is distributed in the hope that it will be useful,
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
* GNU General Public License for more details.
26
#include "staticswitcher.h"
28
COMPIZ_PLUGIN_20090315 (staticswitcher, StaticSwitchPluginVTable)
31
StaticSwitchScreen::updatePopupWindow ()
33
int newXCount, newYCount;
34
int winWidth, winHeight;
36
int count = windows.size ();
37
double dCount = count;
38
int w = PREVIEWSIZE, h = PREVIEWSIZE, b = BORDER;
42
/* maximum window size is 2/3 of the current output */
43
winWidth = ::screen->currentOutputDev ().width () * 2 / 3;
44
winHeight = ::screen->currentOutputDev ().height () * 2 / 3;
48
/* don't put 4 or less windows in multiple rows */
54
aspect = (float) winWidth / winHeight;
55
/* round is available in C99 only, so use a replacement for that */
56
newYCount = floor (sqrt (dCount / aspect) + 0.5f);
57
newXCount = ceil (dCount / newYCount);
60
while ((w + b) * newXCount > winWidth ||
61
(h + b) * newYCount > winHeight)
63
/* shrink by 10% until all windows fit */
69
winWidth = MIN (count, newXCount);
70
winHeight = (count + newXCount - 1) / newXCount;
72
winWidth = winWidth * w + (winWidth + 1) * b;
73
winHeight = winHeight * h + (winHeight + 1) * b;
74
xCount = MIN (newXCount, count);
80
x = ::screen->currentOutputDev ().region ()->extents.x1 +
81
::screen->currentOutputDev ().width () / 2;
82
y = ::screen->currentOutputDev ().region ()->extents.y1 +
83
::screen->currentOutputDev ().height () / 2;
85
xsh.flags = PSize | PPosition | PWinGravity;
89
xsh.height = winHeight;
90
xsh.win_gravity = StaticGravity;
92
XSetWMNormalHints (::screen->dpy (), popupWindow, &xsh);
94
CompWindow *popup = screen->findWindow (popupWindow);
97
unsigned int valueMask = 0;
99
valueMask |= (CWX | CWY | CWWidth | CWHeight);
101
xwc.x = x - winWidth / 2;
102
xwc.y = y - winHeight / 2;
103
xwc.width = winWidth;
104
xwc.height = winHeight;
107
popup->configureXWindow (valueMask, &xwc);
109
XConfigureWindow (::screen->dpy (), popupWindow,
114
StaticSwitchScreen::updateWindowList ()
119
selectedWindow = windows.front ();
122
updatePopupWindow ();
126
StaticSwitchScreen::createWindowList ()
130
foreach (CompWindow *w, ::screen->windows ())
134
if (sw->isSwitchWin ())
136
windows.push_back (w);
138
sw->cWindow->damageRectSetEnabled (sw, true);
142
windows.sort (BaseSwitchScreen::compareWindows);
148
StaticSwitchWindow::damageRect (bool initial, const CompRect &rect)
150
return BaseSwitchWindow::damageRect (initial, rect);
153
BaseSwitchWindow::IconMode
154
StaticSwitchWindow::getIconMode ()
156
if (sScreen->optionGetIconOnly ())
158
if (!sScreen->optionGetIcon ())
165
StaticSwitchScreen::getPaintRectangle (CompWindow *w,
171
mode = optionGetHighlightRectHidden ();
173
if (w->isViewable () || w->shaded ())
175
rect = w->inputRect ();
178
else if (mode == HighlightRectHiddenTaskbarEntry &&
179
(w->iconGeometry ().x1 () != 0 ||
180
w->iconGeometry ().y1 () != 0 ||
181
w->iconGeometry ().x2 () != 0 ||
182
w->iconGeometry ().y2 () != 0))
184
rect = w->iconGeometry ();
187
else if (mode == HighlightRectHiddenOriginalWindowPosition)
189
rect = w->serverInputRect ();
201
StaticSwitchScreen::doWindowDamage (CompWindow *w)
203
if (w->isViewable () || w->shaded ())
205
CompositeWindow::get (w)->addDamage ();
210
if (getPaintRectangle (w, box, NULL))
212
CompRect boxExtended (box.x () - 2,
217
cScreen->damageRegion (CompRegion (boxExtended));
223
StaticSwitchScreen::handleSelectionChange (bool toNext, int nextIdx)
230
StaticSwitchScreen::createPopup ()
234
Display *dpy = ::screen->dpy ();
239
XSetWindowAttributes attr;
242
visual = findArgbVisual (dpy, ::screen->screenNum ());
246
xwmh.flags = InputHint;
249
xch.res_name = (char *)"compiz";
250
xch.res_class = (char *)"switcher-window";
252
attr.background_pixel = 0;
253
attr.border_pixel = 0;
254
attr.colormap = XCreateColormap (dpy, ::screen->root (), visual,
256
attr.override_redirect = 1;
259
XCreateWindow (dpy, ::screen->root (),
261
32, InputOutput, visual,
262
CWBackPixel | CWBorderPixel | CWColormap | CWOverrideRedirect, &attr);
264
XSetWMProperties (dpy, popupWindow, NULL, NULL,
265
programArgv, programArgc,
268
state[nState++] = Atoms::winStateAbove;
269
state[nState++] = Atoms::winStateSticky;
270
state[nState++] = Atoms::winStateSkipTaskbar;
271
state[nState++] = Atoms::winStateSkipPager;
273
XChangeProperty (dpy, popupWindow,
275
XA_ATOM, 32, PropModeReplace,
276
(unsigned char *) state, nState);
278
XChangeProperty (dpy, popupWindow,
280
XA_ATOM, 32, PropModeReplace,
281
(unsigned char *) &Atoms::winTypeUtil, 1);
283
::screen->setWindowProp (popupWindow, Atoms::winDesktop, 0xffffffff);
285
setSelectedWindowHint ();
287
updatePopupWindow ();
292
StaticSwitchScreen::showPopup ()
294
/* Always checks for an existing popup */
297
XMapWindow (::screen->dpy (), popupWindow);
299
cScreen->damageScreen ();
301
popupDelayTimer.stop ();
307
StaticSwitchScreen::getCursor (bool mouseSelectOn)
310
return ::screen->normalCursor ();
312
return ::screen->invisibleCursor ();
316
StaticSwitchScreen::initiate (SwitchWindowSelection selection,
317
bool shouldShowPopup)
319
bool noSwitchWindows;
322
if (::screen->otherGrabExist ("switcher", "scale", "cube", 0))
325
this->selection = selection;
326
selectedWindow = NULL;
328
noSwitchWindows = true;
329
foreach (CompWindow *w, ::screen->windows ())
331
if (StaticSwitchWindow::get (w)->isSwitchWin ())
333
noSwitchWindows = false;
340
newMouseSelect = optionGetMouseSelect () &&
341
selection != Panels && shouldShowPopup;
344
grabIndex = ::screen->pushGrab (getCursor (newMouseSelect), "switcher");
345
else if (newMouseSelect != mouseSelect)
346
::screen->updateGrab (grabIndex, getCursor (newMouseSelect));
348
mouseSelect = newMouseSelect;
354
lastActiveNum = ::screen->activeNum ();
362
delay = optionGetPopupDelay () * 1000;
365
if (popupDelayTimer.active ())
366
popupDelayTimer.stop ();
368
popupDelayTimer.start
369
(boost::bind (&StaticSwitchScreen::showPopup, this),
377
setSelectedWindowHint ();
380
lastActiveWindow = screen->activeWindow ();
381
activateEvent (true);
384
cScreen->damageScreen ();
389
::screen->handleEventSetEnabled (this, true);
390
cScreen->preparePaintSetEnabled (this, true);
391
cScreen->donePaintSetEnabled (this, true);
392
gScreen->glPaintOutputSetEnabled (this, true);
394
foreach (CompWindow *w, ::screen->windows ())
398
sw->gWindow->glPaintSetEnabled (sw, true);
404
switchTerminate (CompAction *action,
405
CompAction::State state,
406
CompOption::Vector &options)
410
xid = (Window) CompOption::getIntOptionNamed (options, "root");
413
action->setState (action->state () &
414
(unsigned)~(CompAction::StateTermKey |
415
CompAction::StateTermButton));
417
if (xid && xid != ::screen->root ())
420
SWITCH_SCREEN (screen);
424
if (ss->popupDelayTimer.active ())
425
ss->popupDelayTimer.stop ();
428
XUnmapWindow (::screen->dpy (), ss->popupWindow);
430
ss->switching = false;
432
if (state & CompAction::StateCancel)
433
ss->selectedWindow = NULL;
435
if (state && ss->selectedWindow && !ss->selectedWindow->destroyed ())
436
::screen->sendWindowActivationRequest (ss->selectedWindow->id ());
438
::screen->removeGrab (ss->grabIndex, 0);
439
ss->grabIndex = NULL;
441
if (!ss->popupWindow)
442
::screen->handleEventSetEnabled (ss, false);
444
ss->selectedWindow = NULL;
446
if (screen->activeWindow () != ss->lastActiveWindow)
448
CompWindow *w = screen->findWindow (ss->lastActiveWindow);
451
w->moveInputFocusTo ();
454
ss->setSelectedWindowHint ();
456
ss->lastActiveNum = 0;
458
ss->cScreen->damageScreen ();
465
switchInitiateCommon (CompAction *action,
466
CompAction::State state,
467
CompOption::Vector &options,
468
SwitchWindowSelection selection,
469
bool shouldShowPopup,
474
xid = (Window) CompOption::getIntOptionNamed (options, "root");
476
if (xid != ::screen->root ())
479
SWITCH_SCREEN (::screen);
483
if (selection == Group)
488
xid = (Window) CompOption::getIntOptionNamed (options, "window");
489
w = ::screen->findWindow (xid);
491
ss->clientLeader = (w->clientLeader ()) ?
492
w->clientLeader () : xid;
494
ss->clientLeader = None;
497
ss->initiate (selection, shouldShowPopup);
499
if (state & CompAction::StateInitKey)
500
action->setState (action->state () | CompAction::StateTermKey);
502
if (state & CompAction::StateInitEdge)
503
action->setState (action->state () | CompAction::StateTermEdge);
504
else if (state & CompAction::StateInitButton)
505
action->setState (action->state () | CompAction::StateTermButton);
508
ss->switchToWindow (nextWindow, ss->optionGetAutoChangeVp ());
514
StaticSwitchScreen::getMinimizedAndMatch (bool &minimizedOption,
515
CompMatch *&matchOption)
517
minimizedOption = optionGetMinimized ();
518
matchOption = &optionGetWindowMatch ();
522
StaticSwitchScreen::getMipmap ()
524
return optionGetMipmap ();
528
StaticSwitchScreen::windowRemove (CompWindow *w)
534
CompWindow *selected;
539
if (!sw->isSwitchWin (true))
542
sw->cWindow->damageRectSetEnabled (sw, false);
543
sw->gWindow->glPaintSetEnabled (sw, false);
545
old = selected = selectedWindow;
547
CompWindowList::iterator it = windows.begin ();
548
while (it != windows.end ())
557
if (it == windows.end ())
558
selected = windows.front ();
564
CompWindowList::iterator del = it;
575
if (windows.size () == 0)
577
CompOption::Vector o (0);
578
o.push_back (CompOption ("root", CompOption::TypeInt));
579
o[0].value ().set ((int) ::screen->root ());
581
switchTerminate (NULL, 0, o);
591
foreach (CompWindow *w, windows)
596
if (selectedWindow == selected)
605
popup = ::screen->findWindow (popupWindow);
607
CompositeWindow::get (popup)->addDamage ();
609
setSelectedWindowHint ();
612
if (old != selectedWindow)
614
CompositeWindow::get (selectedWindow)->addDamage ();
615
CompositeWindow::get (w)->addDamage ();
617
if (old && !old->destroyed ())
618
CompositeWindow::get (old)->addDamage ();
626
StaticSwitchScreen::getRowXOffset (int y)
629
int count = windows.size ();
631
if (count - (y * (int)xCount) >= (int)xCount)
634
switch (optionGetRowAlign ()) {
637
case RowAlignCentered:
638
retval = (xCount - count + (y * (int)xCount)) *
639
(previewWidth + previewBorder) / 2;
642
retval = (xCount - count + (y * (int)xCount)) *
643
(previewWidth + previewBorder);
651
StaticSwitchScreen::getWindowPosition (unsigned int index,
657
if (index >= windows.size ())
660
column = (int)index % xCount;
661
row = (int)index / xCount;
663
*x = column * previewWidth + (column + 1) * previewBorder;
664
*x += getRowXOffset (row);
666
*y = row * previewHeight + (row + 1) * previewBorder;
670
StaticSwitchScreen::findWindowAt (int x,
675
popup = ::screen->findWindow (popupWindow);
679
foreach (CompWindow *w, windows)
683
getWindowPosition (i, &x1, &y1);
685
x1 += popup->geometry ().x ();
686
y1 += popup->geometry ().y ();
688
x2 = x1 + previewWidth;
689
y2 = y1 + previewHeight;
691
if (x >= x1 && x < x2 && y >= y1 && y < y2)
702
StaticSwitchScreen::handleEvent (XEvent *event)
704
BaseSwitchScreen::handleEvent (event);
709
if (grabIndex && mouseSelect)
711
CompWindow *selected;
713
selected = findWindowAt (event->xbutton.x_root,
714
event->xbutton.y_root);
717
selectedWindow = selected;
719
CompOption::Vector o (0);
720
o.push_back (CompOption ("root", CompOption::TypeInt));
721
o[0].value ().set ((int) ::screen->root ());
723
switchTerminate (NULL, CompAction::StateTermButton, o);
733
StaticSwitchScreen::adjustVelocity ()
735
float dx, adjust, amount;
736
int count = windows.size ();
739
if (abs (dx) > abs (dx + count))
741
if (abs (dx) > abs (dx - count))
745
amount = fabs (dx) * 1.5f;
748
else if (amount > 2.0f)
751
mVelocity = (amount * mVelocity + adjust) / (amount + 1.0f);
753
if (fabs (dx) < 0.001f && fabs (mVelocity) < 0.001f)
763
StaticSwitchScreen::preparePaint (int msSinceLastPaint)
769
int count = windows.size ();
771
amount = msSinceLastPaint * 0.05f * optionGetSpeed ();
772
steps = amount / (0.5f * optionGetTimestep ());
773
if (!steps) steps = 1;
774
chunk = amount / (float) steps;
778
moreAdjust = adjustVelocity ();
785
pos += mVelocity * chunk;
786
pos = fmod (pos, count);
792
cScreen->preparePaint (msSinceLastPaint);
796
StaticSwitchScreen::paintRect (CompRect &box,
798
unsigned short *color,
801
glColor4us (color[0], color[1], color[2], color[3] * opacity / 100);
802
glBegin (GL_LINE_LOOP);
803
glVertex2i (box.x1 () + offset, box.y1 () + offset);
804
glVertex2i (box.x2 () - offset, box.y1 () + offset);
805
glVertex2i (box.x2 () - offset, box.y2 () - offset);
806
glVertex2i (box.x1 () + offset, box.y2 () - offset);
811
StaticSwitchScreen::glPaintOutput (const GLScreenPaintAttrib &sAttrib,
812
const GLMatrix &transform,
813
const CompRegion ®ion,
822
CompWindow *switcher, *zoomed;
823
Window zoomedAbove = None;
825
if (!popupDelayTimer.active ())
826
mode = optionGetHighlightMode ();
828
mode = HighlightModeNone;
830
if (mode == HighlightModeBringSelectedToFront)
832
CompWindow *frontWindow = ::screen->clientList ().back ();
834
zoomed = selectedWindow;
835
if (zoomed && zoomed != frontWindow)
839
for (w = zoomed->prev; w && w->id () <= 1; w = w->prev)
841
zoomedAbove = (w) ? w->id () : None;
843
::screen->unhookWindow (zoomed);
844
::screen->insertWindow (zoomed, frontWindow->id ());
856
ignoreSwitcher = true;
858
status = gScreen->glPaintOutput (sAttrib, transform, region, output,
863
::screen->unhookWindow (zoomed);
864
::screen->insertWindow (zoomed, zoomedAbove);
867
ignoreSwitcher = false;
869
switcher = ::screen->findWindow (popupWindow);
871
if (switcher || mode == HighlightModeShowRectangle)
873
GLMatrix sTransform (transform);
875
sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
878
glLoadMatrixf (sTransform.getMatrix ());
880
if (mode == HighlightModeShowRectangle)
891
if (getPaintRectangle (w, box, &opacity))
893
unsigned short *color;
899
r = optionGetHighlightColorRed ();
900
g = optionGetHighlightColorGreen ();
901
b = optionGetHighlightColorBlue ();
902
a = optionGetHighlightColorAlpha ();
903
a = a * opacity / 100;
905
glColor4us (r, g, b, a);
906
glRecti (box.x1 (), box.y2 (), box.x2 (), box.y1 ());
910
glDisable (GL_LINE_SMOOTH);
912
color = optionGetHighlightBorderColor ();
913
paintRect (box, 0, color, opacity);
914
paintRect (box, 2, color, opacity);
915
color = optionGetHighlightBorderInlayColor ();
916
paintRect (box, 1, color, opacity);
919
glColor4usv (defaultColor);
920
glDisable (GL_BLEND);
927
SWITCH_WINDOW (switcher);
929
if (!switcher->destroyed () &&
930
switcher->isViewable () &&
931
sw->cWindow->damaged ())
933
sw->gWindow->glPaint (sw->gWindow->paintAttrib (),
934
sTransform, infiniteRegion, 0);
943
status = gScreen->glPaintOutput (sAttrib, transform, region, output,
951
StaticSwitchScreen::donePaint ()
953
if (grabIndex && moreAdjust)
957
w = ::screen->findWindow (popupWindow);
959
CompositeWindow::get (w)->addDamage ();
961
else if (!grabIndex && !moreAdjust)
963
activateEvent (false);
965
cScreen->preparePaintSetEnabled (this, false);
966
cScreen->donePaintSetEnabled (this, false);
967
gScreen->glPaintOutputSetEnabled (this, false);
969
foreach (CompWindow *w, ::screen->windows ())
972
sw->cWindow->damageRectSetEnabled (sw, false);
973
sw->gWindow->glPaintSetEnabled (sw, false);
977
cScreen->donePaint ();
981
StaticSwitchScreen::paintSelectionRect (int x,
985
unsigned int opacity)
989
int count = windows.size ();
991
w = previewWidth + previewBorder;
992
h = previewHeight + previewBorder;
997
op = 1.0 - MIN (1.0, dx - (xCount - 1));
998
else if (dx + (dy * xCount) > count - 1)
999
op = 1.0 - MIN (1.0, dx - (count - 1 - (dy * xCount)));
1001
op = 1.0 + MAX (-1.0, dx);
1005
for (unsigned int i = 0; i < 4; i++)
1006
color[i] = (float)fgColor[i] * opacity * op / 0xffffffff;
1010
glTranslatef (x + previewBorder / 2 + (dx * w),
1011
y + previewBorder / 2 + (dy * h), 0.0f);
1014
glVertex2i (-1, -1);
1016
glVertex2i (w + 1, 1);
1017
glVertex2i (w + 1, -1);
1018
glVertex2i (-1, h - 1);
1019
glVertex2i (-1, h + 1);
1020
glVertex2i (w + 1, h + 1);
1021
glVertex2i (w + 1, h - 1);
1023
glVertex2i (-1, h - 1);
1024
glVertex2i (1, h - 1);
1026
glVertex2i (w - 1, 1);
1027
glVertex2i (w - 1, h - 1);
1028
glVertex2i (w + 1, h - 1);
1029
glVertex2i (w + 1, 1);
1033
glColor4usv (defaultColor);
1034
glDisable (GL_BLEND);
1038
StaticSwitchWindow::isSwitchWin (bool removing)
1040
bool baseIsSwitchWin = BaseSwitchWindow::isSwitchWin (removing);
1042
if (baseIsSwitchWin && sScreen->selection == Group)
1044
if (sScreen->clientLeader != window->clientLeader () &&
1045
sScreen->clientLeader != window->id ())
1049
return baseIsSwitchWin;
1053
StaticSwitchWindow::updateIconTexturedWindow (GLWindowPaintAttrib &sAttrib,
1060
float xScale, yScale;
1062
xScale = (float) ICON_SIZE / icon->width ();
1063
yScale = (float) ICON_SIZE / icon->height ();
1065
if (xScale < yScale)
1070
sAttrib.xScale = (float) sScreen->previewWidth * xScale / PREVIEWSIZE;
1071
sAttrib.yScale = (float) sScreen->previewWidth * yScale / PREVIEWSIZE;
1073
wx = x + sScreen->previewWidth - (sAttrib.xScale * icon->width ());
1074
wy = y + sScreen->previewHeight - (sAttrib.yScale * icon->height ());
1078
StaticSwitchWindow::updateIconNontexturedWindow (GLWindowPaintAttrib &sAttrib,
1087
sAttrib.xScale = width / icon->width ();
1088
sAttrib.yScale = height / icon->height ();
1090
if (sAttrib.xScale < sAttrib.yScale)
1091
sAttrib.yScale = sAttrib.xScale;
1093
sAttrib.xScale = sAttrib.yScale;
1095
width = icon->width () * sAttrib.xScale;
1096
height = icon->height () * sAttrib.yScale;
1098
wx = x + (sScreen->previewWidth / 2) - (width / 2);
1099
wy = y + (sScreen->previewHeight / 2) - (height / 2);
1103
StaticSwitchWindow::updateIconPos (int &wx,
1110
wx = x + (sScreen->previewWidth / 2) - (width / 2);
1111
wy = y + (sScreen->previewHeight / 2) - (height / 2);
1115
StaticSwitchWindow::paintThumb (const GLWindowPaintAttrib &attrib,
1116
const GLMatrix &transform,
1121
BaseSwitchWindow::paintThumb (attrib,
1126
sScreen->previewWidth,
1127
sScreen->previewHeight,
1128
sScreen->previewWidth * 3 / 4,
1129
sScreen->previewHeight * 3 / 4);
1133
StaticSwitchWindow::glPaint (const GLWindowPaintAttrib &attrib,
1134
const GLMatrix &transform,
1135
const CompRegion ®ion,
1140
/* We are painting the switcher popup window:
1141
* Paint the popup window first and then paint
1142
* the relevant thumbnails */
1143
if (window->id () == sScreen->popupWindow)
1147
int count = sScreen->windows.size ();
1149
CompWindow::Geometry &g = window->geometry ();
1151
if (mask & PAINT_WINDOW_OCCLUSION_DETECTION_MASK ||
1152
sScreen->ignoreSwitcher)
1155
status = gWindow->glPaint (attrib, transform, region, mask);
1157
if (!(mask & PAINT_WINDOW_TRANSFORMED_MASK) && region.isEmpty ())
1160
glPushAttrib (GL_SCISSOR_BIT);
1162
glEnable (GL_SCISSOR_TEST);
1163
glScissor (g.x (), 0, g.width (), ::screen->height ());
1166
foreach (CompWindow *w, sScreen->windows)
1168
sScreen->getWindowPosition (i, &x, &y);
1169
StaticSwitchWindow::get (w)->paintThumb (
1170
gWindow->lastPaintAttrib (), transform,
1171
mask, x + g.x (), y + g.y ());
1175
pos = fmod (sScreen->pos, count);
1176
px = fmod (pos, sScreen->xCount);
1177
py = floor (pos / sScreen->xCount);
1179
offX = sScreen->getRowXOffset (py);
1181
if (pos > count - 1)
1183
px = fmod (pos - count, sScreen->xCount);
1184
sScreen->paintSelectionRect (g.x (), g.y (), px, 0.0,
1185
gWindow->lastPaintAttrib ().opacity);
1187
px = fmod (pos, sScreen->xCount);
1188
sScreen->paintSelectionRect (g.x () + offX, g.y (),
1190
gWindow->lastPaintAttrib ().opacity);
1192
if (px > sScreen->xCount - 1)
1194
sScreen->paintSelectionRect (g.x (), g.y (), px, py,
1195
gWindow->lastPaintAttrib ().opacity);
1197
py = fmod (py + 1, ceil ((double) count / sScreen->xCount));
1198
offX = sScreen->getRowXOffset (py);
1200
sScreen->paintSelectionRect (g.x () + offX, g.y (),
1201
px - sScreen->xCount, py,
1202
gWindow->lastPaintAttrib ().opacity);
1206
sScreen->paintSelectionRect (g.x () + offX, g.y (),
1208
gWindow->lastPaintAttrib ().opacity);
1210
glDisable (GL_SCISSOR_TEST);
1213
/* Adjust opacity/brightness/saturation of windows that are
1216
else if (sScreen->switching && !sScreen->popupDelayTimer.active () &&
1217
(window != sScreen->selectedWindow))
1219
GLWindowPaintAttrib sAttrib (attrib);
1222
value = (GLuint) sScreen->optionGetSaturation ();
1224
sAttrib.saturation = sAttrib.saturation * value / 100;
1226
value = (GLuint) sScreen->optionGetBrightness ();
1228
sAttrib.brightness = sAttrib.brightness * value / 100;
1230
if (window->wmType () & (unsigned)~(CompWindowTypeDockMask |
1231
CompWindowTypeDesktopMask))
1233
value = (GLuint) sScreen->optionGetOpacity ();
1235
sAttrib.opacity = sAttrib.opacity * value / 100;
1238
status = gWindow->glPaint (sAttrib, transform, region, mask);
1240
/* Fallback case for selected window */
1243
status = gWindow->glPaint (attrib, transform, region, mask);
1249
StaticSwitchScreen::StaticSwitchScreen (CompScreen *screen) :
1250
BaseSwitchScreen (screen),
1251
PluginClassHandler<StaticSwitchScreen,CompScreen> (screen),
1252
clientLeader (None),
1259
#define SWITCHBIND(a,b,c) boost::bind (switchInitiateCommon, _1, _2, _3, a, b, c)
1261
optionSetNextButtonInitiate (SWITCHBIND (CurrentViewport, true, true));
1262
optionSetNextButtonTerminate (switchTerminate);
1263
optionSetNextKeyInitiate (SWITCHBIND (CurrentViewport, true, true));
1264
optionSetNextKeyTerminate (switchTerminate);
1265
optionSetPrevButtonInitiate (SWITCHBIND (CurrentViewport, true, false));
1266
optionSetPrevButtonTerminate (switchTerminate);
1267
optionSetPrevKeyInitiate (SWITCHBIND (CurrentViewport, true, false));
1268
optionSetPrevKeyTerminate (switchTerminate);
1270
optionSetNextAllButtonInitiate (SWITCHBIND (AllViewports, true, true));
1271
optionSetNextAllButtonTerminate (switchTerminate);
1272
optionSetNextAllKeyInitiate (SWITCHBIND (AllViewports, true, true));
1273
optionSetNextAllKeyTerminate (switchTerminate);
1274
optionSetPrevAllButtonInitiate (SWITCHBIND (AllViewports, true, false));
1275
optionSetPrevAllButtonTerminate (switchTerminate);
1276
optionSetPrevAllKeyInitiate (SWITCHBIND (AllViewports, true, false));
1277
optionSetPrevAllKeyTerminate (switchTerminate);
1279
optionSetNextGroupButtonInitiate (SWITCHBIND (Group, true, true));
1280
optionSetNextGroupButtonTerminate (switchTerminate);
1281
optionSetNextGroupKeyInitiate (SWITCHBIND (Group, true, true));
1282
optionSetNextGroupKeyTerminate (switchTerminate);
1283
optionSetPrevGroupButtonInitiate (SWITCHBIND (Group, true, false));
1284
optionSetPrevGroupButtonTerminate (switchTerminate);
1285
optionSetPrevGroupKeyInitiate (SWITCHBIND (Group, true, false));
1286
optionSetPrevGroupKeyTerminate (switchTerminate);
1288
optionSetNextNoPopupButtonInitiate (SWITCHBIND (CurrentViewport, false, true));
1289
optionSetNextNoPopupButtonTerminate (switchTerminate);
1290
optionSetNextNoPopupKeyInitiate (SWITCHBIND (CurrentViewport, false, true));
1291
optionSetNextNoPopupKeyTerminate (switchTerminate);
1292
optionSetPrevNoPopupButtonInitiate (SWITCHBIND (CurrentViewport, false, false));
1293
optionSetPrevNoPopupButtonTerminate (switchTerminate);
1294
optionSetPrevNoPopupKeyInitiate (SWITCHBIND (CurrentViewport, false, false));
1295
optionSetPrevNoPopupKeyTerminate (switchTerminate);
1297
optionSetNextPanelButtonInitiate (SWITCHBIND (Panels, false, true));
1298
optionSetNextPanelButtonTerminate (switchTerminate);
1299
optionSetNextPanelKeyInitiate (SWITCHBIND (Panels, false, true));
1300
optionSetNextPanelKeyTerminate (switchTerminate);
1301
optionSetPrevPanelButtonInitiate (SWITCHBIND (Panels, false, false));
1302
optionSetPrevPanelButtonTerminate (switchTerminate);
1303
optionSetPrevPanelKeyInitiate (SWITCHBIND (Panels, false, false));
1304
optionSetPrevPanelKeyTerminate (switchTerminate);
1308
ScreenInterface::setHandler (screen, false);
1309
CompositeScreenInterface::setHandler (cScreen, false);
1310
GLScreenInterface::setHandler (gScreen, false);
1314
StaticSwitchScreen::~StaticSwitchScreen ()
1316
if (popupDelayTimer.active ())
1317
popupDelayTimer.stop ();
1320
XDestroyWindow (::screen->dpy (), popupWindow);
1323
StaticSwitchWindow::StaticSwitchWindow (CompWindow *window) :
1324
BaseSwitchWindow (dynamic_cast<BaseSwitchScreen *>
1325
(StaticSwitchScreen::get (screen)), window),
1326
PluginClassHandler<StaticSwitchWindow,CompWindow> (window),
1327
sScreen (StaticSwitchScreen::get (screen))
1329
GLWindowInterface::setHandler (gWindow, false);
1330
CompositeWindowInterface::setHandler (cWindow, false);
1332
if (sScreen->popupWindow && sScreen->popupWindow == window->id ())
1333
gWindow->glPaintSetEnabled (this, true);
1337
StaticSwitchPluginVTable::init ()
1339
if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION) ||
1340
!CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI) ||
1341
!CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI) ||
1342
!CompPlugin::checkPluginABI ("compiztoolbox", COMPIZ_COMPIZTOOLBOX_ABI))