~linaro-graphics-wg/compiz-plugins-main/oneiric-gles2

« back to all changes in this revision

Viewing changes to expo/src/expo.cpp

  • Committer: Sam Spilsbury
  • Date: 2011-09-20 07:43:55 UTC
  • Revision ID: sam.spilsbury@canonical.com-20110920074355-puzdutejjwsu3ta2
Sync - Remove Plugins

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 *
3
 
 * Compiz expo plugin
4
 
 *
5
 
 * expo.c
6
 
 *
7
 
 * Copyright (c) 2008 Dennis Kasprzyk <racarr@opencompositing.org>
8
 
 * Copyright (c) 2006 Robert Carr <racarr@beryl-project.org>
9
 
 *
10
 
 * Authors:
11
 
 * Robert Carr <racarr@beryl-project.org>
12
 
 * Dennis Kasprzyk <onestone@opencompositing.org>
13
 
 *
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.
18
 
 *
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.
23
 
 *
24
 
 **/
25
 
 
26
 
#include "expo.h"
27
 
#include <math.h>
28
 
#include <GL/glu.h>
29
 
#include <X11/cursorfont.h>
30
 
 
31
 
COMPIZ_PLUGIN_20090315 (expo, ExpoPluginVTable);
32
 
 
33
 
#define sigmoid(x) (1.0f / (1.0f + exp (-5.5f * 2 * ((x) - 0.5))))
34
 
#define sigmoidProgress(x) ((sigmoid (x) - sigmoid (0)) / \
35
 
                            (sigmoid (1) - sigmoid (0)))
36
 
 
37
 
#define interpolate(a, b, val) (((val) * (a)) + ((1 - (val)) * (b)))
38
 
 
39
 
bool
40
 
ExpoScreen::dndInit (CompAction          *action,
41
 
                     CompAction::State   state,
42
 
                     CompOption::Vector& options)
43
 
{
44
 
    Window xid = CompOption::getIntOptionNamed (options, "root", 0);
45
 
    if (xid != screen->root ())
46
 
        return false;
47
 
 
48
 
    if (expoMode)
49
 
    {
50
 
        dndState = DnDStart;
51
 
        action->setState (action->state () | CompAction::StateTermButton);
52
 
        cScreen->damageScreen ();
53
 
 
54
 
        return true;
55
 
    }
56
 
 
57
 
    return false;
58
 
}
59
 
 
60
 
bool
61
 
ExpoScreen::dndFini (CompAction          *action,
62
 
                     CompAction::State   state,
63
 
                     CompOption::Vector& options)
64
 
{
65
 
    Window xid = CompOption::getIntOptionNamed (options, "root", 0);
66
 
    if (xid != screen->root ())
67
 
        return false;
68
 
 
69
 
    if (dndState == DnDDuring || dndState == DnDStart)
70
 
    {
71
 
        if (dndWindows.size ())
72
 
            finishWindowMovement ();
73
 
 
74
 
        dndState  = DnDNone;
75
 
 
76
 
        action->setState (action->state () & CompAction::StateInitButton);
77
 
        cScreen->damageScreen ();
78
 
 
79
 
        return true;
80
 
    }
81
 
 
82
 
    return false;
83
 
}
84
 
 
85
 
bool
86
 
ExpoScreen::doExpo (CompAction          *action,
87
 
                    CompAction::State   state,
88
 
                    CompOption::Vector& options)
89
 
{
90
 
    Window xid = CompOption::getIntOptionNamed (options, "root", 0);
91
 
    if (xid != screen->root ())
92
 
        return false;
93
 
 
94
 
    if (screen->otherGrabExist ("expo", NULL))
95
 
        return false;
96
 
 
97
 
    if (!expoMode)
98
 
    {
99
 
        if (!grabIndex)
100
 
            grabIndex = screen->pushGrab (None, "expo");
101
 
 
102
 
        updateWraps (true);
103
 
 
104
 
        expoMode    = true;
105
 
        anyClick    = false;
106
 
        doubleClick = false;
107
 
        clickTime   = 0;
108
 
 
109
 
        dndState  = DnDNone;
110
 
 
111
 
        selectedVp = screen->vp ();
112
 
        origVp     = screen->vp ();
113
 
 
114
 
        screen->addAction (&optionGetDndButton ());
115
 
        screen->addAction (&optionGetExitButton ());
116
 
        screen->addAction (&optionGetNextVpButton ());
117
 
        screen->addAction (&optionGetPrevVpButton ());
118
 
 
119
 
        cScreen->damageScreen ();
120
 
    }
121
 
    else
122
 
    {
123
 
        termExpo (action, state, options);
124
 
    }
125
 
 
126
 
    return true;
127
 
}
128
 
 
129
 
bool
130
 
ExpoScreen::termExpo (CompAction          *action,
131
 
                      CompAction::State   state,
132
 
                      CompOption::Vector& options)
133
 
{
134
 
    Window xid = CompOption::getIntOptionNamed (options, "root", 0);
135
 
    if (xid && xid != screen->root ())
136
 
        return false;
137
 
 
138
 
    if (!expoMode)
139
 
        return true;
140
 
 
141
 
    expoMode = false;
142
 
 
143
 
    if (dndState != DnDNone)
144
 
        dndFini (action, state, options);
145
 
 
146
 
    if (state & CompAction::StateCancel)
147
 
        vpUpdateMode = VPUpdatePrevious;
148
 
    else
149
 
        vpUpdateMode = VPUpdateMouseOver;
150
 
 
151
 
    dndState  = DnDNone;
152
 
 
153
 
    screen->removeAction (&optionGetDndButton ());
154
 
    screen->removeAction (&optionGetExitButton ());
155
 
    screen->removeAction (&optionGetNextVpButton ());
156
 
    screen->removeAction (&optionGetPrevVpButton ());
157
 
 
158
 
    cScreen->damageScreen ();
159
 
    screen->focusDefaultWindow ();
160
 
 
161
 
    return true;
162
 
}
163
 
 
164
 
bool
165
 
ExpoScreen::exitExpo (CompAction          *action,
166
 
                      CompAction::State   state,
167
 
                      CompOption::Vector& options)
168
 
{
169
 
    Window xid = CompOption::getIntOptionNamed (options, "root", 0);
170
 
    if (xid != screen->root ())
171
 
        return false;
172
 
 
173
 
    if (!expoMode)
174
 
        return false;
175
 
 
176
 
    termExpo (action, 0, noOptions);
177
 
    anyClick = true;
178
 
    cScreen->damageScreen ();
179
 
 
180
 
    return true;
181
 
}
182
 
 
183
 
bool
184
 
ExpoScreen::nextVp (CompAction          *action,
185
 
                    CompAction::State   state,
186
 
                    CompOption::Vector& options)
187
 
{
188
 
    unsigned int newX, newY;
189
 
    Window       xid = CompOption::getIntOptionNamed (options, "root", 0);
190
 
    if (xid != screen->root ())
191
 
        return false;
192
 
 
193
 
    if (!expoMode)
194
 
        return false;
195
 
 
196
 
    newX = selectedVp.x () + 1;
197
 
    newY = selectedVp.y ();
198
 
 
199
 
    if (newX >= (unsigned int) screen->vpSize ().width ())
200
 
    {
201
 
        newX = 0;
202
 
        newY = newY + 1;
203
 
        if (newY >= (unsigned int) screen->vpSize ().height ())
204
 
            newY = 0;
205
 
    }
206
 
 
207
 
    moveFocusViewport (newX - selectedVp.x (),
208
 
                       newY - selectedVp.y ());
209
 
    cScreen->damageScreen ();
210
 
 
211
 
    return true;
212
 
}
213
 
 
214
 
bool
215
 
ExpoScreen::prevVp (CompAction          *action,
216
 
                    CompAction::State   state,
217
 
                    CompOption::Vector& options)
218
 
{
219
 
    unsigned int newX, newY;
220
 
    Window       xid = CompOption::getIntOptionNamed (options, "root", 0);
221
 
    if (xid != screen->root ())
222
 
        return false;
223
 
 
224
 
    if (!expoMode)
225
 
        return false;
226
 
 
227
 
    newX = selectedVp.x () - 1;
228
 
    newY = selectedVp.y ();
229
 
 
230
 
    if (newX < 0)
231
 
    {
232
 
        newX = screen->vpSize ().width () - 1;
233
 
        newY = newY - 1;
234
 
        if (newY < 0)
235
 
            newY = screen->vpSize ().height () - 1;
236
 
    }
237
 
 
238
 
    moveFocusViewport (newX - selectedVp.x (),
239
 
                       newY - selectedVp.y ());
240
 
    cScreen->damageScreen ();
241
 
 
242
 
    return true;
243
 
}
244
 
 
245
 
void
246
 
ExpoScreen::moveFocusViewport (int dx,
247
 
                               int dy)
248
 
