264
262
ExpoScreen::finishWindowMovement ()
266
dndWindow->syncPosition ();
267
dndWindow->ungrabNotify ();
269
screen->moveViewport (screen->vp ().x () - selectedVp.x (),
270
screen->vp ().y () - selectedVp.y (), true);
272
/* update saved window attributes in case we moved the
273
window to a new viewport */
274
if (dndWindow->saveMask () & CWX)
276
dndWindow->saveWc ().x = dndWindow->saveWc ().x % screen->width ();
277
if (dndWindow->saveWc ().x < 0)
278
dndWindow->saveWc ().x += screen->width ();
280
if (dndWindow->saveMask () & CWY)
282
dndWindow->saveWc ().y = dndWindow->saveWc ().y % screen->height ();
283
if (dndWindow->saveWc ().y < 0)
284
dndWindow->saveWc ().y += screen->height ();
287
/* update window attibutes to make sure a moved maximized window
288
is properly snapped to the work area */
289
if (dndWindow->state () & MAXIMIZE_STATE)
290
dndWindow->updateAttributes (CompStackingUpdateModeNone);
292
#if 0 /* FIXME: obsolete in the meantime? */
295
int centerX, centerY;
297
/* make sure we snap to the correct output */
298
lastOutput = s->currentOutputDev;
299
centerX = (WIN_X (w) + WIN_W (w) / 2) % s->width;
302
centerY = (WIN_Y (w) + WIN_H (w) / 2) % s->height;
304
centerY += s->height;
306
s->currentOutputDev = outputDeviceForPoint (s, centerX, centerY);
308
updateWindowAttributes (w, CompStackingUpdateModeNone);
310
s->currentOutputDev = lastOutput;
264
foreach (CompWindow *dndWindow, dndWindows)
266
if (dndWindow->grabbed ())
268
dndWindow->syncPosition ();
269
dndWindow->ungrabNotify ();
271
screen->updateGrab (grabIndex, None);
273
screen->moveViewport (screen->vp ().x () - selectedVp.x (),
274
screen->vp ().y () - selectedVp.y (), true);
276
/* update saved window attributes in case we moved the
277
window to a new viewport */
278
if (dndWindow->saveMask () & CWX)
280
dndWindow->saveWc ().x = dndWindow->saveWc ().x % screen->width ();
281
if (dndWindow->saveWc ().x < 0)
282
dndWindow->saveWc ().x += screen->width ();
284
if (dndWindow->saveMask () & CWY)
286
dndWindow->saveWc ().y = dndWindow->saveWc ().y % screen->height ();
287
if (dndWindow->saveWc ().y < 0)
288
dndWindow->saveWc ().y += screen->height ();
291
/* update window attibutes to make sure a moved maximized window
292
is properly snapped to the work area */
293
if (dndWindow->state () & MAXIMIZE_STATE)
294
dndWindow->updateAttributes (CompStackingUpdateModeNone);
736
ExpoScreen::paintViewport (const GLScreenPaintAttrib& attrib,
737
const GLMatrix& transform,
738
const CompRegion& region,
745
GLMatrix sTransform (transform);
746
GLMatrix sTransform2, sTransform3;
747
float sx = (float) screen->width () / output->width ();
748
float sy = (float) screen->height () / output->height ();
750
float progress = sigmoidProgress (expoCam);
752
CompPoint vpSize (screen->vpSize ().width (), screen->vpSize ().height ());
754
const float gapY = optionGetVpDistance () * 0.1f * expoCam;
755
const float gapX = optionGetVpDistance () * 0.1f * screen->height () /
756
screen->width () * expoCam;
758
/* not sure this will work with different resolutions */
759
sTransform.translate (0.0, MAX (0, vpPos.y ()) * -(sy + gapY), 0.0f);
761
sTransform2 = sTransform;
763
/* not sure this will work with different resolutions */
764
if (optionGetDeform () != DeformCurve)
765
sTransform2.translate (MAX (0, vpPos.x ()) * (sx + gapX), 0.0f, 0.0);
768
if (optionGetExpoAnimation () == ExpoAnimationVortex)
769
sTransform2.rotate (360 * expoCam,
770
0.0f, 1.0f, 2.0f * expoCam);
772
sTransform3 = sTransform2;
774
sTransform3.translate (output->x () / output->width (),
775
-output->y () / output->height (), 0.0);
777
cScreen->setWindowPaintOffset ((screen->vp ().x () - vpPos.x ()) *
779
(screen->vp ().y () - vpPos.y ()) *
782
vp = (vpPos.y () * vpSize.x ()) + vpPos.x ();
784
vpp = (expoCam * vpActivity[vp]) + (1 - expoCam);
785
vpp = sigmoidProgress (vpp);
787
vpBrightness = vpp + ((1.0 - vpp) *
788
optionGetVpBrightness () / 100.0);
789
vpSaturation = vpp + ((1.0 - vpp) *
790
optionGetVpSaturation () / 100.0);
794
if (optionGetDeform () == DeformCurve)
798
sTransform3.translate (-vpCamPos[GLVector::x], 0.0f,
799
curveDistance - DEFAULT_Z_CAMERA);
801
rotateX = -vpPos.x () + interpolate (((float) vpSize.x () / 2.0) - 0.5,
802
screen->vp ().x (), progress);
804
sTransform3.rotate (curveAngle * rotateX, 0.0, 1.0, 0.0);
806
sTransform3.translate (vpCamPos[GLVector::x], 0.0f,
807
DEFAULT_Z_CAMERA - curveDistance);
810
cScreen->getWindowPaintListSetEnabled (this, paintingDndWindow);
812
gScreen->glPaintTransformedOutput (attrib, sTransform3,
813
screen->region (), output,
816
cScreen->getWindowPaintListSetEnabled (this, !paintingDndWindow);
818
if (!reflection && !paintingDndWindow)
820
int cursor[2] = { pointerX, pointerY };
822
invertTransformedVertex (attrib, sTransform3,
825
if ((cursor[0] > 0) && (cursor[0] < (int) screen->width ()) &&
826
(cursor[1] > 0) && (cursor[1] < (int) screen->height ()))
828
newCursor.setX (vpPos.x () * screen->width () + cursor[0]);
829
newCursor.setY (vpPos.y () * screen->height () + cursor[1]);
831
if (anyClick || dndState != DnDNone)
833
/* Used to save last viewport interaction was in */
840
/* Calculate the current viewport size */
841
int tl[2] = { 0, 0 };
842
int br[2] = { screen->width (), screen->height () };
844
invertTransformedVertex (attrib, sTransform3, output, tl);
845
invertTransformedVertex (attrib, sTransform3, output, br);
847
viewport_size = CompSize (br[0] - tl[0], br[1] - tl[1]);
692
851
ExpoScreen::paintWall (const GLScreenPaintAttrib& attrib,
693
852
const GLMatrix& transform,
694
853
const CompRegion& region,
699
858
GLMatrix sTransformW, sTransform (transform);
701
859
GLenum oldFilter = gScreen->textureFilter ();
703
float sx = (float) screen->width () / output->width ();
704
float sy = (float) screen->height () / output->height ();
860
float sx = (float) screen->width () / output->width ();
861
float sy = (float) screen->height () / output->height ();
706
float oScale, rotation = 0.0f, progress, vpp;
863
float oScale, rotation = 0.0f, progress;
707
864
float aspectX = 1.0f, aspectY = 1.0f;
709
866
CompPoint vpSize (screen->vpSize ().width (), screen->vpSize ().height ());
833
990
sTransform.rotate (rotation, 0.0f, 1.0f, 0.0f);
834
991
sTransform.scale (aspectX, aspectY, 1.0);
836
float xoffset = ((vpSize.x () * sx) / ((float) screen->width ()) * optionGetXOffset ()) * sigmoidProgress (expoCam);
837
float yoffset = ((vpSize.y () * sy) / ((float) screen->height ()) * optionGetYOffset ()) * sigmoidProgress (expoCam);
838
float xadjs = 1.0f - ((float) optionGetXOffset () / (float) screen->width ()) * sigmoidProgress (expoCam);
839
float yadjs = 1.0f - ((float) optionGetYOffset () / (float) screen->height ()) * sigmoidProgress (expoCam);
998
if (output->left () == 0)
1000
xoffset = ((vpSize.x () * sx) / ((float) output->width ()) * (optionGetXOffset ()) * sigmoidProgress (expoCam));
1001
xadjs = 1.0f - ((float) (optionGetXOffset ()) / (float) (output->width ())) * sigmoidProgress (expoCam);
1004
if (output->top () == 0)
1006
yoffset = ((vpSize.y () * sy) / ((float) output->height ()) * (optionGetYOffset ()) * sigmoidProgress (expoCam));
1008
yadjs = 1.0f - ((float) (optionGetYOffset ()) / (float) output->height ()) * sigmoidProgress (expoCam);
841
1011
/* translate expo to center */
842
1012
sTransform.translate (vpSize.x () * sx * -0.5 + xoffset,
866
1036
expoActive = true;
868
for (j = 0; j < vpSize.y (); j++)
1038
for (int j = 0; j < screen->vpSize ().height (); j++)
1039
for (int i = 0; i < screen->vpSize().width (); i++)
1040
paintViewport (attrib, sTransform, region, output, mask, CompPoint (i, j), vpCamPos, reflection);
1042
paintingDndWindow = true;
1044
foreach (CompWindow *dndWindow, dndWindows)
870
GLMatrix sTransform2 (sTransform), sTransform3;
872
for (i = 0; i < vpSize.x (); i++)
874
if (optionGetExpoAnimation () == ExpoAnimationVortex)
875
sTransform2.rotate (360 * expoCam,
876
0.0f, 1.0f, 2.0f * expoCam);
878
sTransform3 = sTransform2;
880
sTransform3.translate (output->x () / output->width (),
881
-output->y () / output->height (), 0.0);
883
cScreen->setWindowPaintOffset ((screen->vp ().x () - i) *
885
(screen->vp ().y () - j) *
888
vp = (j * vpSize.x ()) + i;
890
vpp = (expoCam * vpActivity[vp]) + (1 - expoCam);
891
vpp = sigmoidProgress (vpp);
893
vpBrightness = vpp + ((1.0 - vpp) *
894
optionGetVpBrightness () / 100.0);
895
vpSaturation = vpp + ((1.0 - vpp) *
896
optionGetVpSaturation () / 100.0);
898
paintingVp.set (i, j);
900
if (optionGetDeform () == DeformCurve)
904
sTransform3.translate (-vpCamPos[GLVector::x], 0.0f,
905
curveDistance - DEFAULT_Z_CAMERA);
907
rotateX = -i + interpolate (((float) vpSize.x () / 2.0) - 0.5,
908
screen->vp ().x (), progress);
910
sTransform3.rotate (curveAngle * rotateX, 0.0, 1.0, 0.0);
912
sTransform3.translate (vpCamPos[GLVector::x], 0.0f,
913
DEFAULT_Z_CAMERA - curveDistance);
916
gScreen->glPaintTransformedOutput (attrib, sTransform3,
917
screen->region (), output,
922
int cursor[2] = { pointerX, pointerY };
924
invertTransformedVertex (attrib, sTransform3,
927
if ((cursor[0] > 0) && (cursor[0] < (int) screen->width ()) &&
928
(cursor[1] > 0) && (cursor[1] < (int) screen->height ()))
930
newCursor.setX (i * screen->width () + cursor[0]);
931
newCursor.setY (j * screen->height () + cursor[1]);
933
if (anyClick || dndState != DnDNone)
935
/* Used to save last viewport interaction was in */
936
selectedVp.set (i, j);
942
/* not sure this will work with different resolutions */
943
if (optionGetDeform () != DeformCurve)
944
sTransform2.translate (sx + gapX, 0.0f, 0.0);
947
/* not sure this will work with different resolutions */
948
sTransform.translate (0.0, -(sy + gapY), 0.0f);
1048
screen->viewportForGeometry (dndWindow->geometry (), vp);
1051
vp.setX (screen->vpSize ().width () + vp.x ());
1054
vp.setY (screen->vpSize ().height () + vp.y ());
1056
paintViewport (attrib, sTransform, infiniteRegion, output, mask, vp, vpCamPos, reflection);
1059
paintingDndWindow = false;
951
1061
glNormal3f (0.0, 0.0, -1.0);
1119
1243
(1 - sigmoidProgress (eScreen->expoCam)));
1122
return gWindow->glDraw (transform, fA, region, mask);
1246
bool status = gWindow->glDraw (wTransform, fA, region, mask);
1248
if (window->type () & CompWindowTypeDesktopMask)
1250
/* We want to set the geometry of the polka dots to the window
1252
CompRegion reg = CompRegion (0, 0, window->width (), window->height ());
1254
foreach(GLTexture * tex, eScreen->polkadots_texture)
1256
GLTexture::MatrixList matl;
1257
GLTexture::Matrix mat = tex->matrix();
1258
CompRegion paintRegion(region);
1260
/* We can reset the window geometry since it will be
1262
gWindow->geometry().reset();
1264
float xScale = screen->width () / (float) eScreen->viewport_size.width ();
1265
float yScale = screen->height () / (float) eScreen->viewport_size.height ();
1270
/* Not sure what this does, but it is necessary
1271
* (adjusts for scale?) */
1272
mat.x0 -= mat.xx * reg.boundingRect().x1();
1273
mat.y0 -= mat.yy * reg.boundingRect().y1();
1275
matl.push_back(mat);
1277
if (mask & PAINT_WINDOW_TRANSFORMED_MASK)
1278
paintRegion = infiniteRegion;
1280
/* Now allow plugins to mess with the geometry of our
1281
* dim (so we get a nice render for things like
1283
gWindow->glAddGeometry(matl, reg, paintRegion);
1285
/* Did it succeed? */
1286
if (gWindow->geometry().vertices)
1288
unsigned int glDrawTextureIndex = gWindow->glDrawTextureGetCurrentIndex();
1289
fA.setOpacity (fragment.getOpacity () * (((1.0 - eScreen->vpBrightness) + (1.0 - eScreen->vpSaturation) / 2.0)));
1290
/* Texture rendering set-up */
1291
eScreen->gScreen->setTexEnvMode(GL_MODULATE);
1292
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
1293
/* Draw the dim texture with all of it's modified
1295
gWindow->glDrawTextureSetCurrentIndex(MAXSHORT);
1296
gWindow->glDrawTexture(tex, fA, mask | PAINT_WINDOW_BLEND_MASK
1297
| PAINT_WINDOW_TRANSLUCENT_MASK |
1298
PAINT_WINDOW_TRANSFORMED_MASK);
1299
gWindow->glDrawTextureSetCurrentIndex(glDrawTextureIndex);
1300
/* Texture rendering tear-down */
1301
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
1302
eScreen->gScreen->setTexEnvMode(GL_REPLACE);
1306
/* Paint the outline */
1307
if (mGlowQuads && eScreen->paintingVp == eScreen->selectedVp)
1309
if (region.numRects ())
1311
/* reset geometry and paint */
1312
gWindow->geometry ().reset ();
1314
paintGlow (fragment, infiniteRegion, mask);
1125
1324
#define EXPO_GRID_SIZE 100
1295
1500
if (opacity <= 0)
1296
1501
mask |= PAINT_WINDOW_NO_CORE_INSTANCE_MASK;
1299
return gWindow->glPaint (attrib, transform, region, mask);
1503
wAttrib.opacity = wAttrib.opacity * opacity;
1506
/* Stretch maximized windows a little so that you don't
1507
* have an awkward gap */
1508
if (window->state () & MAXIMIZE_STATE)
1510
CompOutput *o = &screen->outputDevs ()[screen->outputDeviceForGeometry(window->geometry())];
1511
float yS = 1.0 + ((o->height () / (float) window->height ()) - 1.0f) * sigmoidProgress (eScreen->expoCam);
1512
wTransform.translate (window->x () + window->width () / 2,
1513
window->y () + window->height (),
1515
wTransform.scale (1.0f, yS, 1.0f);
1516
wTransform.translate (-(window->x () + window->width () / 2),
1517
-(window->y () + window->height ()),
1520
if (eScreen->paintingVp != vp)
1521
mask |= PAINT_WINDOW_NO_CORE_INSTANCE_MASK;
1523
mask |= PAINT_WINDOW_TRANSFORMED_MASK;
1526
if (std::find (eScreen->dndWindows.begin(), eScreen->dndWindows.end (), window) != eScreen->dndWindows.end ())
1528
if (!eScreen->paintingDndWindow)
1530
if ((1.0f - dndOpacity) <= 0.0f || (eScreen->paintingVp == vp &&
1531
eScreen->dndState != ExpoScreen::DnDNone))
1532
mask |= PAINT_WINDOW_NO_CORE_INSTANCE_MASK;
1533
else if (!window->region ().subtracted (screen->region ()).isEmpty () &&
1534
eScreen->paintingVp != vp)
1535
wAttrib.opacity = wAttrib.opacity * (1.0f - dndOpacity);
1539
mask |= PAINT_WINDOW_TRANSFORMED_MASK;
1540
if (!window->region ().subtracted (screen->region ()).isEmpty ())
1541
wAttrib.opacity = wAttrib.opacity * dndOpacity;
1545
bool status = gWindow->glPaint (wAttrib, wTransform, region, mask);
1325
1573
expoActive (false),
1326
1574
expoMode (false),
1327
1575
dndState (DnDNone),
1329
1577
origVp (s->vp ()),
1330
1578
selectedVp (s->vp ()),
1331
1579
vpUpdateMode (VPUpdateNone),
1333
1581
doubleClick (false),
1334
1582
vpNormals (360 * 3),
1584
paintingDndWindow (false),
1585
mGlowTextureProperties (&glowTextureProperties)
1588
CompString pname = "expo";
1337
1592
leftKey = XKeysymToKeycode (s->dpy (), XStringToKeysym ("Left"));
1338
1593
rightKey = XKeysymToKeycode (s->dpy (), XStringToKeysym ("Right"));
1339
1594
upKey = XKeysymToKeycode (s->dpy (), XStringToKeysym ("Up"));
1340
1595
downKey = XKeysymToKeycode (s->dpy (), XStringToKeysym ("Down"));
1597
mMoveCursor = XCreateFontCursor (screen->dpy (), XC_fleur);
1342
1599
EXPOINITBIND (ExpoKey, doExpo);
1343
1600
EXPOTERMBIND (ExpoKey, termExpo);
1344
1601
EXPOINITBIND (ExpoButton, doExpo);
1355
1612
ScreenInterface::setHandler (screen, false);
1356
1613
CompositeScreenInterface::setHandler (cScreen, false);
1357
1614
GLScreenInterface::setHandler (gScreen, false);
1616
outline_texture = GLTexture::imageDataToTexture (mGlowTextureProperties->textureData,
1617
CompSize (mGlowTextureProperties->textureSize,
1618
mGlowTextureProperties->textureSize),
1619
GL_RGBA, GL_UNSIGNED_BYTE);
1620
fname = "texture_tile.png";
1621
polkadots_texture = GLTexture::readImageToTexture (fname, pname, polkadots_texture_size);
1623
if (polkadots_texture.empty ())
1624
compLogMessage ("expo", CompLogLevelWarn, "failed to bind image to texture");
1627
foreach (GLTexture *tex, polkadots_texture)
1629
tex->enable (GLTexture::Good);
1630
glTexParameteri (tex->target (), GL_TEXTURE_WRAP_S, GL_REPEAT);
1631
glTexParameteri (tex->target (), GL_TEXTURE_WRAP_T, GL_REPEAT);
1637
ExpoScreen::~ExpoScreen ()
1640
XFreeCursor (screen->dpy (), mMoveCursor);
1644
ExpoWindow::resizeNotify(int dx, int dy, int dw, int dh)
1646
window->resizeNotify (dx, dy, dw, dh);
1648
/* mGlowQuads contains positional info, so we need to recalc that */
1651
/* FIXME: we need to find a more multitexture friendly way
1653
GLTexture::Matrix tMat = eScreen->outline_texture.at (0)->matrix ();
1654
computeGlowQuads (&tMat);
1360
1658
ExpoWindow::ExpoWindow (CompWindow *w) :
1363
1661
cWindow (CompositeWindow::get (w)),
1364
1662
gWindow (GLWindow::get (w)),
1365
eScreen (ExpoScreen::get (screen))
1663
eScreen (ExpoScreen::get (screen)),
1367
1667
CompositeWindowInterface::setHandler (cWindow, false);
1368
1668
GLWindowInterface::setHandler (gWindow, false);
1669
WindowInterface::setHandler (window, true);
1671
if (window->type () & CompWindowTypeDesktopMask)
1673
foreach (GLTexture *tex, eScreen->outline_texture)
1675
GLTexture::Matrix mat = tex->matrix ();
1676
computeGlowQuads (&mat);
1681
ExpoWindow::~ExpoWindow ()
1683
eScreen->dndWindows.remove (window);
1684
computeGlowQuads (NULL);