37
37
COMPIZ_PLUGIN_20090315 (expo, ExpoPluginVTable);
39
#define sigmoid(x) (1.0f / (1.0f + exp (-5.5f * 2 * ((x) - 0.5))))
39
#define sigmoid(x) (1.0f / (1.0f + exp (-11.0f * ((x) - 0.5f))))
40
40
#define sigmoidProgress(x) ((sigmoid (x) - sigmoid (0)) / \
41
41
(sigmoid (1) - sigmoid (0)))
43
43
#define interpolate(a, b, val) (((val) * (a)) + ((1 - (val)) * (b)))
46
ExpoScreen::dndInit (CompAction *action,
47
CompAction::State state,
48
CompOption::Vector& options)
46
ExpoScreen::dndInit (CompAction *action,
47
CompAction::State state,
48
CompOption::Vector &options)
230
226
ExpoScreen::moveFocusViewport (int dx,
235
229
lastSelectedVp = selectedVp;
237
newX = selectedVp.x () + dx;
238
newY = selectedVp.y () + dy;
231
int newX = selectedVp.x () + dx;
232
int newY = selectedVp.y () + dy;
240
newX = MAX (0, MIN ((int) screen->vpSize ().width () - 1, newX));
241
newY = MAX (0, MIN ((int) screen->vpSize ().height () - 1, newY));
234
newX = MAX (0, MIN (static_cast <int> (screen->vpSize ().width ()) - 1, newX));
235
newY = MAX (0, MIN (static_cast <int> (screen->vpSize ().height ()) - 1, newY));
243
237
selectedVp.set (newX, newY);
244
238
cScreen->damageScreen ();
302
299
ExpoScreen::handleEvent (XEvent *event)
304
switch (event->type) {
306
if (expoMode && event->xkey.root == screen->root ())
308
if (event->xkey.keycode == leftKey)
309
moveFocusViewport (-1, 0);
310
else if (event->xkey.keycode == rightKey)
311
moveFocusViewport (1, 0);
312
else if (event->xkey.keycode == upKey)
313
moveFocusViewport (0, -1);
314
else if (event->xkey.keycode == downKey)
315
moveFocusViewport (0, 1);
320
if (expoMode && event->xbutton.button == Button1 &&
321
event->xbutton.root == screen->root ())
323
CompPoint pointer (event->xbutton.x_root, event->xbutton.y_root);
324
if (!screen->workArea().contains (pointer))
330
clickTime = event->xbutton.time;
332
else if (event->xbutton.time - clickTime <=
333
(unsigned int) optionGetDoubleClickTime () && lastSelectedVp == selectedVp)
339
clickTime = event->xbutton.time;
342
cScreen->damageScreen ();
343
prevClickPoint = CompPoint(event->xbutton.x, event->xbutton.y);
348
if (expoMode && event->xbutton.button == Button1 &&
349
event->xbutton.root == screen->root ())
351
CompPoint pointer (event->xbutton.x_root, event->xbutton.y_root);
352
if (!screen->workArea().contains (pointer))
355
if (event->xbutton.time - clickTime >
356
(unsigned int) optionGetDoubleClickTime ())
361
else if (doubleClick ||
362
compiz::expo::clickMovementInThreshold(prevClickPoint.x (),
367
CompAction& action = optionGetExpoKey ();
372
termExpo (&action, 0, noOptions ());
304
if (expoMode && event->xkey.root == screen->root ())
306
if (event->xkey.keycode == leftKey)
307
moveFocusViewport (-1, 0);
308
else if (event->xkey.keycode == rightKey)
309
moveFocusViewport (1, 0);
310
else if (event->xkey.keycode == upKey)
311
moveFocusViewport (0, -1);
312
else if (event->xkey.keycode == downKey)
313
moveFocusViewport (0, 1);
320
event->xbutton.button == Button1 &&
321
event->xbutton.root == screen->root ())
323
CompPoint pointer (event->xbutton.x_root, event->xbutton.y_root);
325
if (!screen->workArea ().contains (pointer))
331
clickTime = event->xbutton.time;
332
else if (event->xbutton.time - clickTime <=
333
static_cast <unsigned int> (optionGetDoubleClickTime ()) &&
334
lastSelectedVp == selectedVp)
338
clickTime = event->xbutton.time;
342
cScreen->damageScreen ();
343
prevClickPoint = CompPoint (event->xbutton.x, event->xbutton.y);
350
event->xbutton.button == Button1 &&
351
event->xbutton.root == screen->root ())
353
CompPoint pointer (event->xbutton.x_root, event->xbutton.y_root);
355
if (!screen->workArea ().contains (pointer))
358
if (event->xbutton.time - clickTime >
359
(unsigned int)optionGetDoubleClickTime ())
364
else if (doubleClick ||
365
compiz::expo::clickMovementInThreshold(prevClickPoint.x (),
370
/* TODO: What action to take if expo_key is not defined ? */
371
CompAction &action = optionGetExpoKey ();
376
termExpo (&action, 0, noOptions ());
379
387
screen->handleEvent (event);
394
403
unsigned int i, j, vp;
395
unsigned int vpCount = screen->vpSize ().width () *
396
screen->vpSize ().height ();
404
unsigned int vpCountHorz = screen->vpSize ().width ();
405
unsigned int vpCountVert = screen->vpSize ().height ();
406
unsigned int vpCount = vpCountHorz * vpCountVert;
398
408
if (vpActivity.size () < vpCount)
400
410
vpActivity.resize (vpCount);
401
foreach (float& activity, vpActivity)
412
foreach (float &activity, vpActivity)
405
for (i = 0; i < (unsigned int) screen->vpSize ().width (); i++)
416
for (i = 0; i < vpCountHorz; ++i)
407
for (j = 0; j < (unsigned int) screen->vpSize ().height (); j++)
418
for (j = 0; j < vpCountVert; ++j)
409
vp = (j * screen->vpSize ().width ()) + i;
420
vp = j * vpCountHorz + i;
411
422
if (CompPoint (i, j) == selectedVp)
412
423
vpActivity[vp] = MIN (1.0, vpActivity[vp] + val);
440
450
gScreen->glPaintOutputSetEnabled (this, enable);
441
451
gScreen->glPaintTransformedOutputSetEnabled (this, enable);
443
455
foreach (CompWindow *w, screen->windows ())
445
ExpoWindow *ew = ExpoWindow::get (w);
457
ew = ExpoWindow::get (w);
447
ew->cWindow->damageRectSetEnabled (ew, enable);
448
ew->gWindow->glPaintSetEnabled (ew, enable);
449
ew->gWindow->glDrawSetEnabled (ew, enable);
459
ew->cWindow->damageRectSetEnabled (ew, enable);
460
ew->gWindow->glPaintSetEnabled (ew, enable);
461
ew->gWindow->glDrawSetEnabled (ew, enable);
450
462
ew->gWindow->glAddGeometrySetEnabled (ew, enable);
451
463
ew->gWindow->glDrawTextureSetEnabled (ew, enable);
456
ExpoScreen::paint (CompOutput::ptrList& outputs,
468
ExpoScreen::paint (CompOutput::ptrList &outputs,
459
int width = outputs.front ()->width ();
460
int height = outputs.front ()->height ();
461
bool sizeDiff = false;
463
/* "One big wall" does not make sense where outputs are different
464
* sizes, so force multiple walls in this case
466
* TODO: Is it possible to re-create "one big wall" using
467
* independent output painting in this case? */
469
foreach (CompOutput *o, outputs)
471
if (o->width () != width || o->height () != height)
478
if (expoCam > 0.0 && outputs.size () > 1 &&
479
optionGetMultioutputMode () == MultioutputModeOneBigWall &&
472
outputs.size () > 1 &&
473
optionGetMultioutputMode () == MultioutputModeOneBigWall)
482
475
outputs.clear ();
483
476
outputs.push_back (&screen->fullscreenOutput ());
492
485
CompOption::Vector o(0);
493
486
screen->handleCompizEvent ("expo", "start_viewport_switch", o);
494
switch (vpUpdateMode) {
495
case VPUpdateMouseOver:
496
screen->moveViewport (screen->vp ().x () - selectedVp.x (),
497
screen->vp ().y () - selectedVp.y (), true);
498
screen->focusDefaultWindow ();
499
vpUpdateMode = VPUpdateNone;
501
case VPUpdatePrevious:
502
screen->moveViewport (screen->vp ().x () - origVp.x (),
503
screen->vp ().y () - origVp.y (), true);
504
lastSelectedVp = selectedVp;
506
screen->focusDefaultWindow ();
507
vpUpdateMode = VPUpdateNone;
488
switch (vpUpdateMode)
490
case VPUpdateMouseOver:
491
screen->moveViewport (screen->vp ().x () - selectedVp.x (),
492
screen->vp ().y () - selectedVp.y (), true);
493
screen->focusDefaultWindow ();
494
vpUpdateMode = VPUpdateNone;
497
case VPUpdatePrevious:
498
screen->moveViewport (screen->vp ().x () - origVp.x (),
499
screen->vp ().y () - origVp.y (), true);
500
lastSelectedVp = selectedVp;
502
screen->focusDefaultWindow ();
503
vpUpdateMode = VPUpdateNone;
512
510
screen->handleCompizEvent ("expo", "end_viewport_switch", o);
514
512
if ((expoCam > 0.0f && expoCam < 1.0f) || dndState != DnDNone)
541
540
prevCursor = newCursor;
542
541
cScreen->damageScreen ();
548
int xOffset, yOffset;
549
CompWindowList::reverse_iterator iter;
551
xOffset = screen->vpSize ().width () * screen->width ();
552
yOffset = screen->vpSize ().height () * screen->height ();
547
int xOffset = screen->vpSize ().width () * screen->width ();
548
int yOffset = screen->vpSize ().height () * screen->height ();
554
550
dndState = DnDNone;
556
for (iter = screen->windows ().rbegin ();
556
for (CompWindowList::reverse_iterator iter = screen->windows ().rbegin ();
557
557
iter != screen->windows ().rend (); ++iter)
559
CompWindow *w = *iter;
560
CompRect input (w->inputRect ());
567
if (!w->shaded () && !w->isViewable ())
560
CompRect input (w->inputRect ());
562
if (w->destroyed () ||
563
(!w->shaded () && !w->isViewable ()))
570
566
if (w->onAllViewports ())
577
nx = newCursor.x () -
578
(screen->vp ().x () * screen->width ());
579
ny = newCursor.y () -
580
(screen->vp ().y () * screen->height ());
573
nx = newCursor.x () - (screen->vp ().x () * screen->width ());
574
ny = newCursor.y () - (screen->vp ().y () * screen->height ());
583
577
inWindow = (nx >= input.left () && nx <= input.right ()) ||
584
(nx >= (input.left () + xOffset) &&
578
(nx >= (input.left () + xOffset) &&
585
579
nx <= (input.right () + xOffset));
587
581
inWindow &= (ny >= input.top () && ny <= input.bottom ()) ||
588
(ny >= (input.top () + yOffset) &&
582
(ny >= (input.top () + yOffset) &&
589
583
ny <= (input.bottom () + yOffset));
617
611
prevCursor = newCursor;
621
screen->updateGrab (grabIndex, screen->normalCursor ());
617
screen->updateGrab (grabIndex, screen->normalCursor ());
629
unproject (float winx, float winy, float winz,
630
const GLMatrix &modelview,
631
const GLMatrix &projection,
632
const GLint viewport[4],
633
float *objx, float *objy, float *objz)
626
unproject (float winx,
629
const GLMatrix &modelview,
630
const GLMatrix &projection,
631
const GLint viewport[4],
635
636
GLMatrix finalMatrix = projection * modelview;
636
637
float in[4], out[4];
678
ExpoScreen::invertTransformedVertex (const GLScreenPaintAttrib& attrib,
679
const GLMatrix& transform,
679
ExpoScreen::invertTransformedVertex (const GLScreenPaintAttrib &attrib,
680
const GLMatrix &transform,
683
684
GLMatrix sTransform (transform);
684
float p1[3], p2[3], v[3], alpha;
685
float p1[3], p2[3], v[3];
685
686
GLint viewport[4];
687
688
gScreen->glApplyTransform (attrib, output, &sTransform);
690
691
glGetIntegerv (GL_VIEWPORT, viewport);
692
693
unproject (vertex[0], screen->height () - vertex[1], 0,
693
sTransform, *gScreen->projectionMatrix (), viewport,
694
&p1[0], &p1[1], &p1[2]);
694
sTransform, *gScreen->projectionMatrix (), viewport,
695
&p1[0], &p1[1], &p1[2]);
695
696
unproject (vertex[0], screen->height () - vertex[1], -1.0,
696
sTransform, *gScreen->projectionMatrix (), viewport,
697
&p2[0], &p2[1], &p2[2]);
697
sTransform, *gScreen->projectionMatrix (), viewport,
698
&p2[0], &p2[1], &p2[2]);
699
for (int i = 0; i < 3; i++)
700
for (int i = 0; i < 3; ++i)
700
701
v[i] = p1[i] - p2[i];
702
alpha = -p1[2] / v[2];
703
float alpha = -p1[2] / v[2];
704
705
if (optionGetDeform () == DeformCurve && screen->desktopWindowCount ())
706
const float sws = screen->width () * screen->width ();
707
const float rs = (curveDistance * curveDistance) + 0.25;
708
const float p = ((2.0 * sws * (p1[2] - curveDistance) * v[2]) +
709
(2.0 * p1[0] * v[0]) -
710
(v[0] * (float) screen->width ())) /
711
((v[2] * v[2] * sws) + (v[0] * v[0]));
712
const float q = (-(sws * rs) + (sws * (p1[2] - curveDistance) *
713
(p1[2] - curveDistance)) +
714
(0.25 * sws) + (p1[0] * p1[0]) -
715
(p1[0] * (float) screen->width ())) /
716
((v[2] * v[2] * sws) + (v[0] * v[0]));
718
const float rq = (0.25 * p * p) - q;
719
const float ph = -p * 0.5;
707
const float screenWidth = static_cast <float> (screen->width ());
708
const float screenWidthSquared = screenWidth * screenWidth;
709
const float curveDistSquaredPlusQuarter = curveDistance * curveDistance + 0.25;
710
const float pOne2MinusCurveDist = p1[2] - curveDistance;
711
const float v0Squared = v[0] * v[0];
712
const float v2Squared = v[2] * v[2];
713
const float vsv = v2Squared * screenWidthSquared +
716
const float p = (2.0 * screenWidthSquared * pOne2MinusCurveDist * v[2] +
717
2.0 * p1[0] * v[0] - v[0] * screenWidth) / vsv;
718
const float q = (-screenWidthSquared * curveDistSquaredPlusQuarter +
719
screenWidthSquared * pOne2MinusCurveDist * pOne2MinusCurveDist +
720
0.25 * screenWidthSquared +
721
p1[0] * p1[0] - p1[0] * screenWidth) / vsv;
723
const float rq = 0.25 * p * p - q;
724
const float ph = -p * 0.5;
744
ExpoScreen::paintWall (const GLScreenPaintAttrib& attrib,
745
const GLMatrix& transform,
746
const CompRegion& region,
750
ExpoScreen::paintWall (const GLScreenPaintAttrib &attrib,
751
const GLMatrix& transform,
752
const CompRegion& region,
751
GLfloat vertexData[12];
757
GLfloat vertexData[12];
752
758
GLushort colorData[16];
753
759
GLMatrix sTransformW, sTransform (transform);
755
GLenum oldFilter = gScreen->textureFilter ();
757
float sx = (float) screen->width () / output->width ();
758
float sy = (float) screen->height () / output->height ();
760
float oScale, rotation = 0.0f, progress, vpp;
761
float aspectX = 1.0f, aspectY = 1.0f;
763
761
CompPoint vpSize (screen->vpSize ().width (), screen->vpSize ().height ());
765
763
/* amount of gap between viewports */
782
779
/* camera position during expo mode */
783
780
GLVector expoCamPos (0, 0, 0, 0);
782
float sx = screen->width () / static_cast <float> (output->width ());
783
float sy = screen->height () / static_cast <float> (output->height ());
785
785
if (optionGetDeform () == DeformCurve)
787
vpCamPos[GLVector::x] = -sx * (0.5 - (((float) output->x () +
788
(output->width () / 2.0)) /
789
(float) screen->width ()));
786
vpCamPos[GLVector::x] = -sx * (0.5 - ((static_cast <float> (output->x ()) +
787
output->width () / 2.0) /
788
static_cast <float> (screen->width ())));
793
vpCamPos[GLVector::x] = (screen->vp ().x () * sx) + 0.5 +
794
(output->x () / output->width ()) -
795
(vpSize.x () * 0.5 * sx) +
790
vpCamPos[GLVector::x] = screen->vp ().x () * sx + 0.5 +
791
output->x () / output->width () -
792
vpSize.x () * 0.5 * sx +
796
793
gapX * screen->vp ().x ();
798
vpCamPos[GLVector::y] = -((screen->vp ().y () * sy) + 0.5 +
799
(output->y () / output->height ())) +
800
(vpSize.y () * 0.5 * sy) -
801
gapY * screen->vp ().y ();
803
biasZ = MAX (vpSize.x () * sx, vpSize.y () * sy);
795
vpCamPos[GLVector::y] = -(screen->vp ().y () * sy + 0.5 +
796
output->y () / output->height ()) +
797
vpSize.y () * 0.5 * sy -
798
gapY * screen->vp ().y ();
800
float biasZ = MAX (vpSize.x () * sx, vpSize.y () * sy);
804
802
if (optionGetDeform () == DeformTilt || optionGetReflection ())
805
803
biasZ *= (0.15 + optionGetDistance ());
807
805
biasZ *= optionGetDistance ();
809
progress = sigmoidProgress (expoCam);
807
float progress = sigmoidProgress (expoCam);
811
809
if (optionGetDeform () != DeformCurve)
812
810
expoCamPos[GLVector::x] = gapX * (vpSize.x () - 1) * 0.5;
814
812
expoCamPos[GLVector::y] = -gapY * (vpSize.y () - 1) * 0.5;
815
813
expoCamPos[GLVector::z] = -DEFAULT_Z_CAMERA + DEFAULT_Z_CAMERA *
816
(MAX (vpSize.x () + (vpSize.x () - 1) * gapX,
814
(MAX (vpSize.x () + (vpSize.x () - 1) * gapX,
817
815
vpSize.y () + (vpSize.y () - 1) * gapY) +
820
818
/* interpolate between vpCamPos and expoCamPos */
821
821
cam[GLVector::x] = vpCamPos[GLVector::x] * (1 - progress) +
822
expoCamPos[GLVector::x] * progress;
822
expoCamPos[GLVector::x] * progress;
823
823
cam[GLVector::y] = vpCamPos[GLVector::y] * (1 - progress) +
824
expoCamPos[GLVector::y] * progress;
824
expoCamPos[GLVector::y] * progress;
825
825
cam[GLVector::z] = vpCamPos[GLVector::z] * (1 - progress) +
826
expoCamPos[GLVector::z] * progress;
826
expoCamPos[GLVector::z] * progress;
828
float aspectX = 1.0f, aspectY = 1.0f;
828
830
if (vpSize.x () > vpSize.y ())
830
aspectY = (float) vpSize.x () / (float) vpSize.y ();
832
aspectY = vpSize.x () / static_cast <float> (vpSize.y ());
832
834
aspectY *= -optionGetAspectRatio () + 1.0;
833
835
aspectY *= progress;
925
931
curveAngle = interpolate (180 / vpSize.x (), 1, optionGetCurve ());
927
curveDistance = ((0.5f * sx) + (gapX / 2.0)) /
928
tanf ((M_PI / 180.0f) * curveAngle / 2.0);
929
curveRadius = ((0.5f * sx) + (gapX / 2.0)) /
930
sinf ((M_PI / 180.0f) * curveAngle / 2.0);
933
const float halfGapX = gapX / 2.0;
935
curveDistance = ((0.5f * sx) + halfGapX) /
936
tanf ((M_PI / 360.0f) * curveAngle);
937
curveRadius = ((0.5f * sx) + halfGapX) /
938
sinf ((M_PI / 360.0f) * curveAngle);
932
940
expoActive = true;
934
for (j = 0; j < vpSize.y (); j++)
945
for (int j = 0; j < vpSize.y (); ++j)
936
947
GLMatrix sTransform2 (sTransform), sTransform3;
938
for (i = 0; i < vpSize.x (); i++)
949
for (int i = 0; i < vpSize.x (); ++i)
940
951
if (optionGetExpoAnimation () == ExpoAnimationVortex)
941
952
sTransform2.rotate (360 * expoCam,
1185
1208
cScreen->setWindowPaintOffset (0, 0);
1187
1210
gScreen->glPaintTransformedOutputSetCurrentIndex (glPaintTransformedOutputIndex);
1188
1212
gScreen->setTextureFilter (oldFilter);
1192
ExpoScreen::glPaintOutput (const GLScreenPaintAttrib& attrib,
1193
const GLMatrix& transform,
1194
const CompRegion& region,
1216
ExpoScreen::glPaintOutput (const GLScreenPaintAttrib &attrib,
1217
const GLMatrix &transform,
1218
const CompRegion ®ion,
1198
1222
if (expoCam > 0.0)
1199
1223
mask |= PAINT_SCREEN_TRANSFORMED_MASK | PAINT_SCREEN_CLEAR_MASK;
1251
ExpoWindow::glDraw (const GLMatrix& transform,
1252
const GLWindowPaintAttrib &attrib,
1253
const CompRegion& region,
1271
ExpoWindow::glDraw (const GLMatrix &transform,
1272
const GLWindowPaintAttrib &attrib,
1273
const CompRegion ®ion,
1256
1276
if (eScreen->expoCam == 0.0f)
1257
1277
return gWindow->glDraw (transform, attrib, region, mask);
1261
1279
// Scaling factors to be applied to attrib later in glDrawTexture
1262
1280
expoOpacity = 1.0f;
1264
expoAnimation = eScreen->optionGetExpoAnimation ();
1282
int expoAnimation = eScreen->optionGetExpoAnimation ();
1266
1284
if (eScreen->expoActive)
1274
1292
if (expoAnimation == ExpoScreen::ExpoAnimationZoom &&
1275
1293
eScreen->paintingVp == eScreen->selectedVp)
1277
1294
expoOpacity = (1.0f - sigmoidProgress (eScreen->expoCam));
1281
1296
expoOpacity = 0.0f;
1286
1300
bool status = gWindow->glDraw (transform, attrib, region, mask);
1288
1302
if (window->type () & CompWindowTypeDesktopMask &&
1289
eScreen->optionGetSelectedColor ()[3] && // colour is visible
1291
eScreen->paintingVp == eScreen->selectedVp &&
1303
eScreen->optionGetSelectedColor ()[3] && // colour is visible
1305
eScreen->paintingVp == eScreen->selectedVp &&
1294
1308
/* reset geometry and paint */
1295
1309
gWindow->vertexBuffer ()->begin ();
1303
1317
static const unsigned short EXPO_GRID_SIZE = 100;
1306
ExpoWindow::glAddGeometry (const GLTexture::MatrixList& matrices,
1307
const CompRegion& region,
1308
const CompRegion& clip,
1309
unsigned int maxGridWidth,
1310
unsigned int maxGridHeight)
1320
ExpoWindow::glAddGeometry (const GLTexture::MatrixList &matrices,
1321
const CompRegion ®ion,
1322
const CompRegion &clip,
1323
unsigned int maxGridWidth,
1324
unsigned int maxGridHeight)
1312
if (eScreen->expoCam > 0.0 &&
1313
screen->desktopWindowCount () &&
1326
if (eScreen->expoCam > 0.0 &&
1327
screen->desktopWindowCount () &&
1314
1328
eScreen->optionGetDeform () == ExpoScreen::DeformCurve)
1316
int i, oldVCount = gWindow->vertexBuffer ()->countVertices ();
1319
float lastX, lastZ = 0.0;
1320
const float radSquare = pow (eScreen->curveDistance, 2) + 0.25;
1323
1330
gWindow->glAddGeometry (matrices, region, clip,
1324
MIN(maxGridWidth , EXPO_GRID_SIZE),
1331
MIN (maxGridWidth, EXPO_GRID_SIZE),
1325
1332
maxGridHeight);
1327
int stride = gWindow->vertexBuffer ()->getVertexStride ();
1328
v = gWindow->vertexBuffer ()->getVertices ();
1334
int stride = gWindow->vertexBuffer ()->getVertexStride ();
1335
int oldVCount = gWindow->vertexBuffer ()->countVertices ();
1336
GLfloat *v = gWindow->vertexBuffer ()->getVertices ();
1329
1338
v += stride - 3;
1330
1339
v += stride * oldVCount;
1332
1343
if (!window->onAllViewports ())
1334
1345
offset = eScreen->cScreen->windowPaintOffset ();
1335
1346
offset = window->getMovementForOffset (offset);
1338
lastX = -1000000000.0;
1350
float lastX = -1000000000.0f;
1352
const float radSquare = pow (eScreen->curveDistance, 2) + 0.25;
1340
for (i = oldVCount; i < gWindow->vertexBuffer ()->countVertices (); i++)
1354
for (int i = oldVCount; i < gWindow->vertexBuffer ()->countVertices (); ++i)
1342
1356
if (v[0] == lastX)
1346
1358
else if (v[0] + offset.x () >= -EXPO_GRID_SIZE &&
1347
1359
v[0] + offset.x () < screen->width () + EXPO_GRID_SIZE)
1349
ang = (((v[0] + offset.x ()) / (float) screen->width ()) - 0.5);
1361
ang = ((v[0] + offset.x ()) /
1362
static_cast <float> (screen->width ())) - 0.5;
1351
1365
if (ang < radSquare)
1353
v[2] = eScreen->curveDistance - sqrt (radSquare - ang);
1367
v[2] = eScreen->curveDistance - sqrt (radSquare - ang);
1354
1368
v[2] *= sigmoidProgress (eScreen->expoCam);
1366
1379
gWindow->glAddGeometry (matrices, region, clip, maxGridWidth, maxGridHeight);
1371
ExpoWindow::glDrawTexture (GLTexture *texture,
1372
const GLMatrix &transform,
1373
const GLWindowPaintAttrib &attrib,
1383
ExpoWindow::glDrawTexture (GLTexture *texture,
1384
const GLMatrix &transform,
1385
const GLWindowPaintAttrib &attrib,
1376
1388
GLWindowPaintAttrib wAttrib (attrib);
1378
1390
if (eScreen->expoCam > 0.0)
1380
wAttrib.opacity *= expoOpacity;
1392
wAttrib.opacity *= expoOpacity;
1381
1393
wAttrib.brightness *= eScreen->vpBrightness;
1382
1394
wAttrib.saturation *= eScreen->vpSaturation;
1385
if (eScreen->expoCam > 0.0 &&
1386
eScreen->optionGetDeform () == ExpoScreen::DeformCurve &&
1387
eScreen->gScreen->lighting () &&
1397
if (eScreen->expoCam > 0.0 &&
1398
eScreen->optionGetDeform () == ExpoScreen::DeformCurve &&
1399
eScreen->gScreen->lighting () &&
1388
1400
screen->desktopWindowCount ())
1392
GLVertexBuffer *vb = gWindow->vertexBuffer ();
1394
1404
if (!window->onAllViewports ())
1397
1407
offset = window->getMovementForOffset (offset);
1400
int stride = vb->getVertexStride ();
1401
v = vb->getVertices () + stride - 3;
1410
GLVertexBuffer *vb = gWindow->vertexBuffer ();
1411
int stride = vb->getVertexStride ();
1412
GLfloat *v = vb->getVertices () + stride - 3;
1403
for (int i = 0; i < vb->countVertices (); i++)
1417
for (int i = 0; i < vb->countVertices (); ++i)
1405
float x = (v[0] + offset.x () - screen->width () / 2) *
1406
eScreen->curveAngle / screen->width ();
1419
x = (v[0] + offset.x () - screen->width () / 2) *
1420
eScreen->curveAngle / screen->width ();
1411
int idx = floor (x);
1414
1427
normal[0] = -eScreen->vpNormals[idx * 3];
1415
1428
normal[1] = eScreen->vpNormals[(idx * 3) + 1];
1416
1429
normal[2] = eScreen->vpNormals[(idx * 3) + 2];
1442
ExpoWindow::glPaint (const GLWindowPaintAttrib& attrib,
1443
const GLMatrix& transform,
1444
const CompRegion& region,
1455
ExpoWindow::glPaint (const GLWindowPaintAttrib &attrib,
1456
const GLMatrix &transform,
1457
const CompRegion ®ion,
1447
1460
if (eScreen->expoActive)
1449
float opacity = 1.0;
1453
zoomAnim = eScreen->optionGetExpoAnimation () ==
1454
ExpoScreen::ExpoAnimationZoom;
1455
hide = eScreen->optionGetHideDocks () &&
1456
(window->wmType () & CompWindowTypeDockMask);
1458
1462
if (eScreen->expoCam > 0.0)
1459
1463
mask |= PAINT_WINDOW_TRANSLUCENT_MASK;
1465
float opacity = 1.0;
1466
bool zoomAnim = eScreen->optionGetExpoAnimation () ==
1467
ExpoScreen::ExpoAnimationZoom;
1468
bool hide = eScreen->optionGetHideDocks () &&
1469
(window->wmType () & CompWindowTypeDockMask);
1462
1472
opacity = attrib.opacity * eScreen->expoCam;
1497
1507
ExpoScreen::ExpoScreen (CompScreen *s) :
1498
1508
PluginClassHandler<ExpoScreen, CompScreen> (s),
1499
1509
ExpoOptions (),
1500
cScreen (CompositeScreen::get (s)),
1501
gScreen (GLScreen::get (s)),
1508
selectedVp (s->vp ()),
1509
lastSelectedVp (s->vp ()),
1510
vpUpdateMode (VPUpdateNone),
1512
doubleClick (false),
1513
vpNormals (360 * 3),
1510
cScreen (CompositeScreen::get (s)),
1511
gScreen (GLScreen::get (s)),
1518
selectedVp (s->vp ()),
1519
lastSelectedVp (s->vp ()),
1520
vpUpdateMode (VPUpdateNone),
1522
doubleClick (false),
1523
vpNormals (360 * 3),
1515
1525
mGlowTextureProperties (&glowTextureProperties)
1517
1527
leftKey = XKeysymToKeycode (s->dpy (), XStringToKeysym ("Left"));
1553
1563
ExpoWindow::ExpoWindow (CompWindow *w) :
1554
1564
PluginClassHandler<ExpoWindow, CompWindow> (w),
1556
cWindow (CompositeWindow::get (w)),
1557
gWindow (GLWindow::get (w)),
1558
eScreen (ExpoScreen::get (screen)),
1566
cWindow (CompositeWindow::get (w)),
1567
gWindow (GLWindow::get (w)),
1568
eScreen (ExpoScreen::get (screen)),
1560
1570
expoOpacity (1.0f)
1562
1572
CompositeWindowInterface::setHandler (cWindow, false);