{
249
 
    int newX, newY;
250
 
 
251
 
    newX = selectedVp.x () + dx;
252
 
    newY = selectedVp.y () + dy;
253
 
 
254
 
    newX = MAX (0, MIN ((int) screen->vpSize ().width () - 1, newX));
255
 
    newY = MAX (0, MIN ((int) screen->vpSize ().height () - 1, newY));
256
 
 
257
 
    selectedVp.set (newX, newY);
258
 
    cScreen->damageScreen ();
259
 
}
260
 
 
261
 
void
262
 
ExpoScreen::finishWindowMovement ()
263
 
{
264
 
    foreach (CompWindow *dndWindow, dndWindows)
265
 
    {
266
 
        if (dndWindow->grabbed ())
267
 
        {
268
 
            dndWindow->syncPosition ();
269
 
            dndWindow->ungrabNotify ();
270
 
 
271
 
            screen->updateGrab (grabIndex, None);
272
 
 
273
 
            screen->moveViewport (screen->vp ().x () - selectedVp.x (),
274
 
                                  screen->vp ().y () - selectedVp.y (), true);
275
 
 
276
 
            /* update saved window attributes in case we moved the
277
 
    window to a new viewport */
278
 
            if (dndWindow->saveMask () & CWX)
279
 
            {
280
 
                dndWindow->saveWc ().x = dndWindow->saveWc ().x % screen->width ();
281
 
                if (dndWindow->saveWc ().x < 0)
282
 
                    dndWindow->saveWc ().x += screen->width ();
283
 
            }
284
 
            if (dndWindow->saveMask () & CWY)
285
 
            {
286
 
                dndWindow->saveWc ().y = dndWindow->saveWc ().y % screen->height ();
287
 
                if (dndWindow->saveWc ().y < 0)
288
 
                    dndWindow->saveWc ().y += screen->height ();
289
 
            }
290
 
 
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);
295
 
        }
296
 
    }
297
 
}
298
 
 
299
 
void
300
 
ExpoScreen::handleEvent (XEvent *event)
301
 
{
302
 
    switch (event->type) {
303
 
    case KeyPress:
304
 
        if (expoMode && event->xkey.root == screen->root ())
305
 
        {
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);
314
 
        }
315
 
        break;
316
 
 
317
 
    case ButtonPress:
318
 
        if (expoMode && event->xbutton.button == Button1 &&
319
 
            event->xbutton.root == screen->root ())
320
 
        {
321
 
            anyClick = true;
322
 
            if (clickTime == 0)
323
 
            {
324
 
                clickTime = event->xbutton.time;
325
 
            }
326
 
            else if (event->xbutton.time - clickTime <=
327
 
                     (unsigned int) optionGetDoubleClickTime ())
328
 
            {
329
 
                doubleClick = true;
330
 
            }
331
 
            else
332
 
            {
333
 
                clickTime   = event->xbutton.time;
334
 
                doubleClick = false;
335
 
            }
336
 
            cScreen->damageScreen ();
337
 
        }
338
 
        break;
339
 
 
340
 
    case ButtonRelease:
341
 
        if (expoMode && event->xbutton.button == Button1 &&
342
 
            event->xbutton.root == screen->root ())
343
 
        {
344
 
            if (event->xbutton.time - clickTime >
345
 
                (unsigned int) optionGetDoubleClickTime ())
346
 
            {
347
 
                clickTime   = 0;
348
 
                doubleClick = false;
349
 
            }
350
 
            else if (doubleClick)
351
 
            {
352
 
                CompAction& action = optionGetExpoKey ();
353
 
 
354
 
                clickTime   = 0;
355
 
                doubleClick = false;
356
 
 
357
 
                termExpo (&action, 0, noOptions);
358
 
                anyClick = true;
359
 
            }
360
 
        }
361
 
        break;
362
 
    }
363
 
 
364
 
    screen->handleEvent (event);
365
 
}
366
 
 
367
 
bool
368
 
ExpoScreen::windowsOnVp (CompPoint &p)
369
 
{
370
 
    foreach (CompWindow *w, screen->clientList (true))
371
 
    {
372
 
        CompPoint viewport;
373
 
 
374
 
        screen->viewportForGeometry (w->geometry (), viewport);
375
 
 
376
 
        if (viewport == p&&
377
 
            w->type () != CompWindowTypeDesktopMask &&
378
 
            w->type () != CompWindowTypeDockMask)
379
 
        {
380
 
            return true;
381
 
        }
382
 
    }
383
 
 
384
 
    return false;
385
 
}
386
 
 
387
 
void
388
 
ExpoScreen::preparePaint (int msSinceLastPaint)
389
 
{
390
 
    float val = ((float) msSinceLastPaint / 1000.0) / optionGetZoomTime ();
391
 
 
392
 
    if (expoMode)
393
 
        expoCam = MIN (1.0, expoCam + val);
394
 
    else
395
 
        expoCam = MAX (0.0, expoCam - val);
396
 
 
397
 
    if (dndState == DnDDuring)
398
 
    {
399
 
        foreach (CompWindow *w, dndWindows)
400
 
            ExpoWindow::get (w)->dndOpacity = MIN (1.0, ExpoWindow::get (w)->dndOpacity + val);
401
 
    }
402
 
    else if (dndState == DnDNone)
403
 
    {
404
 
        CompWindowList::iterator it = dndWindows.begin ();
405
 
 
406
 
        while (it != dndWindows.end ())
407
 
        {
408
 
            ExpoWindow::get ((*it))->dndOpacity = MAX (0.0, ExpoWindow::get ((*it))->dndOpacity - val);
409
 
 
410
 
            if (ExpoWindow::get ((*it))->dndOpacity <= 0.0f)
411
 
            {
412
 
                dndWindows.erase (it);
413
 
                it = dndWindows.begin ();
414
 
            }
415
 
            else
416
 
                it++;
417
 
        }
418
 
    }
419
 
 
420
 
    if (expoCam)
421
 
    {
422
 
        unsigned int i, j, vp;
423
 
        unsigned int vpCount = screen->vpSize ().width () *
424
 
                               screen->vpSize ().height ();
425
 
 
426
 
        if (vpActivity.size () < vpCount)
427
 
        {
428
 
            vpActivity.resize (vpCount);
429
 
            foreach (float& activity, vpActivity)
430
 
                activity = 1.0f;
431
 
        }
432
 
 
433
 
        for (i = 0; i < (unsigned int) screen->vpSize ().width (); i++)
434
 
        {
435
 
            for (j = 0; j < (unsigned int) screen->vpSize ().height (); j++)
436
 
            {
437
 
                vp = (j * screen->vpSize ().width ()) + i;
438
 
                CompPoint vpPos = CompPoint (i, j);
439
 
 
440
 
                if (windowsOnVp (vpPos))
441
 
                    vpActivity[vp] = MIN (1.0, vpActivity[vp] + val);
442
 
                else
443
 
                    vpActivity[vp] = MAX (0.0, vpActivity[vp] - val);
444
 
            }
445
 
        }
446
 
 
447
 
        for (i = 0; i < 360; i++)
448
 
        {
449
 
            float fi = (float) i;
450
 
 
451
 
            vpNormals[i * 3] = (-sin (fi * DEG2RAD) / screen->width ()) *
452
 
                               expoCam;
453
 
            vpNormals[(i * 3) + 1] = 0.0;
454
 
            vpNormals[(i * 3) + 2] = (-cos (fi * DEG2RAD) * expoCam) -
455
 
                                     (1 - expoCam);
456
 
        }
457
 
    }
458
 
 
459
 
    cScreen->preparePaint (msSinceLastPaint);
460
 
}
461
 
 
462
 
void
463
 
ExpoScreen::updateWraps (bool enable)
464
 
{
465
 
    screen->handleEventSetEnabled (this, enable);
466
 
    cScreen->preparePaintSetEnabled (this, enable);
467
 
    cScreen->paintSetEnabled (this, enable);
468
 
    cScreen->getWindowPaintListSetEnabled (this, false);
469
 
    cScreen->donePaintSetEnabled (this, enable);
470
 
    gScreen->glPaintOutputSetEnabled (this, enable);
471
 
    gScreen->glPaintTransformedOutputSetEnabled (this, enable);
472
 
 
473
 
    foreach (CompWindow *w, screen->windows ())
474
 
    {
475
 
        ExpoWindow *ew = ExpoWindow::get (w);
476
 
 
477
 
        ew->cWindow->damageRectSetEnabled (ew, enable);
478
 
        ew->gWindow->glPaintSetEnabled (ew, enable);
479
 
        ew->gWindow->glDrawSetEnabled (ew, enable);
480
 
        ew->gWindow->glAddGeometrySetEnabled (ew, enable);
481
 
        ew->gWindow->glDrawTextureSetEnabled (ew, enable);
482
 
    }
483
 
}
484
 
 
485
 
void
486
 
ExpoScreen::paint (CompOutput::ptrList& outputs,
487
 
                   unsigned int         mask)
488
 
{
489
 
    int width = outputs.front ()->width ();
490
 
    int height = outputs.front ()->height ();
491
 
    bool sizeDiff = false;
492
 
 
493
 
    /* "One big wall" does not make sense where outputs are different
494
 
     * sizes, so force multiple walls in this case
495
 
     *
496
 
     * TODO: Is it possible to re-create "one big wall" using
497
 
     * independent output painting in this case? */
498
 
 
499
 
    foreach (CompOutput *o, outputs)
500
 
    {
501
 
        if (o->width () != width || o->height () != height)
502
 
        {
503
 
            sizeDiff = true;
504
 
            break;
505
 
        }
506
 
    }
507
 
 
508
 
    if (expoCam > 0.0 && outputs.size () > 1 &&
509
 
        optionGetMultioutputMode () == MultioutputModeOneBigWall &&
510
 
        !sizeDiff)
511
 
    {
512
 
        outputs.clear ();
513
 
        outputs.push_back (&screen->fullscreenOutput ());
514
 
    }
515
 
 
516
 
    cScreen->paint (outputs, mask);
517
 
}
518
 
 
519
 
void
520
 
ExpoScreen::donePaint ()
521
 
{
522
 
    switch (vpUpdateMode) {
523
 
    case VPUpdateMouseOver:
524
 
        screen->moveViewport (screen->vp ().x () - selectedVp.x (),
525
 
                              screen->vp ().y () - selectedVp.y (), true);
526
 
        screen->focusDefaultWindow ();
527
 
        vpUpdateMode = VPUpdateNone;
528
 
        break;
529
 
    case VPUpdatePrevious:
530
 
        screen->moveViewport (screen->vp ().x () - origVp.x (),
531
 
                              screen->vp ().y () - origVp.y (), true);
532
 
        selectedVp = origVp;
533
 
        screen->focusDefaultWindow ();
534
 
        vpUpdateMode = VPUpdateNone;
535
 
        break;
536
 
    default:
537
 
        break;
538
 
    }
539
 
 
540
 
    if ((expoCam > 0.0f && expoCam < 1.0f) || dndState != DnDNone)
541
 
        cScreen->damageScreen ();
542
 
 
543
 
    if (expoCam == 1.0f)
544
 
    {
545
 
        foreach (float& vp, vpActivity)
546
 
            if (vp != 0.0 && vp != 1.0)
547
 
                cScreen->damageScreen ();
548
 
 
549
 
        foreach (CompWindow *w, dndWindows)
550
 
            if (ExpoWindow::get (w)->dndOpacity != 0.0f &&
551
 
                ExpoWindow::get (w)->dndOpacity != 1.0f)
552
 
                cScreen->damageScreen ();
553
 
    }
554
 
 
555
 
    if (grabIndex && expoCam <= 0.0f && !expoMode)
556
 
    {
557
 
        screen->removeGrab (grabIndex, NULL);
558
 
        grabIndex = 0;
559
 
        updateWraps (false);
560
 
    }
561
 
 
562
 
    cScreen->donePaint ();
563
 
 
564
 
    switch (dndState) {
565
 
    case DnDDuring:
566
 
        {
567
 
            if (dndWindows.size ())
568
 
            {
569
 
                foreach (CompWindow *dndWindow, dndWindows)
570
 
                {
571
 
                    if (dndWindow->grabbed ())
572
 
                    {
573
 
                        dndWindow->move (newCursor.x () - prevCursor.x (),
574
 
                                         newCursor.y () - prevCursor.y (),
575
 
                                         optionGetExpoImmediateMove ());
576
 
                    }
577
 
                }
578
 
            }
579
 
 
580
 
            prevCursor = newCursor;
581
 
            cScreen->damageScreen ();
582
 
        }
583
 
        break;
584
 
 
585
 
    case DnDStart:
586
 
        {
587
 
            int                              xOffset, yOffset;
588
 
            CompWindowList::reverse_iterator iter;
589
 
 
590
 
            xOffset = screen->vpSize ().width () * screen->width ();
591
 
            yOffset = screen->vpSize ().height () * screen->height ();
592
 
 
593
 
            dndState = DnDNone;
594
 
 
595
 
            for (iter = screen->windows ().rbegin ();
596
 
                 iter != screen->windows ().rend (); ++iter)
597
 
            {
598
 
                CompWindow *w = *iter;
599
 
                CompRect   input (w->inputRect ());
600
 
                bool       inWindow;
601
 
                int        nx, ny;
602
 
 
603
 
                if (w->destroyed ())
604
 
                    continue;
605
 
 
606
 
                if (!w->shaded () && !w->isViewable ())
607
 
                    continue;
608
 
 
609
 
                if (w->onAllViewports ())
610
 
                {
611
 
                    nx = (newCursor.x () + xOffset) % screen->width ();
612
 
                    ny = (newCursor.y () + yOffset) % screen->height ();
613
 
                }
614
 
                else
615
 
                {
616
 
                    nx = newCursor.x () -
617
 
                         (screen->vp ().x () * screen->width ());
618
 
                    ny = newCursor.y () -
619
 
                         (screen->vp ().y () * screen->height ());
620
 
                }
621
 
 
622
 
                inWindow = (nx >= input.left () && nx <= input.right ()) ||
623
 
                           (nx >= (input.left () + xOffset) &&
624
 
                            nx <= (input.right () + xOffset));
625
 
 
626
 
                inWindow &= (ny >= input.top () && ny <= input.bottom ()) ||
627
 
                            (ny >= (input.top () + yOffset) &&
628
 
                             ny <= (input.bottom () + yOffset));
629
 
 
630
 
                if (!inWindow)
631
 
                    continue;
632
 
 
633
 
                /* make sure we never move windows we're not allowed to move */
634
 
                if (!w->managed ())
635
 
                    break;
636
 
                else if (!(w->actions () & CompWindowActionMoveMask))
637
 
                    break;
638
 
                else if (w->type () & (CompWindowTypeDockMask |
639
 
                                       CompWindowTypeDesktopMask))
640
 
                    break;
641
 
 
642
 
                dndState  = DnDDuring;
643
 
                dndWindows.push_back (w);
644
 
 
645
 
                w->grabNotify (nx, ny, 0,
646
 
                               CompWindowGrabMoveMask |
647
 
                               CompWindowGrabButtonMask);
648
 
 
649
 
                screen->updateGrab (grabIndex, mMoveCursor);
650
 
 
651
 
                w->raise ();
652
 
                w->moveInputFocusTo ();
653
 
                break;
654
 
            }
655
 
 
656
 
            prevCursor = newCursor;
657
 
        }
658
 
        break;
659
 
    default:
660
 
        break;
661
 
    }
662
 
}
663
 
 
664
 
void
665
 
ExpoScreen::invertTransformedVertex (const GLScreenPaintAttrib& attrib,
666
 
                                     const GLMatrix&            transform,
667
 
                                     CompOutput                 *output,
668
 
                                     int                        vertex[2])
669
 
{
670
 
    GLMatrix sTransform (transform);
671
 
    GLdouble p1[3], p2[3], v[3], alpha;
672
 
    GLdouble mvm[16], pm[16];
673
 
    GLint    viewport[4];
674
 
    int      i;
675
 
 
676
 
    gScreen->glApplyTransform (attrib, output, &sTransform);
677
 
    sTransform.toScreenSpace (output, -attrib.zTranslate);
678
 
 
679
 
    glGetIntegerv (GL_VIEWPORT, viewport);
680
 
    for (i = 0; i < 16; i++)
681
 
    {
682
 
        mvm[i] = sTransform[i];
683
 
        pm[i]  = gScreen->projectionMatrix ()[i];
684
 
    }
685
 
 
686
 
    gluUnProject (vertex[0], screen->height () - vertex[1], 0, mvm, pm,
687
 
                  viewport, &p1[0], &p1[1], &p1[2]);
688
 
    gluUnProject (vertex[0], screen->height () - vertex[1], -1.0, mvm, pm,
689
 
                  viewport, &p2[0], &p2[1], &p2[2]);
690
 
 
691
 
    for (i = 0; i < 3; i++)
692
 
        v[i] = p1[i] - p2[i];
693
 
 
694
 
    alpha = -p1[2] / v[2];
695
 
 
696
 
    if (optionGetDeform () == DeformCurve && screen->desktopWindowCount ())
697
 
    {
698
 
        const float sws = screen->width () * screen->width ();
699
 
        const float rs = (curveDistance * curveDistance) + 0.25;
700
 
        const float p = ((2.0 * sws * (p1[2] - curveDistance) * v[2]) +
701
 
                         (2.0 * p1[0] * v[0]) -
702
 
                         (v[0] * (float) screen->width ())) /
703
 
                        ((v[2] * v[2] * sws) + (v[0] * v[0]));
704
 
        const float q = (-(sws * rs) + (sws * (p1[2] - curveDistance) *
705
 
                                        (p1[2] - curveDistance)) +
706
 
                         (0.25 * sws) + (p1[0] * p1[0]) -
707
 
                         (p1[0] * (float) screen->width ())) /
708
 
                        ((v[2] * v[2] * sws) + (v[0] * v[0]));
709
 
 
710
 
        const float rq = (0.25 * p * p) - q;
711
 
        const float ph = -p * 0.5;
712
 
 
713
 
        if (rq < 0.0)
714
 
        {
715
 
            vertex[0] = -1000;
716
 
            vertex[1] = -1000;
717
 
            return;
718
 
        }
719
 
        else
720
 
        {
721
 
            alpha = ph + sqrt(rq);
722
 
            if (p1[2] + (alpha * v[2]) > 0.0)
723
 
            {
724
 
                vertex[0] = -1000;
725
 
                vertex[1] = -1000;
726
 
                return;
727
 
            }
728
 
        }
729
 
    }
730
 
 
731
 
    vertex[0] = ceil (p1[0] + (alpha * v[0]));
732
 
    vertex[1] = ceil (p1[1] + (alpha * v[1]));
733
 
}
734
 
 
735
 
void
736
 
ExpoScreen::paintViewport (const GLScreenPaintAttrib& attrib,
737
 
                           const GLMatrix&            transform,
738
 
                           const CompRegion&          region,
739
 
                           CompOutput                 *output,
740
 
                           unsigned int               mask,
741
 
                           CompPoint                  vpPos,
742
 
                           GLVector                   &vpCamPos,
743
 
                           bool                       reflection)
744
 
{
745
 
    GLMatrix     sTransform (transform);
746
 
    GLMatrix     sTransform2, sTransform3;
747
 
    float        sx = (float) screen->width () / output->width ();
748
 
    float        sy = (float) screen->height () / output->height ();
749
 
    float        vpp;
750
 
    float        progress = sigmoidProgress (expoCam);
751
 
    unsigned int vp;
752
 
    CompPoint    vpSize (screen->vpSize ().width (), screen->vpSize ().height ());
753
 
 
754
 
    const float gapY = optionGetVpDistance () * 0.1f * expoCam;
755
 
    const float gapX = optionGetVpDistance () * 0.1f * screen->height () /
756
 
                       screen->width () * expoCam;
757
 
 
758
 
    /* not sure this will work with different resolutions */
759
 
    sTransform.translate (0.0, MAX (0, vpPos.y ()) * -(sy + gapY), 0.0f);
760
 
 
761
 
    sTransform2 = sTransform;
762
 
 
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);
766
 
 
767
 
 
768
 
    if (optionGetExpoAnimation () == ExpoAnimationVortex)
769
 
        sTransform2.rotate (360 * expoCam,
770
 
                            0.0f, 1.0f, 2.0f * expoCam);
771
 
 
772
 
    sTransform3 = sTransform2;
773
 
 
774
 
    sTransform3.translate (output->x () / output->width (),
775
 
                           -output->y () / output->height (), 0.0);
776
 
 
777
 
    cScreen->setWindowPaintOffset ((screen->vp ().x () - vpPos.x ()) *
778
 
                                   screen->width (),
779
 
                                   (screen->vp ().y () - vpPos.y ()) *
780
 
                                   screen->height ());
781
 
 
782
 
    vp = (vpPos.y () * vpSize.x ()) + vpPos.x ();
783
 
 
784
 
    vpp = (expoCam * vpActivity[vp]) + (1 - expoCam);
785
 
    vpp = sigmoidProgress (vpp);
786
 
 
787
 
    vpBrightness = vpp + ((1.0 - vpp) *
788
 
                          optionGetVpBrightness () / 100.0);
789
 
    vpSaturation = vpp + ((1.0 - vpp) *
790
 
                          optionGetVpSaturation () / 100.0);
791
 
 
792
 
    paintingVp = vpPos;
793
 
 
794
 
    if (optionGetDeform () == DeformCurve)
795
 
    {
796
 
        float rotateX;
797
 
 
798
 
        sTransform3.translate (-vpCamPos[GLVector::x], 0.0f,
799
 
                               curveDistance - DEFAULT_Z_CAMERA);
800
 
 
801
 
        rotateX = -vpPos.x () + interpolate (((float) vpSize.x () / 2.0) - 0.5,
802
 
                                    screen->vp ().x (), progress);
803
 
 
804
 
        sTransform3.rotate (curveAngle * rotateX, 0.0, 1.0, 0.0);
805
 
 
806
 
        sTransform3.translate (vpCamPos[GLVector::x], 0.0f,
807
 
                               DEFAULT_Z_CAMERA - curveDistance);
808
 
    }
809
 
 
810
 
    cScreen->getWindowPaintListSetEnabled (this, paintingDndWindow);
811
 
 
812
 
    gScreen->glPaintTransformedOutput (attrib, sTransform3,
813
 
                                       screen->region (), output,
814
 
                                       mask);
815
 
 
816
 
    cScreen->getWindowPaintListSetEnabled (this, !paintingDndWindow);
817
 
 
818
 
    if (!reflection && !paintingDndWindow)
819
 
    {
820
 
        int cursor[2] = { pointerX, pointerY };
821
 
 
822
 
        invertTransformedVertex (attrib, sTransform3,
823
 
                                 output, cursor);
824
 
 
825
 
        if ((cursor[0] > 0) && (cursor[0] < (int) screen->width ()) &&
826
 
                (cursor[1] > 0) && (cursor[1] < (int) screen->height ()))
827
 
        {
828
 
            newCursor.setX (vpPos.x () * screen->width () + cursor[0]);
829
 
            newCursor.setY (vpPos.y () * screen->height () + cursor[1]);
830
 
 
831
 
            if (anyClick || dndState != DnDNone)
832
 
            {
833
 
                /* Used to save last viewport interaction was in */
834
 
                selectedVp = vpPos;
835
 
                anyClick = false;
836
 
            }
837
 
        }
838
 
    }
839
 
 
840
 
    /* Calculate the current viewport size */
841
 
    int tl[2] = { 0, 0 };
842
 
    int br[2] = { screen->width (), screen->height () };
843
 
 
844
 
    invertTransformedVertex (attrib, sTransform3, output, tl);
845
 
    invertTransformedVertex (attrib, sTransform3, output, br);
846
 
 
847
 
    viewport_size = CompSize (br[0] - tl[0], br[1] - tl[1]);
848
 
}
849
 
 
850
 
void
851
 
ExpoScreen::paintWall (const GLScreenPaintAttrib& attrib,
852
 
                       const GLMatrix&            transform,
853
 
                       const CompRegion&          region,
854
 
                       CompOutput                 *output,
855
 
                       unsigned int               mask,
856
 
                       bool                       reflection)
857
 
{
858
 
    GLMatrix sTransformW, sTransform (transform);
859
 
    GLenum   oldFilter = gScreen->textureFilter ();
860
 
    float        sx = (float) screen->width () / output->width ();
861
 
    float        sy = (float) screen->height () / output->height ();
862
 
    float     biasZ;
863
 
    float     oScale, rotation = 0.0f, progress;
864
 
    float     aspectX = 1.0f, aspectY = 1.0f;
865
 
    GLVector  cam;
866
 
    CompPoint vpSize (screen->vpSize ().width (), screen->vpSize ().height ());
867
 
 
868
 
    /* amount of gap between viewports */
869
 
    const float gapY = optionGetVpDistance () * 0.1f * expoCam;
870
 
    const float gapX = optionGetVpDistance () * 0.1f * screen->height () /
871
 
                       screen->width () * expoCam;
872
 
 
873
 
    int      glPaintTransformedOutputIndex =
874
 
        gScreen->glPaintTransformedOutputGetCurrentIndex ();
875
 
 
876
 
    // Make sure that the base glPaintTransformedOutput function is called
877
 
    gScreen->glPaintTransformedOutputSetCurrentIndex (MAXSHORT);
878
 
 
879
 
    /* Zoom animation stuff */
880
 
    /* camera position for the selected viewport */
881
 
    GLVector vpCamPos (0, 0, 0, 0);
882
 
 
883
 
    /* camera position during expo mode */
884
 
    GLVector expoCamPos (0, 0, 0, 0);
885
 
 
886
 
    if (optionGetDeform () == DeformCurve)
887
 
    {
888
 
        vpCamPos[GLVector::x] = -sx * (0.5 - (((float) output->x () +
889
 
                                               (output->width () / 2.0)) /
890
 
                                              (float) screen->width ()));
891
 
    }
892
 
    else
893
 
    {
894
 
        vpCamPos[GLVector::x] = (screen->vp ().x () * sx) + 0.5 +
895
 
                                (output->x () / output->width ()) -
896
 
                                (vpSize.x () * 0.5 * sx) +
897
 
                                gapX * screen->vp ().x ();
898
 
    }
899
 
    vpCamPos[GLVector::y] = -((screen->vp ().y () * sy) + 0.5 +
900
 
                              (output->y () / output->height ())) +
901
 
                             (vpSize.y () * 0.5 * sy) -
902
 
                             gapY * screen->vp ().y ();
903
 
 
904
 
    biasZ = MAX (vpSize.x () * sx, vpSize.y () * sy);
905
 
    if (optionGetDeform () == DeformTilt || optionGetReflection ())
906
 
        biasZ *= (0.15 + optionGetDistance ());
907
 
    else
908
 
        biasZ *= optionGetDistance ();
909
 
 
910
 
    progress = sigmoidProgress (expoCam);
911
 
 
912
 
    if (optionGetDeform () != DeformCurve)
913
 
        expoCamPos[GLVector::x] = gapX * (vpSize.x () - 1) * 0.5;
914
 
 
915
 
    expoCamPos[GLVector::y] = -gapY * (vpSize.y () - 1) * 0.5;
916
 
    expoCamPos[GLVector::z] = -DEFAULT_Z_CAMERA + DEFAULT_Z_CAMERA *
917
 
                              (MAX (vpSize.x () + (vpSize.x () - 1) * gapX,
918
 
                                    vpSize.y () + (vpSize.y () - 1) * gapY) +
919
 
                               biasZ);
920
 
 
921
 
    /* interpolate between vpCamPos and expoCamPos */
922
 
    cam[GLVector::x] = vpCamPos[GLVector::x] * (1 - progress) +
923
 
                       expoCamPos[GLVector::x] * progress;
924
 
    cam[GLVector::y] = vpCamPos[GLVector::y] * (1 - progress) +
925
 
                       expoCamPos[GLVector::y] * progress;
926
 
    cam[GLVector::z] = vpCamPos[GLVector::z] * (1 - progress) +
927
 
                       expoCamPos[GLVector::z] * progress;
928
 
 
929
 
    if (vpSize.x () > vpSize.y ())
930
 
    {
931
 
        aspectY = (float) vpSize.x () / (float) vpSize.y ();
932
 
        aspectY -= 1.0;
933
 
        aspectY *= -optionGetAspectRatio () + 1.0;
934
 
        aspectY *= progress;
935
 
        aspectY += 1.0;
936
 
    }
937
 
    else
938
 
    {
939
 
        aspectX = (float) vpSize.y () / (float) vpSize.x ();
940
 
        aspectX -= 1.0;
941
 
        aspectX *= -optionGetAspectRatio () + 1.0;
942
 
        aspectX *= progress;
943
 
        aspectX += 1.0;
944
 
    }
945
 
 
946
 
    /* End of Zoom animation stuff */
947
 
 
948
 
    if (optionGetDeform () == DeformTilt)
949
 
    {
950
 
        if (optionGetExpoAnimation () == ExpoAnimationZoom)
951
 
            rotation = 10.0 * sigmoidProgress (expoCam);
952
 
        else
953
 
            rotation = 10.0 * expoCam;
954
 
    }
955
 
 
956
 
    if (optionGetMipmaps ())
957
 
        gScreen->setTextureFilter (GL_LINEAR_MIPMAP_LINEAR);
958
 
 
959
 
    /* ALL TRANSFORMATION ARE EXECUTED FROM BOTTOM TO TOP */
960
 
 
961
 
    oScale = 1 / (1 + ((MAX (sx, sy) - 1) * progress));
962
 
 
963
 
    sTransform.scale (oScale, oScale, 1.0);
964
 
 
965
 
    /* zoom out */
966
 
    oScale = DEFAULT_Z_CAMERA / (cam[GLVector::z] + DEFAULT_Z_CAMERA);
967
 
    sTransform.scale (oScale, oScale, oScale);
968
 
    glNormal3f (0.0, 0.0, -oScale);
969
 
    sTransform.translate (-cam[GLVector::x], -cam[GLVector::y],
970
 
                          -cam[GLVector::z] - DEFAULT_Z_CAMERA);
971
 
 
972
 
    if (reflection)
973
 
    {
974
 
        float scaleFactor = optionGetScaleFactor ();
975
 
 
976
 
        sTransform.translate (0.0,
977
 
                              (vpSize.y () + ((vpSize.y () - 1) * gapY * 2)) *
978
 
                              -sy * aspectY,
979
 
                              0.0);
980
 
        sTransform.scale (1.0, -1.0, 1.0);
981
 
        sTransform.translate (0.0,
982
 
                              - (1 - scaleFactor) / 2 * sy * aspectY *
983
 
                              (vpSize.y () + ((vpSize.y () - 1) * gapY * 2)),
984
 
                              0.0);
985
 
        sTransform.scale (1.0, scaleFactor, 1.0);
986
 
        glCullFace (GL_FRONT);
987
 
    }
988
 
 
989
 
    /* rotate */
990
 
    sTransform.rotate (rotation, 0.0f, 1.0f, 0.0f);
991
 
    sTransform.scale (aspectX, aspectY, 1.0);
992
 
 
993
 
    float xoffset = 0.0;
994
 
    float yoffset = 0.0;
995
 
    float xadjs = 1.0f;
996
 
    float yadjs = 1.0f;
997
 
 
998
 
    if (output->left () == 0)
999
 
    {
1000
 
        xoffset = ((vpSize.x () * sx) / ((float) output->width ()) * (optionGetXOffset ()) * sigmoidProgress (expoCam));
1001
 
        xadjs = 1.0f - ((float) (optionGetXOffset ()) / (float) (output->width ())) * sigmoidProgress (expoCam);
1002
 
    }
1003
 
 
1004
 
    if (output->top () == 0)
1005
 
    {
1006
 
        yoffset = ((vpSize.y () * sy) / ((float) output->height ()) * (optionGetYOffset ()) * sigmoidProgress (expoCam));
1007
 
 
1008
 
        yadjs = 1.0f - ((float) (optionGetYOffset ()) / (float) output->height ()) * sigmoidProgress (expoCam);
1009
 
    }
1010
 
 
1011
 
    /* translate expo to center */
1012
 
    sTransform.translate (vpSize.x () * sx * -0.5 + xoffset,
1013
 
                          vpSize.y () * sy * 0.5 - yoffset, 0.0f);
1014
 
    sTransform.scale (xadjs, yadjs, 1.0f);
1015
 
 
1016
 
    if (optionGetDeform () == DeformCurve)
1017
 
        sTransform.translate ((vpSize.x () - 1) * sx * 0.5, 0.0, 0.0);
1018
 
 
1019
 
    sTransformW = sTransform;
1020
 
 
1021
 
    /* revert prepareXCoords region shift. Now all screens display the same */
1022
 
    sTransform.translate (0.5f, -0.5f, DEFAULT_Z_CAMERA);
1023
 
 
1024
 
    if (vpSize.x () > 2)
1025
 
        /* we can't have 90 degree for the left/right most viewport */
1026
 
        curveAngle = interpolate (359 / ((vpSize.x () - 1) * 2), 1,
1027
 
                                  optionGetCurve ());
1028
 
    else
1029
 
        curveAngle = interpolate (180 / vpSize.x (), 1, optionGetCurve ());
1030
 
 
1031
 
    curveDistance = ((0.5f * sx) + (gapX / 2.0)) /
1032
 
                    tanf (DEG2RAD * curveAngle / 2.0);
1033
 
    curveRadius   = ((0.5f * sx) + (gapX / 2.0)) /
1034
 
                    sinf (DEG2RAD * curveAngle / 2.0);
1035
 
 
1036
 
    expoActive = true;
1037
 
 
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);
1041
 
 
1042
 
    paintingDndWindow = true;
1043
 
 
1044
 
    foreach (CompWindow *dndWindow, dndWindows)
1045
 
    {
1046
 
        CompPoint vp;
1047
 
 
1048
 
        screen->viewportForGeometry (dndWindow->geometry (), vp);
1049
 
 
1050
 
        while (vp.x () < 0)
1051
 
            vp.setX (screen->vpSize ().width () + vp.x ());
1052
 
 
1053
 
        while (vp.y () < 0)
1054
 
            vp.setY (screen->vpSize ().height () + vp.y ());
1055
 
 
1056
 
        paintViewport (attrib, sTransform, infiniteRegion, output, mask, vp, vpCamPos, reflection);
1057
 
    }
1058
 
 
1059
 
    paintingDndWindow = false;
1060
 
 
1061
 
    glNormal3f (0.0, 0.0, -1.0);
1062
 
 
1063
 
    if (reflection)
1064
 
    {
1065
 
        glEnable (GL_BLEND);
1066
 
        glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1067
 
 
1068
 
        glPushMatrix ();
1069
 
 
1070
 
        if (optionGetDeform () != DeformCurve)
1071
 
        {
1072
 
            glLoadMatrixf (sTransformW.getMatrix ());
1073
 
 
1074
 
            glBegin (GL_QUADS);
1075
 
            glColor4f (0.0, 0.0, 0.0, 1.0);
1076
 
            glVertex2f (0.0, 0.0);
1077
 
            glColor4f (0.0, 0.0, 0.0, 0.5);
1078
 
            glVertex2f (0.0, -vpSize.y () * (sy + gapY));
1079
 
            glVertex2f (vpSize.x () * sx * (1.0 + gapX),
1080
 
                        -vpSize.y () * sy * (1.0 + gapY));
1081
 
            glColor4f (0.0, 0.0, 0.0, 1.0);
1082
 
            glVertex2f (vpSize.x () * sx * (1.0 + gapX), 0.0);
1083
 
            glEnd ();
1084
 
        }
1085
 
        else
1086
 
        {
1087
 
            glCullFace (GL_BACK);
1088
 
            glLoadIdentity ();
1089
 
            glTranslatef (0.0, 0.0, -DEFAULT_Z_CAMERA);
1090
 
 
1091
 
            glBegin (GL_QUADS);
1092
 
            glColor4f (0.0, 0.0, 0.0, 1.0 * expoCam);
1093
 
            glVertex2f (-0.5, -0.5);
1094
 
            glVertex2f (0.5, -0.5);
1095
 
            glColor4f (0.0, 0.0, 0.0, 0.5 * expoCam);
1096
 
            glVertex2f (0.5, 0.0);
1097
 
            glVertex2f (-0.5, 0.0);
1098
 
            glColor4f (0.0, 0.0, 0.0, 0.5 * expoCam);
1099
 
            glVertex2f (-0.5, 0.0);
1100
 
            glVertex2f (0.5, 0.0);
1101
 
            glColor4f (0.0, 0.0, 0.0, 0.0);
1102
 
            glVertex2f (0.5, 0.5);
1103
 
            glVertex2f (-0.5, 0.5);
1104
 
            glEnd ();
1105
 
        }
1106
 
        glCullFace (GL_BACK);
1107
 
 
1108
 
        glLoadIdentity ();
1109
 
        glTranslatef (0.0, 0.0, -DEFAULT_Z_CAMERA);
1110
 
 
1111
 
        if (optionGetGroundSize () > 0.0)
1112
 
        {
1113
 
            glBegin (GL_QUADS);
1114
 
            glColor4usv (optionGetGroundColor1 ());
1115
 
            glVertex2f (-0.5, -0.5);
1116
 
            glVertex2f (0.5, -0.5);
1117
 
            glColor4usv (optionGetGroundColor2 ());
1118
 
            glVertex2f (0.5, -0.5 + optionGetGroundSize ());
1119
 
            glVertex2f (-0.5, -0.5 + optionGetGroundSize ());
1120
 
            glEnd ();
1121
 
        }
1122
 
 
1123
 
        glColor4usv (defaultColor);
1124
 
 
1125
 
        glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
1126
 
        glDisable (GL_BLEND);
1127
 
        glPopMatrix ();
1128
 
    }
1129
 
 
1130
 
    expoActive = false;
1131
 
 
1132
 
    cScreen->setWindowPaintOffset (0, 0);
1133
 
 
1134
 
    gScreen->glPaintTransformedOutputSetCurrentIndex (glPaintTransformedOutputIndex);
1135
 
    gScreen->setTextureFilter (oldFilter);
1136
 
}
1137
 
 
1138
 
const CompWindowList &
1139
 
ExpoScreen::getWindowPaintList ()
1140
 
{
1141
 
    return dndWindows;
1142
 
}
1143
 
 
1144
 
bool
1145
 
ExpoScreen::glPaintOutput (const GLScreenPaintAttrib& attrib,
1146
 
                           const GLMatrix&            transform,
1147
 
                           const CompRegion&          region,
1148
 
                           CompOutput                 *output,
1149
 
                           unsigned int               mask)
1150
 
{
1151
 
    if (expoCam > 0.0)
1152
 
        mask |= PAINT_SCREEN_TRANSFORMED_MASK | PAINT_SCREEN_CLEAR_MASK;
1153
 
 
1154
 
    return gScreen->glPaintOutput (attrib, transform, region, output, mask);
1155
 
}
1156
 
 
1157
 
void
1158
 
ExpoScreen::glPaintTransformedOutput (const GLScreenPaintAttrib& attrib,
1159
 
                                      const GLMatrix&            transform,
1160
 
                                      const CompRegion&          region,
1161
 
                                      CompOutput                 *output,
1162
 
                                      unsigned int               mask)
1163
 
{
1164
 
    expoActive = false;
1165
 
 
1166
 
    if (expoCam > 0)
1167
 
        mask |= PAINT_SCREEN_CLEAR_MASK;
1168
 
 
1169
 
    if (expoCam <= 0 || (expoCam > 0.0 && expoCam < 1.0 &&
1170
 
                         optionGetExpoAnimation () != ExpoAnimationZoom))
1171
 
    {
1172
 
        gScreen->glPaintTransformedOutput (attrib, transform, region,
1173
 
                                           output, mask);
1174
 
    }
1175
 
    else
1176
 
    {
1177
 
        gScreen->clearOutput (output, GL_COLOR_BUFFER_BIT);
1178
 
    }
1179
 
 
1180
 
    mask &= ~PAINT_SCREEN_CLEAR_MASK;
1181
 
 
1182
 
    if (expoCam > 0.0)
1183
 
    {
1184
 
        if (optionGetReflection ())
1185
 
            paintWall (attrib, transform, region, output, mask, true);
1186
 
 
1187
 
        paintWall (attrib, transform, region, output, mask, false);
1188
 
        anyClick = false;
1189
 
    }
1190
 
}
1191
 
 
1192
 
bool
1193
 
ExpoWindow::glDraw (const GLMatrix&     transform,
1194
 
                    GLFragment::Attrib& fragment,
1195
 
                    const CompRegion&   region,
1196
 
                    unsigned int        mask)
1197
 
{
1198
 
    GLMatrix wTransform (transform);
1199
 
    CompPoint vp;
1200
 
 
1201
 
    screen->viewportForGeometry (window->geometry (), vp);
1202
 
 
1203
 
    if (eScreen->expoCam == 0.0f)
1204
 
        return gWindow->glDraw (transform, fragment, region, mask);
1205
 
 
1206
 
    GLFragment::Attrib fA (fragment);
1207
 
    int                expoAnimation;
1208
 
 
1209
 
    expoAnimation = eScreen->optionGetExpoAnimation ();
1210
 
 
1211
 
    if (eScreen->expoActive)
1212
 
    {
1213
 
        if (expoAnimation != ExpoScreen::ExpoAnimationZoom)
1214
 
            fA.setOpacity (fragment.getOpacity () * eScreen->expoCam);
1215
 
 
1216
 
        if (window->wmType () & CompWindowTypeDockMask &&
1217
 
            eScreen->optionGetHideDocks ())
1218
 
        {
1219
 
            if (expoAnimation == ExpoScreen::ExpoAnimationZoom &&
1220
 
                eScreen->paintingVp == eScreen->selectedVp)
1221
 
            {
1222
 
                fA.setOpacity (fragment.getOpacity () *
1223
 
                               (1 - sigmoidProgress (eScreen->expoCam)));
1224
 
            }
1225
 
            else
1226
 
            {
1227
 
                fA.setOpacity (0);
1228
 
            }
1229
 
        }
1230
 
 
1231
 
        if (vp == eScreen->paintingVp || window->onAllViewports ())
1232
 
        {
1233
 
            fA.setBrightness (fragment.getBrightness () * eScreen->vpBrightness);
1234
 
            fA.setSaturation (fragment.getSaturation () * eScreen->vpSaturation);
1235
 
        }
1236
 
    }
1237
 
    else
1238
 
    {
1239
 
        if (expoAnimation == ExpoScreen::ExpoAnimationZoom)
1240
 
            fA.setBrightness (0);
1241
 
        else
1242
 
            fA.setBrightness (fragment.getBrightness () *
1243
 
                              (1 - sigmoidProgress (eScreen->expoCam)));
1244
 
    }
1245
 
 
1246
 
    bool status = gWindow->glDraw (wTransform, fA, region, mask);
1247
 
 
1248
 
    if (window->type () & CompWindowTypeDesktopMask)
1249
 
    {
1250
 
        /* We want to set the geometry of the polka dots to the window
1251
 
         * region */
1252
 
        CompRegion reg = CompRegion (0, 0, window->width (), window->height ());
1253
 
 
1254
 
        foreach(GLTexture * tex, eScreen->polkadots_texture)
1255
 
        {
1256
 
            GLTexture::MatrixList matl;
1257
 
            GLTexture::Matrix     mat = tex->matrix();
1258
 
            CompRegion            paintRegion(region);
1259
 
 
1260
 
            /* We can reset the window geometry since it will be
1261
 
             * re-added later */
1262
 
            gWindow->geometry().reset();
1263
 
 
1264
 
            float xScale = screen->width () / (float) eScreen->viewport_size.width ();
1265
 
            float yScale = screen->height () / (float) eScreen->viewport_size.height ();
1266
 
 
1267
 
            mat.xx *= xScale;
1268
 
            mat.yy *= yScale;
1269
 
 
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();
1274
 
 
1275
 
            matl.push_back(mat);
1276
 
 
1277
 
            if (mask & PAINT_WINDOW_TRANSFORMED_MASK)
1278
 
                paintRegion = infiniteRegion;
1279
 
 
1280
 
            /* Now allow plugins to mess with the geometry of our
1281
 
             * dim (so we get a nice render for things like
1282
 
             * wobbly etc etc */
1283
 
            gWindow->glAddGeometry(matl, reg, paintRegion);
1284
 
 
1285
 
            /* Did it succeed? */
1286
 
            if (gWindow->geometry().vertices)
1287
 
            {
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
1294
 
                 * geometry glory */
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);
1303
 
            }
1304
 
        }
1305
 
 
1306
 
        /* Paint the outline */
1307
 
        if (mGlowQuads && eScreen->paintingVp == eScreen->selectedVp)
1308
 
        {
1309
 
            if (region.numRects ())
1310
 
            {
1311
 
                /* reset geometry and paint */
1312
 
                gWindow->geometry ().reset ();
1313
 
 
1314
 
                paintGlow (fragment, infiniteRegion, mask);
1315
 
            }
1316
 
        }
1317
 
 
1318
 
  }
1319
 
 
1320
 
  return status;
1321
 
 
1322
 
}
1323
 
 
1324
 
#define EXPO_GRID_SIZE 100
1325
 
 
1326
 
void
1327
 
ExpoWindow::glAddGeometry (const GLTexture::MatrixList& matrices,
1328
 
                           const CompRegion&            region,
1329
 
                           const CompRegion&            clip,
1330
 
                           unsigned int                 maxGridWidth,
1331
 
                           unsigned int                 maxGridHeight)
1332
 
{
1333
 
    if (eScreen->expoCam > 0.0        &&
1334
 
        screen->desktopWindowCount () &&
1335
 
        eScreen->optionGetDeform () == ExpoScreen::DeformCurve)
1336
 
    {
1337
 
        int         i, oldVCount = gWindow->geometry ().vCount;
1338
 
        GLfloat     *v;
1339
 
        CompPoint   offset;
1340
 
        float       lastX, lastZ = 0.0;
1341
 
        const float radSquare = pow (eScreen->curveDistance, 2) + 0.25;
1342
 
        float       ang;
1343
 
 
1344
 
        gWindow->glAddGeometry (matrices, region, clip,
1345
 
                                MIN(maxGridWidth , EXPO_GRID_SIZE),
1346
 
                                maxGridHeight);
1347
 
 
1348
 
        v  = gWindow->geometry ().vertices;
1349
 
        v += gWindow->geometry ().vertexStride - 3;
1350
 
        v += gWindow->geometry ().vertexStride * oldVCount;
1351
 
 
1352
 
        if (!window->onAllViewports ())
1353
 
        {
1354
 
            offset = eScreen->cScreen->windowPaintOffset ();
1355
 
            offset = window->getMovementForOffset (offset);
1356
 
        }
1357
 
 
1358
 
        lastX = -1000000000.0;
1359
 
 
1360
 
        for (i = oldVCount; i < gWindow->geometry ().vCount; i++)
1361
 
        {
1362
 
            if (v[0] == lastX)
1363
 
            {
1364
 
                v[2] = lastZ;
1365
 
            }
1366
 
            else if (v[0] + offset.x () >= -EXPO_GRID_SIZE &&
1367
 
                     v[0] + offset.x () < screen->width () + EXPO_GRID_SIZE)
1368
 
            {
1369
 
                ang = (((v[0] + offset.x ()) / (float) screen->width ()) - 0.5);
1370
 
                ang *= ang;
1371
 
                if (ang < radSquare)
1372
 
                {
1373
 
                    v[2] = eScreen->curveDistance - sqrt (radSquare - ang);
1374
 
                    v[2] *= sigmoidProgress (eScreen->expoCam);
1375
 
                }
1376
 
            }
1377
 
 
1378
 
            lastX = v[0];
1379
 
            lastZ = v[2];
1380
 
 
1381
 
            v += gWindow->geometry ().vertexStride;
1382
 
        }
1383
 
    }
1384
 
    else
1385
 
    {
1386
 
        gWindow->glAddGeometry (matrices, region, clip, maxGridWidth, maxGridHeight);
1387
 
    }
1388
 
}
1389
 
 
1390
 
void
1391
 
ExpoWindow::glDrawTexture (GLTexture           *texture,
1392
 
                           GLFragment::Attrib& attrib,
1393
 
                           unsigned int        mask)
1394
 
{
1395
 
    if (eScreen->expoCam > 0.0                                 &&
1396
 
        eScreen->optionGetDeform () == ExpoScreen::DeformCurve &&
1397
 
        eScreen->gScreen->lighting ()                          &&
1398
 
        screen->desktopWindowCount ())
1399
 
    {
1400
 
        unsigned int i, idx, vCount;
1401
 
        CompPoint    offset;
1402
 
        float        x;
1403
 
        GLfloat      *v;
1404
 
 
1405
 
        vCount = gWindow->geometry ().vCount;
1406
 
 
1407
 
        if (eScreen->winNormals.size () < vCount * 3)
1408
 
            eScreen->winNormals.resize (vCount * 3);
1409
 
 
1410
 
        if (!window->onAllViewports ())
1411
 
        {
1412
 
            offset = eScreen->cScreen->windowPaintOffset ();
1413
 
            offset = window->getMovementForOffset (offset);
1414
 
        }
1415
 
 
1416
 
        v = gWindow->geometry ().vertices +
1417
 
            (gWindow->geometry ().vertexStride - 3);
1418
 
 
1419
 
        for (i = 0; i < vCount; i++)
1420
 
        {
1421
 
            x = (float) (v[0] + offset.x () - screen->width () / 2) *
1422
 
                        eScreen->curveAngle / screen->width ();
1423
 
 
1424
 
            while (x < 0)
1425
 
                x += 360.0;
1426
 
 
1427
 
            idx = floor (x);
1428
 
 
1429
 
            eScreen->winNormals[i * 3] = -eScreen->vpNormals[idx * 3];
1430
 
            eScreen->winNormals[(i * 3) + 1] =
1431
 
                eScreen->vpNormals[(idx * 3) + 1];
1432
 
            eScreen->winNormals[(i * 3) + 2] =
1433
 
                eScreen->vpNormals[(idx * 3) + 2];
1434
 
 
1435
 
            v += gWindow->geometry ().vertexStride;
1436
 
        }
1437
 
 
1438
 
        glEnable (GL_NORMALIZE);
1439
 
        glNormalPointer (GL_FLOAT,0, &eScreen->winNormals.at (0));
1440
 
 
1441
 
        glEnableClientState (GL_NORMAL_ARRAY);
1442
 
 
1443
 
        gWindow->glDrawTexture (texture, attrib, mask);
1444
 
 
1445
 
        glDisable (GL_NORMALIZE);
1446
 
        glDisableClientState (GL_NORMAL_ARRAY);
1447
 
        glNormal3f (0.0, 0.0, -1.0);
1448
 
    }
1449
 
    else
1450
 
    {
1451
 
        glEnable (GL_NORMALIZE);
1452
 
        gWindow->glDrawTexture (texture, attrib, mask);
1453
 
        glDisable (GL_NORMALIZE);
1454
 
    }
1455
 
}
1456
 
 
1457
 
bool
1458
 
ExpoWindow::glPaint (const GLWindowPaintAttrib& attrib,
1459
 
                     const GLMatrix&            transform,
1460
 
                     const CompRegion&          region,
1461
 
                     unsigned int               mask)
1462
 
{
1463
 
    GLMatrix            wTransform (transform);
1464
 
    GLWindowPaintAttrib wAttrib (attrib);
1465
 
    CompPoint           vp;
1466
 
 
1467
 
    screen->viewportForGeometry (window->geometry (), vp);
1468
 
 
1469
 
    if (eScreen->expoActive)
1470
 
    {
1471
 
        float opacity = 1.0;
1472
 
        bool  hide;
1473
 
        bool  zoomAnim;
1474
 
 
1475
 
        zoomAnim = eScreen->optionGetExpoAnimation () ==
1476
 
                   ExpoScreen::ExpoAnimationZoom;
1477
 
        hide     = eScreen->optionGetHideDocks () &&
1478
 
                   (window->wmType () & CompWindowTypeDockMask);
1479
 
 
1480
 
        if (eScreen->expoCam > 0.0)
1481
 
        {
1482
 
            if (eScreen->expoCam < 1.0 && !zoomAnim)
1483
 
                mask |= PAINT_WINDOW_TRANSLUCENT_MASK;
1484
 
            else if (hide)
1485
 
                mask |= PAINT_WINDOW_TRANSLUCENT_MASK;
1486
 
        }
1487
 
 
1488
 
        if (!zoomAnim)
1489
 
            opacity = attrib.opacity * eScreen->expoCam;
1490
 
 
1491
 
        if (hide)
1492
 
        {
1493
 
            if (zoomAnim && eScreen->paintingVp == eScreen->selectedVp)
1494
 
                opacity = attrib.opacity *
1495
 
                          (1 - sigmoidProgress (eScreen->expoCam));
1496
 
            else
1497
 
                opacity = 0;
1498
 
        }
1499
 
 
1500
 
        if (opacity <= 0)
1501
 
            mask |= PAINT_WINDOW_NO_CORE_INSTANCE_MASK;
1502
 
        else
1503
 
            wAttrib.opacity = wAttrib.opacity * opacity;
1504
 
    }
1505
 
 
1506
 
    /* Stretch maximized windows a little so that you don't
1507
 
     * have an awkward gap */
1508
 
    if (window->state () & MAXIMIZE_STATE)
1509
 
    {
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 (),
1514
 
                              0.0f);
1515
 
        wTransform.scale (1.0f, yS, 1.0f);
1516
 
        wTransform.translate (-(window->x () + window->width () / 2),
1517
 
                              -(window->y () + window->height ()),
1518
 
                              0.0f);
1519
 
 
1520
 
        if (eScreen->paintingVp != vp)
1521
 
            mask |= PAINT_WINDOW_NO_CORE_INSTANCE_MASK;
1522
 
 
1523
 
        mask |= PAINT_WINDOW_TRANSFORMED_MASK;
1524
 
    }
1525
 
 
1526
 
    if (std::find (eScreen->dndWindows.begin(), eScreen->dndWindows.end (), window) != eScreen->dndWindows.end ())
1527
 
    {
1528
 
        if (!eScreen->paintingDndWindow)
1529
 
        {
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);
1536
 
        }
1537
 
        else
1538
 
        {
1539
 
            mask |= PAINT_WINDOW_TRANSFORMED_MASK;
1540
 
            if (!window->region ().subtracted (screen->region ()).isEmpty ())
1541
 
                wAttrib.opacity = wAttrib.opacity * dndOpacity;
1542
 
        }
1543
 
    }
1544
 
 
1545
 
    bool status = gWindow->glPaint (wAttrib, wTransform, region, mask);
1546
 
 
1547
 
    return status;
1548
 
}
1549
 
 
1550
 
bool
1551
 
ExpoWindow::damageRect (bool            initial,
1552
 
                        const CompRect& rect)
1553
 
{
1554
 
    if (eScreen->expoCam > 0.0f)
1555
 
        eScreen->cScreen->damageScreen ();
1556
 
 
1557
 
    return cWindow->damageRect (initial, rect);
1558
 
}
1559
 
 
1560
 
#define EXPOINITBIND(opt, func)                                \
1561
 
    optionSet##opt##Initiate (boost::bind (&ExpoScreen::func,  \
1562
 
                                           this, _1, _2, _3));
1563
 
#define EXPOTERMBIND(opt, func)                                \
1564
 
    optionSet##opt##Terminate (boost::bind (&ExpoScreen::func, \
1565
 
                                            this, _1, _2, _3));
1566
 
 
1567
 
ExpoScreen::ExpoScreen (CompScreen *s) :
1568
 
    PluginClassHandler<ExpoScreen, CompScreen> (s),
1569
 
    ExpoOptions (),
1570
 
    cScreen (CompositeScreen::get (s)),
1571
 
    gScreen (GLScreen::get (s)),
1572
 
    expoCam (0.0f),
1573
 
    expoActive (false),
1574
 
    expoMode (false),
1575
 
    dndState (DnDNone),
1576
 
    dndWindows (0),
1577
 
    origVp (s->vp ()),
1578
 
    selectedVp (s->vp ()),
1579
 
    vpUpdateMode (VPUpdateNone),
1580
 
    clickTime (0),
1581
 
    doubleClick (false),
1582
 
    vpNormals (360 * 3),
1583
 
    grabIndex (0),
1584
 
    paintingDndWindow (false),
1585
 
    mGlowTextureProperties (&glowTextureProperties)
1586
 
{
1587
 
    CompString fname;
1588
 
    CompString pname = "expo";
1589
 
    CompSize   size;
1590
 
 
1591
 
 
1592
 
    leftKey  = XKeysymToKeycode (s->dpy (), XStringToKeysym ("Left"));
1593
 
    rightKey = XKeysymToKeycode (s->dpy (), XStringToKeysym ("Right"));
1594
 
    upKey    = XKeysymToKeycode (s->dpy (), XStringToKeysym ("Up"));
1595
 
    downKey  = XKeysymToKeycode (s->dpy (), XStringToKeysym ("Down"));
1596
 
 
1597
 
    mMoveCursor = XCreateFontCursor (screen->dpy (), XC_fleur);
1598
 
 
1599
 
    EXPOINITBIND (ExpoKey, doExpo);
1600
 
    EXPOTERMBIND (ExpoKey, termExpo);
1601
 
    EXPOINITBIND (ExpoButton, doExpo);
1602
 
    EXPOTERMBIND (ExpoButton, termExpo);
1603
 
    EXPOINITBIND (ExpoEdge, doExpo);
1604
 
    EXPOTERMBIND (ExpoButton, termExpo);
1605
 
 
1606
 
    EXPOINITBIND (DndButton, dndInit);
1607
 
    EXPOTERMBIND (DndButton, dndFini);
1608
 
    EXPOINITBIND (ExitButton, exitExpo);
1609
 
    EXPOINITBIND (NextVpButton, nextVp);
1610
 
    EXPOINITBIND (PrevVpButton, prevVp);
1611
 
 
1612
 
    ScreenInterface::setHandler (screen, false);
1613
 
    CompositeScreenInterface::setHandler (cScreen, false);
1614
 
    GLScreenInterface::setHandler (gScreen, false);
1615
 
 
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);
1622
 
 
1623
 
    if (polkadots_texture.empty ())
1624
 
        compLogMessage ("expo", CompLogLevelWarn, "failed to bind image to texture");
1625
 
    else
1626
 
    {
1627
 
        foreach (GLTexture *tex, polkadots_texture)
1628
 
        {
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);
1632
 
            tex->disable ();
1633
 
        }
1634
 
    }
1635
 
}
1636
 
 
1637
 
ExpoScreen::~ExpoScreen ()
1638
 
{
1639
 
    if (mMoveCursor)
1640
 
        XFreeCursor (screen->dpy (), mMoveCursor);
1641
 
}
1642
 
 
1643
 
void
1644
 
ExpoWindow::resizeNotify(int dx, int dy, int dw, int dh)
1645
 
{
1646
 
    window->resizeNotify (dx, dy, dw, dh);
1647
 
 
1648
 
    /* mGlowQuads contains positional info, so we need to recalc that */
1649
 
    if (mGlowQuads)
1650
 
    {
1651
 
        /* FIXME: we need to find a more multitexture friendly way
1652
 
         * of doing this */
1653
 
        GLTexture::Matrix tMat = eScreen->outline_texture.at (0)->matrix ();
1654
 
        computeGlowQuads (&tMat);
1655
 
    }
1656
 
}
1657
 
 
1658
 
ExpoWindow::ExpoWindow (CompWindow *w) :
1659
 
    PluginClassHandler<ExpoWindow, CompWindow> (w),
1660
 
    window (w),
1661
 
    cWindow (CompositeWindow::get (w)),
1662
 
    gWindow (GLWindow::get (w)),
1663
 
    eScreen (ExpoScreen::get (screen)),
1664
 
    dndOpacity (0.0f),
1665
 
    mGlowQuads (NULL)
1666
 
{
1667
 
    CompositeWindowInterface::setHandler (cWindow, false);
1668
 
    GLWindowInterface::setHandler (gWindow, false);
1669
 
    WindowInterface::setHandler (window, true);
1670
 
 
1671
 
    if (window->type () & CompWindowTypeDesktopMask)
1672
 
    {
1673
 
        foreach (GLTexture *tex, eScreen->outline_texture)
1674
 
        {
1675
 
            GLTexture::Matrix mat = tex->matrix ();
1676
 
            computeGlowQuads (&mat);
1677
 
        }
1678
 
    }
1679
 
}
1680
 
 
1681
 
ExpoWindow::~ExpoWindow ()
1682
 
{
1683
 
    eScreen->dndWindows.remove (window);
1684
 
    computeGlowQuads (NULL);
1685
 
}
1686
 
 
1687
 
bool
1688
 
ExpoPluginVTable::init ()
1689
 
{
1690
 
    if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION) ||
1691
 
        !CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI) ||
1692
 
        !CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI))
1693
 
        return false;
1694
 
 
1695
 
    return true;
1696
 
}
1697
 
 
1698