~ubuntu-branches/ubuntu/trusty/compiz/trusty

« back to all changes in this revision

Viewing changes to plugins/thumbnail/src/thumbnail.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2013-08-22 06:58:07 UTC
  • mto: This revision was merged to the branch mainline in revision 3352.
  • Revision ID: package-import@ubuntu.com-20130822065807-17nlzez0d30y09so
Tags: upstream-0.9.10+13.10.20130822
ImportĀ upstreamĀ versionĀ 0.9.10+13.10.20130822

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
COMPIZ_PLUGIN_20090315 (thumbnail, ThumbPluginVTable);
34
34
 
35
35
void
36
 
ThumbScreen::freeThumbText (Thumbnail  *t)
 
36
ThumbScreen::freeThumbText (Thumbnail *t)
37
37
{
38
38
    if (!t->text)
39
39
        return;
43
43
}
44
44
 
45
45
void
46
 
ThumbScreen::renderThumbText (Thumbnail  *t,
47
 
                              bool       freeThumb)
 
46
ThumbScreen::renderThumbText (Thumbnail *t,
 
47
                              bool      freeThumb)
48
48
{
49
49
    if (!textPluginLoaded)
50
50
        return;
51
51
 
52
 
    CompText::Attrib tA;
53
 
 
54
52
    if (freeThumb || !t->text)
55
53
    {
56
54
        freeThumbText (t);
57
55
        t->text = new CompText ();
58
56
    }
59
57
 
 
58
    CompText::Attrib tA;
 
59
 
60
60
    tA.maxWidth   = t->width;
61
61
    tA.maxHeight  = 100;
62
62
 
74
74
    tA.color[2]   = optionGetFontColorBlue ();
75
75
    tA.color[3]   = optionGetFontColorAlpha ();
76
76
    tA.flags      = CompText::WithBackground | CompText::Ellipsized;
 
77
 
77
78
    if (optionGetFontBold ())
78
79
        tA.flags |= CompText::StyleBold;
 
80
 
79
81
    tA.family     = "Sans";
80
82
 
81
83
    t->textValid = t->text->renderWindowTitle (t->win->id (), false, tA);
84
86
void
85
87
ThumbScreen::damageThumbRegion (Thumbnail  *t)
86
88
{
87
 
    int x = t->x - t->offset;
88
 
    int y = t->y - t->offset;
89
 
    int width = t->width + (t->offset * 2);
90
 
    int height = t->height + (t->offset * 2);
91
 
    CompRect   rect (x, y, width, height);
 
89
    int x      = t->x      - t->offset;
 
90
    int y      = t->y      - t->offset;
 
91
    int width  = t->width  + t->offset * 2;
 
92
    int height = t->height + t->offset * 2;
 
93
 
 
94
    CompRect rect (x, y, width, height);
92
95
 
93
96
    if (t->text)
94
97
        rect.setHeight (rect.height () + t->text->getHeight () + optionGetTextDistance ());
105
108
void
106
109
ThumbScreen::thumbUpdateThumbnail ()
107
110
{
108
 
    int        igMidPoint[2], tMidPoint[2];
109
 
    int        tPos[2], tmpPos[2];
110
 
    float      distance = 1000000;
111
 
    int        off, oDev, tHeight;
112
 
    CompRect   oGeom;
113
 
    float      maxSize = optionGetThumbSize ();
114
 
    double     scale  = 1.0;
115
 
    ThumbWindow *tw;
116
 
    CompWindow *w;
117
 
 
118
 
    if (thumb.win == pointedWin)
119
 
        return;
120
 
 
121
 
    if (thumb.opacity > 0.0 && oldThumb.opacity > 0.0)
 
111
    if (thumb.win == pointedWin ||
 
112
        (thumb.opacity && oldThumb.opacity))
122
113
        return;
123
114
 
124
115
    if (thumb.win)
126
117
 
127
118
    freeThumbText (&oldThumb);
128
119
 
 
120
    ThumbWindow *tw;
 
121
 
129
122
    if (oldThumb.win)
130
123
    {
131
124
        tw = ThumbWindow::get (oldThumb.win);
136
129
        tw->window->resizeNotifySetEnabled (tw, false);
137
130
    }
138
131
 
139
 
    oldThumb       = thumb;
140
 
    thumb.text     = NULL;
141
 
    thumb.win      = pointedWin;
142
 
    thumb.dock     = dock;
 
132
    oldThumb   = thumb;
 
133
    thumb.text = NULL;
 
134
    thumb.win  = pointedWin;
 
135
    thumb.dock = dock;
143
136
 
144
137
    if (!thumb.win || !dock)
145
138
    {
146
139
        thumb.win  = NULL;
147
 
        thumb.dock = NULL;
 
140
        thumb.dock = NULL;
148
141
        return;
149
142
    }
150
143
 
151
 
    w = thumb.win;
 
144
    CompWindow *w = thumb.win;
152
145
    tw = ThumbWindow::get (w);
153
146
 
154
147
    tw->cWindow->damageRectSetEnabled (tw, true);
155
148
    tw->gWindow->glPaintSetEnabled (tw, true);
156
149
    tw->window->resizeNotifySetEnabled (tw, true);
157
150
 
158
 
    /* do we nee to scale the window down? */
159
 
    if (WIN_W (w) > maxSize || WIN_H (w) > maxSize)
 
151
    float  maxSize = optionGetThumbSize ();
 
152
    double scale   = 1.0;
 
153
 
 
154
    int winWidth  = w->width ()  + w->border ().left + w->border ().right;
 
155
    int winHeight = w->height () + w->border ().top  + w->border ().bottom;
 
156
 
 
157
    /* do we need to scale the window down? */
 
158
    if (winWidth > maxSize || winHeight > maxSize)
160
159
    {
161
 
        if (WIN_W (w) >= WIN_H (w))
162
 
            scale = maxSize / WIN_W (w);
 
160
        if (winWidth >= winHeight)
 
161
            scale = maxSize / winWidth;
163
162
        else
164
 
            scale = maxSize / WIN_H (w);
 
163
            scale = maxSize / winHeight;
165
164
    }
166
165
 
167
 
    thumb.width  = WIN_W (w)* scale;
168
 
    thumb.height = WIN_H (w) * scale;
 
166
    thumb.width  = winWidth  * scale;
 
167
    thumb.height = winHeight * scale;
169
168
    thumb.scale  = scale;
170
169
 
171
170
    if (optionGetTitleEnabled ())
173
172
    else
174
173
        freeThumbText (&thumb);
175
174
 
176
 
    igMidPoint[0] = w->iconGeometry ().x () + (w->iconGeometry ().width () / 2);
177
 
    igMidPoint[1] = w->iconGeometry ().y () + (w->iconGeometry ().height () / 2);
178
 
 
179
 
    off = optionGetBorder ();
180
 
    oDev = screen->outputDeviceForPoint (w->iconGeometry ().x () +
181
 
                                 (w->iconGeometry ().width () / 2),
182
 
                                 w->iconGeometry ().y () +
183
 
                                 (w->iconGeometry ().height () / 2));
 
175
    int igMidPoint[2], tMidPoint[2];
 
176
 
 
177
    igMidPoint[0] = w->iconGeometry ().centerX ();
 
178
    igMidPoint[1] = w->iconGeometry ().centerY ();
 
179
 
 
180
    int off  = optionGetBorder ();
 
181
    int oDev = screen->outputDeviceForPoint (igMidPoint[0],
 
182
                                             igMidPoint[1]);
 
183
 
 
184
    CompRect oGeom;
184
185
 
185
186
    if (screen->outputDevs ().size () == 1 ||
186
 
        (unsigned int) oDev > screen->outputDevs ().size ())
187
 
    {
 
187
        (unsigned int) oDev > screen->outputDevs ().size ())
188
188
        oGeom.setGeometry (0, 0, screen->width (), screen->height ());
189
 
    }
190
189
    else
191
 
    {
192
190
        oGeom = screen->outputDevs ()[oDev];
193
 
    }
194
 
 
195
 
    tHeight = thumb.height;
 
191
 
 
192
    int tHeight = thumb.height;
 
193
    int tWidth  = thumb.width;
 
194
 
196
195
    if (thumb.text)
197
196
        tHeight += thumb.text->getHeight () + optionGetTextDistance ();
198
197
 
199
 
    /* Could someone please explain how this works */
 
198
    int halfTWidth  = tWidth  / 2;
 
199
    int halfTHeight = tHeight / 2;
 
200
    int tPos[2], tmpPos[2];
200
201
 
201
202
    // failsave position
202
 
    tPos[0] = igMidPoint[0] - (thumb.width / 2.0);
 
203
    tPos[0] = igMidPoint[0] - halfTWidth;
203
204
 
204
205
    if (w->iconGeometry ().y () - tHeight >= 0)
205
206
        tPos[1] = w->iconGeometry ().y () - tHeight;
207
208
        tPos[1] = w->iconGeometry ().y () + w->iconGeometry ().height ();
208
209
 
209
210
    // above
210
 
    tmpPos[0] = igMidPoint[0] - (thumb.width / 2.0);
 
211
    tmpPos[0] = igMidPoint[0] - halfTWidth;
211
212
 
212
213
    if (tmpPos[0] - off < oGeom.x1 ())
213
214
        tmpPos[0] = oGeom.x1 () + off;
214
215
 
215
 
    if (tmpPos[0] + off + thumb.width > oGeom.x2 ())
 
216
    if (tmpPos[0] + off + tWidth > oGeom.x2 ())
216
217
    {
217
 
        if (thumb.width + (2 * off) <= oGeom.width ())
218
 
            tmpPos[0] = oGeom.x2 () - thumb.width - off;
 
218
        if (tWidth + (2 * off) <= oGeom.width ())
 
219
            tmpPos[0] = oGeom.x2 () - tWidth - off;
219
220
        else
220
221
            tmpPos[0] = oGeom.x1 () + off;
221
222
    }
222
223
 
223
 
    tMidPoint[0] = tmpPos[0] + (thumb.width / 2.0);
224
 
 
225
 
    tmpPos[1] = WIN_Y (dock) - tHeight - off;
226
 
    tMidPoint[1] = tmpPos[1] + (tHeight / 2.0);
 
224
    tMidPoint[0] = tmpPos[0] + halfTWidth;
 
225
 
 
226
    int dockX      = dock->x () - dock->border ().left;
 
227
    int dockY      = dock->y () - dock->border ().top;
 
228
    int dockWidth  = dock->width ()  + dock->border ().left + dock->border ().right;
 
229
    int dockHeight = dock->height () + dock->border ().top  + dock->border ().bottom;
 
230
 
 
231
    tmpPos[1]    = dockY - tHeight - off;
 
232
    tMidPoint[1] = tmpPos[1] + halfTHeight;
 
233
 
 
234
    float distance = 1000000;
227
235
 
228
236
    if (tmpPos[1] > oGeom.y1 ())
229
237
    {
233
241
    }
234
242
 
235
243
    // below
236
 
    tmpPos[1] = WIN_Y (dock) + WIN_H (dock) + off;
 
244
    tmpPos[1] = dockY + dockHeight + off;
237
245
 
238
 
    tMidPoint[1] = tmpPos[1] + (tHeight / 2.0);
 
246
    tMidPoint[1] = tmpPos[1] + halfTHeight;
239
247
 
240
248
    if (tmpPos[1] + tHeight + off < oGeom.y2 () &&
241
249
        GET_DISTANCE (igMidPoint, tMidPoint) < distance)
246
254
    }
247
255
 
248
256
    // left
249
 
    tmpPos[1] = igMidPoint[1] - (tHeight / 2.0);
 
257
    tmpPos[1] = igMidPoint[1] - halfTHeight;
250
258
 
251
259
    if (tmpPos[1] - off < oGeom.y1 ())
252
260
        tmpPos[1] = oGeom.y1 () + off;
254
262
    if (tmpPos[1] + off + tHeight > oGeom.y2 ())
255
263
    {
256
264
        if (tHeight + (2 * off) <= oGeom.height ())
257
 
            tmpPos[1] = oGeom.y2 () - thumb.height - off;
 
265
            tmpPos[1] = oGeom.y2 () - tHeight - off;
258
266
        else
259
267
            tmpPos[1] = oGeom.y1 () + off;
260
268
    }
261
269
 
262
 
    tMidPoint[1] = tmpPos[1] + (tHeight / 2.0);
263
 
 
264
 
    tmpPos[0] = WIN_X (dock) - thumb.width - off;
265
 
    tMidPoint[0] = tmpPos[0] + (thumb.width / 2.0);
 
270
    tMidPoint[1] = tmpPos[1] + halfTHeight;
 
271
    tmpPos[0]    = dockX - tWidth - off;
 
272
    tMidPoint[0] = tmpPos[0] + halfTWidth;
266
273
 
267
274
    if (tmpPos[0] > oGeom.x1 () && GET_DISTANCE (igMidPoint, tMidPoint) < distance)
268
275
    {
272
279
    }
273
280
 
274
281
    // right
275
 
    tmpPos[0] = WIN_X (dock) + WIN_W (dock) + off;
276
 
 
277
 
    tMidPoint[0] = tmpPos[0] + (thumb.width / 2.0);
278
 
 
279
 
    if (tmpPos[0] + thumb.width + off < oGeom.x2 () &&
 
282
    tmpPos[0]    = dockX + dockWidth + off;
 
283
 
 
284
    tMidPoint[0] = tmpPos[0] + halfTWidth;
 
285
 
 
286
    if (tmpPos[0] + tWidth + off < oGeom.x2 () &&
280
287
        GET_DISTANCE (igMidPoint, tMidPoint) < distance)
281
288
    {
282
289
        tPos[0]  = tmpPos[0];
298
305
bool
299
306
ThumbScreen::thumbShowThumbnail ()
300
307
{
301
 
    showingThumb   = true;
 
308
    showingThumb = true;
302
309
 
303
310
    thumbUpdateThumbnail ();
304
311
    damageThumbRegion (&thumb);
310
317
ThumbScreen::checkPosition (CompWindow *w)
311
318
{
312
319
    if (optionGetCurrentViewport ())
313
 
    {
314
 
        if (w->serverX () >= screen->width ()    ||
315
 
            w->serverX () + w->serverWidth () <= 0  ||
316
 
            w->serverY () >= screen->height ()   ||
 
320
        if (w->serverX () >= screen->width ()       ||
 
321
            w->serverX () + w->serverWidth ()  <= 0 ||
 
322
            w->serverY () >= screen->height ()      ||
317
323
            w->serverY () + w->serverHeight () <= 0)
318
 
        {
319
324
            return false;
320
 
        }
321
 
    }
322
325
 
323
326
    return true;
324
327
}
332
335
    {
333
336
        THUMB_WINDOW (cw);
334
337
 
335
 
        if (cw->destroyed ())
336
 
            continue;
337
 
 
338
 
        if (cw->iconGeometry ().isEmpty ())
339
 
            continue;
340
 
 
341
 
        if (!cw->isMapped ())
342
 
            continue;
343
 
 
344
 
        if (cw->state () & CompWindowStateSkipTaskbarMask)
345
 
            continue;
346
 
 
347
 
        if (cw->state () & CompWindowStateSkipPagerMask)
348
 
            continue;
349
 
 
350
 
        if (!cw->managed ())
351
 
            continue;
352
 
 
353
 
        if (!tw->cWindow->pixmap ())
 
338
        if (cw->destroyed ()                                ||
 
339
            cw->iconGeometry ().isEmpty ()                  ||
 
340
            !cw->isMapped ()                                ||
 
341
            cw->state () & CompWindowStateSkipTaskbarMask   ||
 
342
            cw->state () & CompWindowStateSkipPagerMask     ||
 
343
            !cw->managed ()                                 ||
 
344
            !tw->cWindow->pixmap ())
354
345
            continue;
355
346
 
356
347
        if (cw->iconGeometry ().contains (p) &&
363
354
 
364
355
    if (found)
365
356
    {
 
357
        int showDelay = optionGetShowDelay ();
 
358
 
366
359
        if (!showingThumb &&
367
360
            !(thumb.opacity != 0.0 && thumb.win == found))
368
361
        {
369
362
            if (displayTimeout.active ())
370
 
 
371
363
            {
372
364
                if (pointedWin != found)
373
365
                {
374
366
                    displayTimeout.stop ();
375
 
                    displayTimeout.start (boost::bind
376
 
                                           (&ThumbScreen::thumbShowThumbnail,
377
 
                                            this),
378
 
                                          optionGetShowDelay (),
379
 
                                          optionGetShowDelay () + 500);
 
367
                    displayTimeout.start (boost::bind (&ThumbScreen::thumbShowThumbnail,
 
368
                                                       this), showDelay, showDelay + 500);
380
369
                }
381
370
            }
382
371
            else
383
372
            {
384
 
            displayTimeout.stop ();
385
 
            displayTimeout.start (boost::bind (&ThumbScreen::thumbShowThumbnail,
386
 
                                                this),
387
 
                                  optionGetShowDelay (),
388
 
                                  optionGetShowDelay () + 500);
 
373
                displayTimeout.stop ();
 
374
                displayTimeout.start (boost::bind (&ThumbScreen::thumbShowThumbnail,
 
375
                                                   this), showDelay, showDelay + 500);
389
376
            }
390
 
        }
 
377
        }
391
378
 
392
 
        pointedWin = found;
393
 
        thumbUpdateThumbnail ();
 
379
        pointedWin = found;
 
380
        thumbUpdateThumbnail ();
394
381
    }
395
382
    else
396
383
    {
397
384
        if (displayTimeout.active ())
398
 
        {
399
385
            displayTimeout.stop ();
400
 
        }
401
386
 
402
387
        pointedWin   = NULL;
403
388
        showingThumb = false;
407
392
    }
408
393
}
409
394
 
410
 
 
411
395
void
412
 
ThumbWindow::resizeNotify (int        dx,
413
 
                           int        dy,
414
 
                           int        dwidth,
415
 
                           int        dheight)
 
396
ThumbWindow::resizeNotify (int dx,
 
397
                           int dy,
 
398
                           int dwidth,
 
399
                           int dheight)
416
400
{
417
401
    THUMB_SCREEN (screen);
418
402
 
422
406
}
423
407
 
424
408
void
425
 
ThumbScreen::handleEvent (XEvent * event)
 
409
ThumbScreen::handleEvent (XEvent *event)
426
410
{
427
 
 
428
411
    screen->handleEvent (event);
429
412
 
430
413
    CompWindow *w;
431
414
 
432
415
    switch (event->type)
433
416
    {
434
 
    case PropertyNotify:
435
 
        if (event->xproperty.atom == Atoms::wmName)
436
 
        {
437
 
            w = screen->findWindow (event->xproperty.window);
 
417
        case PropertyNotify:
 
418
            if (event->xproperty.atom == Atoms::wmName)
 
419
            {
 
420
                w = screen->findWindow (event->xproperty.window);
438
421
 
439
 
            if (w)
440
 
            {
441
 
                if (thumb.win == w && optionGetTitleEnabled ())
 
422
                if (w && thumb.win == w && optionGetTitleEnabled ())
442
423
                    renderThumbText (&thumb, true);
443
424
            }
444
 
        }
445
 
        break;
446
 
 
447
 
    case ButtonPress:
 
425
 
 
426
            break;
 
427
 
 
428
        case ButtonPress:
448
429
        {
449
 
 
450
430
            if (displayTimeout.active ())
451
 
            {
452
431
                displayTimeout.stop ();
453
 
            }
454
432
 
455
 
            pointedWin   = 0;
 
433
            pointedWin   = NULL;
456
434
            showingThumb = false;
457
435
        }
458
 
        break;
459
 
 
460
 
    case EnterNotify:
461
 
        w = screen->findWindow (event->xcrossing.window);
462
 
        if (w)
463
 
        {
464
 
            if (w->wmType () & CompWindowTypeDockMask)
 
436
            break;
 
437
 
 
438
        case EnterNotify:
 
439
            w = screen->findWindow (event->xcrossing.window);
 
440
 
 
441
            if (w)
465
442
            {
466
 
                if (dock != w)
467
 
                {
468
 
                    dock = w;
 
443
                if (w->wmType () & CompWindowTypeDockMask)
 
444
                {
 
445
                    if (dock != w)
 
446
                    {
 
447
                        dock = w;
 
448
 
 
449
                        if (displayTimeout.active ())
 
450
                            displayTimeout.stop ();
 
451
 
 
452
                        pointedWin   = NULL;
 
453
                        showingThumb = false;
 
454
                    }
 
455
 
 
456
                    if (!poller.active ())
 
457
                        poller.start ();
 
458
                }
 
459
                else
 
460
                {
 
461
                    dock = NULL;
469
462
 
470
463
                    if (displayTimeout.active ())
471
 
                    {
472
464
                        displayTimeout.stop ();
473
 
                    }
474
465
 
475
466
                    pointedWin   = NULL;
476
467
                    showingThumb = false;
477
 
                }
478
 
 
479
 
                if (!poller.active ())
480
 
                {
481
 
                    poller.start ();
482
 
                }
483
 
            }
484
 
            else
485
 
            {
486
 
                dock = NULL;
487
 
 
488
 
                if (displayTimeout.active ())
489
 
                {
490
 
                    displayTimeout.stop ();
491
 
                }
492
 
 
493
 
                pointedWin   = NULL;
494
 
                showingThumb = false;
495
 
 
496
 
                if (poller.active ())
497
 
                {
498
 
                    poller.stop ();
499
 
                }
500
 
            }
501
 
        }
502
 
        break;
503
 
    case LeaveNotify:
504
 
        w = screen->findWindow (event->xcrossing.window);
505
 
        if (w)
506
 
        {
507
 
            if (w->wmType () & CompWindowTypeDockMask)
508
 
            {
509
 
                dock = NULL;
510
 
 
511
 
                if (displayTimeout.active ())
512
 
                {
513
 
                    displayTimeout.stop ();
514
 
                }
 
468
 
 
469
                    if (poller.active ())
 
470
                        poller.stop ();
 
471
                }
 
472
            }
 
473
 
 
474
            break;
 
475
 
 
476
        case LeaveNotify:
 
477
            w = screen->findWindow (event->xcrossing.window);
 
478
 
 
479
            if (w && (w->wmType () & CompWindowTypeDockMask))
 
480
            {
 
481
                dock = NULL;
 
482
 
 
483
                if (displayTimeout.active ())
 
484
                    displayTimeout.stop ();
515
485
 
516
486
                pointedWin   = NULL;
517
487
                showingThumb = false;
520
490
                cScreen->donePaintSetEnabled (this, true);
521
491
 
522
492
                if (poller.active ())
523
 
                {
524
493
                    poller.stop ();
525
 
                }
526
 
 
527
 
 
528
494
            }
529
 
        }
530
 
        break;
531
 
 
532
 
    default:
533
 
        break;
 
495
 
 
496
            break;
 
497
 
 
498
        default:
 
499
            break;
534
500
    }
535
501
}
536
502
 
537
 
 
538
503
void
539
504
ThumbScreen::paintTexture (const GLMatrix &transform,
540
 
                           GLushort       *color,
541
 
                           int             wx,
542
 
                          int wy,
543
 
                          int width,
544
 
                          int height,
545
 
                          int off)
 
505
                           GLushort       *color,
 
506
                           int            wx,
 
507
                           int            wy,
 
508
                           int            width,
 
509
                           int            height,
 
510
                           int            off)
546
511
{
547
 
    GLfloat         textureData[8];
548
 
    GLfloat         vertexData[12];
 
512
    GLfloat textureData[8];
 
513
    GLfloat vertexData[12];
 
514
 
 
515
    GLfloat wxPlusWidth    = wx + width;
 
516
    GLfloat wyPlusHeight   = wy + height;
 
517
    GLfloat wxPlusWPlusOff = wxPlusWidth  + off;
 
518
    GLfloat wyPlusHPlusOff = wyPlusHeight + off;
 
519
    GLfloat wxMinusOff     = wx - off;
 
520
    GLfloat wyMinusOff     = wy - off;
 
521
 
549
522
    GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
550
523
 
551
524
    streamingBuffer->begin (GL_TRIANGLE_STRIP);
557
530
    vertexData[1]  = wy;
558
531
    vertexData[2]  = 0;
559
532
    vertexData[3]  = wx;
560
 
    vertexData[4]  = wy + height;
 
533
    vertexData[4]  = wyPlusHeight;
561
534
    vertexData[5]  = 0;
562
 
    vertexData[6]  = wx + width;
 
535
    vertexData[6]  = wxPlusWidth;
563
536
    vertexData[7]  = wy;
564
537
    vertexData[8]  = 0;
565
 
    vertexData[9]  = wx + width;
566
 
    vertexData[10] = wy + height;
 
538
    vertexData[9]  = wxPlusWidth;
 
539
    vertexData[10] = wyPlusHeight;
567
540
    vertexData[11] = 0;
568
541
 
569
542
    streamingBuffer->addTexCoords (0, 1, textureData);
573
546
    streamingBuffer->end ();
574
547
    streamingBuffer->render (transform);
575
548
 
576
 
 
577
 
    streamingBuffer->begin (GL_TRIANGLE_STRIP);
578
 
 
579
 
    textureData[0] = 0;
580
 
    textureData[1] = 0;
581
 
    textureData[2] = 0;
582
 
    textureData[3] = 1;
583
 
    textureData[4] = 1;
584
 
    textureData[5] = 0;
585
 
    textureData[6] = 1;
586
 
    textureData[7] = 1;
587
 
 
588
 
    vertexData[0] = wx - off;
589
 
    vertexData[1] = wy - off;
590
 
    vertexData[2] = 0;
591
 
    vertexData[3] = wx - off;
592
 
    vertexData[4] = wy;
593
 
    vertexData[5] = 0;
594
 
    vertexData[6] = wx;
595
 
    vertexData[7] = wy - off;
596
 
    vertexData[8] = 0;
597
 
    vertexData[9] = wx;
598
 
    vertexData[10] = wy;
599
 
    vertexData[11] = 0;
600
 
 
601
 
    streamingBuffer->addTexCoords (0, 4, textureData);
602
 
    streamingBuffer->addVertices (4, vertexData);
603
 
    streamingBuffer->addColors (1, color);
604
 
 
605
 
    streamingBuffer->end ();
606
 
    streamingBuffer->render (transform);
607
 
 
608
 
 
609
 
    streamingBuffer->begin (GL_TRIANGLE_STRIP);
610
 
 
611
 
    textureData[0] = 1;
612
 
    textureData[1] = 0;
613
 
    textureData[2] = 1;
614
 
    textureData[3] = 1;
615
 
    textureData[4] = 0;
616
 
    textureData[5] = 0;
617
 
    textureData[6] = 0;
618
 
    textureData[7] = 1;
619
 
 
620
 
    vertexData[0] = wx + width;
621
 
    vertexData[1] = wy - off;
622
 
    vertexData[2] = 0;
623
 
    vertexData[3] = wx + width;
624
 
    vertexData[4] = wy;
625
 
    vertexData[5] = 0;
626
 
    vertexData[6] = wx + width + off;
627
 
    vertexData[7] = wy - off;
628
 
    vertexData[8] = 0;
629
 
    vertexData[9] = wx + width + off;
630
 
    vertexData[10] = wy;
631
 
    vertexData[11] = 0;
632
 
 
633
 
    streamingBuffer->addTexCoords (0, 4, textureData);
634
 
    streamingBuffer->addVertices (4, vertexData);
635
 
    streamingBuffer->addColors (1, color);
636
 
 
637
 
    streamingBuffer->end ();
638
 
    streamingBuffer->render (transform);
639
 
 
640
 
 
641
 
    streamingBuffer->begin (GL_TRIANGLE_STRIP);
642
 
 
643
 
    textureData[0] = 0;
644
 
    textureData[1] = 1;
645
 
    textureData[2] = 0;
646
 
    textureData[3] = 0;
647
 
    textureData[4] = 1;
648
 
    textureData[5] = 1;
649
 
    textureData[6] = 1;
650
 
    textureData[7] = 0;
651
 
 
652
 
    vertexData[0] = wx - off;
653
 
    vertexData[1] = wy + height;
654
 
    vertexData[2] = 0;
655
 
    vertexData[3] = wx - off;
656
 
    vertexData[4] = wy + height + off;
657
 
    vertexData[5] = 0;
658
 
    vertexData[6] = wx;
659
 
    vertexData[7] = wy + height;
660
 
    vertexData[8] = 0;
661
 
    vertexData[9] = wx;
662
 
    vertexData[10] = wy + height + off;
663
 
    vertexData[11] = 0;
664
 
 
665
 
    streamingBuffer->addTexCoords (0, 4, textureData);
666
 
    streamingBuffer->addVertices (4, vertexData);
667
 
    streamingBuffer->addColors (1, color);
668
 
 
669
 
    streamingBuffer->end ();
670
 
    streamingBuffer->render (transform);
671
 
 
672
 
 
673
 
    streamingBuffer->begin (GL_TRIANGLE_STRIP);
674
 
 
675
 
    textureData[0] = 1;
676
 
    textureData[1] = 1;
677
 
    textureData[2] = 1;
678
 
    textureData[3] = 0;
679
 
    textureData[4] = 0;
680
 
    textureData[5] = 1;
681
 
    textureData[6] = 0;
682
 
    textureData[7] = 0;
683
 
 
684
 
    vertexData[0] = wx + width;
685
 
    vertexData[1] = wy + height;
686
 
    vertexData[2] = 0;
687
 
    vertexData[3] = wx + width;
688
 
    vertexData[4] = wy + height + off;
689
 
    vertexData[5] = 0;
690
 
    vertexData[6] = wx + width + off;
691
 
    vertexData[7] = wy + height;
692
 
    vertexData[8] = 0;
693
 
    vertexData[9] = wx + width + off;
694
 
    vertexData[10] = wy + height + off;
695
 
    vertexData[11] = 0;
696
 
 
697
 
    streamingBuffer->addTexCoords (0, 4, textureData);
698
 
    streamingBuffer->addVertices (4, vertexData);
699
 
    streamingBuffer->addColors (1, color);
700
 
 
701
 
    streamingBuffer->end ();
702
 
    streamingBuffer->render (transform);
703
 
 
704
 
 
705
 
    streamingBuffer->begin (GL_TRIANGLE_STRIP);
706
 
 
707
 
    textureData[0] = 1;
708
 
    textureData[1] = 0;
709
 
    textureData[2] = 1;
710
 
    textureData[3] = 1;
711
 
    textureData[4] = 1;
712
 
    textureData[5] = 0;
713
 
    textureData[6] = 1;
714
 
    textureData[7] = 1;
715
 
 
716
 
    vertexData[0] = wx;
717
 
    vertexData[1] = wy - off;
718
 
    vertexData[2] = 0;
719
 
    vertexData[3] = wx;
720
 
    vertexData[4] = wy;
721
 
    vertexData[5] = 0;
722
 
    vertexData[6] = wx + width;
723
 
    vertexData[7] = wy - off;
724
 
    vertexData[8] = 0;
725
 
    vertexData[9] = wx + width;
726
 
    vertexData[10] = wy;
727
 
    vertexData[11] = 0;
728
 
 
729
 
    streamingBuffer->addTexCoords (0, 4, textureData);
730
 
    streamingBuffer->addVertices (4, vertexData);
731
 
    streamingBuffer->addColors (1, color);
732
 
 
733
 
    streamingBuffer->end ();
734
 
    streamingBuffer->render (transform);
735
 
 
736
 
 
737
 
    streamingBuffer->begin (GL_TRIANGLE_STRIP);
738
 
 
739
 
    textureData[0] = 1;
740
 
    textureData[1] = 1;
741
 
    textureData[2] = 1;
742
 
    textureData[3] = 0;
743
 
    textureData[4] = 1;
744
 
    textureData[5] = 1;
745
 
    textureData[6] = 1;
746
 
    textureData[7] = 0;
747
 
 
748
 
    vertexData[0] = wx;
749
 
    vertexData[1] = wy + height;
750
 
    vertexData[2] = 0;
751
 
    vertexData[3] = wx;
752
 
    vertexData[4] = wy + height + off;
753
 
    vertexData[5] = 0;
754
 
    vertexData[6] = wx + width;
755
 
    vertexData[7] = wy + height;
756
 
    vertexData[8] = 0;
757
 
    vertexData[9] = wx + width;
758
 
    vertexData[10] = wy + height + off;
759
 
    vertexData[11] = 0;
760
 
 
761
 
    streamingBuffer->addTexCoords (0, 4, textureData);
762
 
    streamingBuffer->addVertices (4, vertexData);
763
 
    streamingBuffer->addColors (1, color);
764
 
 
765
 
    streamingBuffer->end ();
766
 
    streamingBuffer->render (transform);
767
 
 
768
 
 
769
 
    streamingBuffer->begin (GL_TRIANGLE_STRIP);
770
 
 
771
 
    textureData[0] = 0;
772
 
    textureData[1] = 1;
773
 
    textureData[2] = 0;
774
 
    textureData[3] = 1;
775
 
    textureData[4] = 1;
776
 
    textureData[5] = 1;
777
 
    textureData[6] = 1;
778
 
    textureData[7] = 1;
779
 
 
780
 
    vertexData[0] = wx - off;
781
 
    vertexData[1] = wy;
782
 
    vertexData[2] = 0;
783
 
    vertexData[3] = wx - off;
784
 
    vertexData[4] = wy + height;
785
 
    vertexData[5] = 0;
786
 
    vertexData[6] = wx;
787
 
    vertexData[7] = wy;
788
 
    vertexData[8] = 0;
789
 
    vertexData[9] = wx;
790
 
    vertexData[10] = wy + height;
791
 
    vertexData[11] = 0;
792
 
 
793
 
    streamingBuffer->addTexCoords (0, 4, textureData);
794
 
    streamingBuffer->addVertices (4, vertexData);
795
 
    streamingBuffer->addColors (1, color);
796
 
 
797
 
    streamingBuffer->end ();
798
 
    streamingBuffer->render (transform);
799
 
 
800
 
 
801
 
    streamingBuffer->begin (GL_TRIANGLE_STRIP);
802
 
 
803
 
    textureData[0] = 1;
804
 
    textureData[1] = 1;
805
 
    textureData[2] = 1;
806
 
    textureData[3] = 1;
807
 
    textureData[4] = 0;
808
 
    textureData[5] = 1;
809
 
    textureData[6] = 0;
810
 
    textureData[7] = 1;
811
 
 
812
 
    vertexData[0] = wx + width;
813
 
    vertexData[1] = wy;
814
 
    vertexData[2] = 0;
815
 
    vertexData[3] = wx + width;
816
 
    vertexData[4] = wy + height;
817
 
    vertexData[5] = 0;
818
 
    vertexData[6] = wx + width + off;
819
 
    vertexData[7] = wy;
820
 
    vertexData[8] = 0;
821
 
    vertexData[9] = wx + width + off;
822
 
    vertexData[10] = wy + height;
 
549
    streamingBuffer->begin (GL_TRIANGLE_STRIP);
 
550
 
 
551
    textureData[0] = 0;
 
552
    textureData[1] = 0;
 
553
    textureData[2] = 0;
 
554
    textureData[3] = 1;
 
555
    textureData[4] = 1;
 
556
    textureData[5] = 0;
 
557
    textureData[6] = 1;
 
558
    textureData[7] = 1;
 
559
 
 
560
    vertexData[0]  = wxMinusOff;
 
561
    vertexData[1]  = wyMinusOff;
 
562
    vertexData[2]  = 0;
 
563
    vertexData[3]  = wxMinusOff;
 
564
    vertexData[4]  = wy;
 
565
    vertexData[5]  = 0;
 
566
    vertexData[6]  = wx;
 
567
    vertexData[7]  = wyMinusOff;
 
568
    vertexData[8]  = 0;
 
569
    vertexData[9]  = wx;
 
570
    vertexData[10] = wy;
 
571
    vertexData[11] = 0;
 
572
 
 
573
    streamingBuffer->addTexCoords (0, 4, textureData);
 
574
    streamingBuffer->addVertices (4, vertexData);
 
575
    streamingBuffer->addColors (1, color);
 
576
 
 
577
    streamingBuffer->end ();
 
578
    streamingBuffer->render (transform);
 
579
 
 
580
    streamingBuffer->begin (GL_TRIANGLE_STRIP);
 
581
 
 
582
    textureData[0] = 1;
 
583
    textureData[1] = 0;
 
584
    textureData[2] = 1;
 
585
    textureData[3] = 1;
 
586
    textureData[4] = 0;
 
587
    textureData[5] = 0;
 
588
    textureData[6] = 0;
 
589
    textureData[7] = 1;
 
590
 
 
591
    vertexData[0]  = wxPlusWidth;
 
592
    vertexData[1]  = wyMinusOff;
 
593
    vertexData[2]  = 0;
 
594
    vertexData[3]  = wxPlusWidth;
 
595
    vertexData[4]  = wy;
 
596
    vertexData[5]  = 0;
 
597
    vertexData[6]  = wxPlusWPlusOff;
 
598
    vertexData[7]  = wyMinusOff;
 
599
    vertexData[8]  = 0;
 
600
    vertexData[9]  = wxPlusWPlusOff;
 
601
    vertexData[10] = wy;
 
602
    vertexData[11] = 0;
 
603
 
 
604
    streamingBuffer->addTexCoords (0, 4, textureData);
 
605
    streamingBuffer->addVertices (4, vertexData);
 
606
    streamingBuffer->addColors (1, color);
 
607
 
 
608
    streamingBuffer->end ();
 
609
    streamingBuffer->render (transform);
 
610
 
 
611
    streamingBuffer->begin (GL_TRIANGLE_STRIP);
 
612
 
 
613
    textureData[0] = 0;
 
614
    textureData[1] = 1;
 
615
    textureData[2] = 0;
 
616
    textureData[3] = 0;
 
617
    textureData[4] = 1;
 
618
    textureData[5] = 1;
 
619
    textureData[6] = 1;
 
620
    textureData[7] = 0;
 
621
 
 
622
    vertexData[0]  = wxMinusOff;
 
623
    vertexData[1]  = wyPlusHeight;
 
624
    vertexData[2]  = 0;
 
625
    vertexData[3]  = wxMinusOff;
 
626
    vertexData[4]  = wyPlusHPlusOff;
 
627
    vertexData[5]  = 0;
 
628
    vertexData[6]  = wx;
 
629
    vertexData[7]  = wyPlusHeight;
 
630
    vertexData[8]  = 0;
 
631
    vertexData[9]  = wx;
 
632
    vertexData[10] = wyPlusHPlusOff;
 
633
    vertexData[11] = 0;
 
634
 
 
635
    streamingBuffer->addTexCoords (0, 4, textureData);
 
636
    streamingBuffer->addVertices (4, vertexData);
 
637
    streamingBuffer->addColors (1, color);
 
638
 
 
639
    streamingBuffer->end ();
 
640
    streamingBuffer->render (transform);
 
641
 
 
642
    streamingBuffer->begin (GL_TRIANGLE_STRIP);
 
643
 
 
644
    textureData[0] = 1;
 
645
    textureData[1] = 1;
 
646
    textureData[2] = 1;
 
647
    textureData[3] = 0;
 
648
    textureData[4] = 0;
 
649
    textureData[5] = 1;
 
650
    textureData[6] = 0;
 
651
    textureData[7] = 0;
 
652
 
 
653
    vertexData[0]  = wxPlusWidth;
 
654
    vertexData[1]  = wyPlusHeight;
 
655
    vertexData[2]  = 0;
 
656
    vertexData[3]  = wxPlusWidth;
 
657
    vertexData[4]  = wyPlusHPlusOff;
 
658
    vertexData[5]  = 0;
 
659
    vertexData[6]  = wxPlusWPlusOff;
 
660
    vertexData[7]  = wyPlusHeight;
 
661
    vertexData[8]  = 0;
 
662
    vertexData[9]  = wxPlusWPlusOff;
 
663
    vertexData[10] = wyPlusHPlusOff;
 
664
    vertexData[11] = 0;
 
665
 
 
666
    streamingBuffer->addTexCoords (0, 4, textureData);
 
667
    streamingBuffer->addVertices (4, vertexData);
 
668
    streamingBuffer->addColors (1, color);
 
669
 
 
670
    streamingBuffer->end ();
 
671
    streamingBuffer->render (transform);
 
672
 
 
673
    streamingBuffer->begin (GL_TRIANGLE_STRIP);
 
674
 
 
675
    textureData[0] = 1;
 
676
    textureData[1] = 0;
 
677
    textureData[2] = 1;
 
678
    textureData[3] = 1;
 
679
    textureData[4] = 1;
 
680
    textureData[5] = 0;
 
681
    textureData[6] = 1;
 
682
    textureData[7] = 1;
 
683
 
 
684
    vertexData[0]  = wx;
 
685
    vertexData[1]  = wyMinusOff;
 
686
    vertexData[2]  = 0;
 
687
    vertexData[3]  = wx;
 
688
    vertexData[4]  = wy;
 
689
    vertexData[5]  = 0;
 
690
    vertexData[6]  = wxPlusWidth;
 
691
    vertexData[7]  = wyMinusOff;
 
692
    vertexData[8]  = 0;
 
693
    vertexData[9]  = wxPlusWidth;
 
694
    vertexData[10] = wy;
 
695
    vertexData[11] = 0;
 
696
 
 
697
    streamingBuffer->addTexCoords (0, 4, textureData);
 
698
    streamingBuffer->addVertices (4, vertexData);
 
699
    streamingBuffer->addColors (1, color);
 
700
 
 
701
    streamingBuffer->end ();
 
702
    streamingBuffer->render (transform);
 
703
 
 
704
    streamingBuffer->begin (GL_TRIANGLE_STRIP);
 
705
 
 
706
    textureData[0] = 1;
 
707
    textureData[1] = 1;
 
708
    textureData[2] = 1;
 
709
    textureData[3] = 0;
 
710
    textureData[4] = 1;
 
711
    textureData[5] = 1;
 
712
    textureData[6] = 1;
 
713
    textureData[7] = 0;
 
714
 
 
715
    vertexData[0]  = wx;
 
716
    vertexData[1]  = wyPlusHeight;
 
717
    vertexData[2]  = 0;
 
718
    vertexData[3]  = wx;
 
719
    vertexData[4]  = wyPlusHPlusOff;
 
720
    vertexData[5]  = 0;
 
721
    vertexData[6]  = wxPlusWidth;
 
722
    vertexData[7]  = wyPlusHeight;
 
723
    vertexData[8]  = 0;
 
724
    vertexData[9]  = wxPlusWidth;
 
725
    vertexData[10] = wyPlusHPlusOff;
 
726
    vertexData[11] = 0;
 
727
 
 
728
    streamingBuffer->addTexCoords (0, 4, textureData);
 
729
    streamingBuffer->addVertices (4, vertexData);
 
730
    streamingBuffer->addColors (1, color);
 
731
 
 
732
    streamingBuffer->end ();
 
733
    streamingBuffer->render (transform);
 
734
 
 
735
    streamingBuffer->begin (GL_TRIANGLE_STRIP);
 
736
 
 
737
    textureData[0] = 0;
 
738
    textureData[1] = 1;
 
739
    textureData[2] = 0;
 
740
    textureData[3] = 1;
 
741
    textureData[4] = 1;
 
742
    textureData[5] = 1;
 
743
    textureData[6] = 1;
 
744
    textureData[7] = 1;
 
745
 
 
746
    vertexData[0]  = wxMinusOff;
 
747
    vertexData[1]  = wy;
 
748
    vertexData[2]  = 0;
 
749
    vertexData[3]  = wxMinusOff;
 
750
    vertexData[4]  = wyPlusHeight;
 
751
    vertexData[5]  = 0;
 
752
    vertexData[6]  = wx;
 
753
    vertexData[7]  = wy;
 
754
    vertexData[8]  = 0;
 
755
    vertexData[9]  = wx;
 
756
    vertexData[10] = wyPlusHeight;
 
757
    vertexData[11] = 0;
 
758
 
 
759
    streamingBuffer->addTexCoords (0, 4, textureData);
 
760
    streamingBuffer->addVertices (4, vertexData);
 
761
    streamingBuffer->addColors (1, color);
 
762
 
 
763
    streamingBuffer->end ();
 
764
    streamingBuffer->render (transform);
 
765
 
 
766
    streamingBuffer->begin (GL_TRIANGLE_STRIP);
 
767
 
 
768
    textureData[0] = 1;
 
769
    textureData[1] = 1;
 
770
    textureData[2] = 1;
 
771
    textureData[3] = 1;
 
772
    textureData[4] = 0;
 
773
    textureData[5] = 1;
 
774
    textureData[6] = 0;
 
775
    textureData[7] = 1;
 
776
 
 
777
    vertexData[0]  = wxPlusWidth;
 
778
    vertexData[1]  = wy;
 
779
    vertexData[2]  = 0;
 
780
    vertexData[3]  = wxPlusWidth;
 
781
    vertexData[4]  = wyPlusHeight;
 
782
    vertexData[5]  = 0;
 
783
    vertexData[6]  = wxPlusWPlusOff;
 
784
    vertexData[7]  = wy;
 
785
    vertexData[8]  = 0;
 
786
    vertexData[9]  = wxPlusWPlusOff;
 
787
    vertexData[10] = wyPlusHeight;
823
788
    vertexData[11] = 0;
824
789
 
825
790
    streamingBuffer->addTexCoords (0, 4, textureData);
831
796
}
832
797
 
833
798
void
834
 
ThumbScreen::thumbPaintThumb (Thumbnail           *t,
 
799
ThumbScreen::thumbPaintThumb (Thumbnail      *t,
835
800
                              const GLMatrix *transform)
836
801
{
837
 
    GLushort              color[4];
838
 
    int                   addWindowGeometryIndex;
839
 
    CompWindow            *w = t->win;
840
 
    int                   wx = t->x;
841
 
    int                   wy = t->y;
842
 
    float                 width  = t->width;
843
 
    float                 backheight = t->height;       // background/glow height
844
 
    GLWindowPaintAttrib     sAttrib;
845
 
    unsigned int          mask = PAINT_WINDOW_TRANSFORMED_MASK |
846
 
                                 PAINT_WINDOW_TRANSLUCENT_MASK;
847
 
    GLWindow              *gWindow = GLWindow::get (w);
 
802
    CompWindow *w = t->win;
848
803
 
849
804
    if (!w)
850
805
        return;
851
806
 
 
807
    GLWindow *gWindow = GLWindow::get (w);
 
808
 
 
809
    GLushort color[4];
 
810
 
 
811
    int wx = t->x;
 
812
    int wy = t->y;
 
813
 
 
814
    GLWindowPaintAttrib sAttrib;
 
815
    unsigned int mask = PAINT_WINDOW_TRANSFORMED_MASK |
 
816
                        PAINT_WINDOW_TRANSLUCENT_MASK;
 
817
 
852
818
    sAttrib = gWindow->paintAttrib ();
853
819
 
854
820
    /* Wrap drawWindowGeometry to make sure the general
855
821
       drawWindowGeometry function is used */
856
 
    addWindowGeometryIndex =
857
 
            gWindow->glAddGeometryGetCurrentIndex ();
 
822
    unsigned int addWindowGeometryIndex = gWindow->glAddGeometryGetCurrentIndex ();
858
823
 
859
824
    if (!gWindow->textures ().empty ())
860
825
    {
861
 
        int            off = t->offset;
862
 
        GLenum         filter = gScreen->textureFilter ();
863
 
        GLMatrix       wTransform (*transform);
864
 
 
865
 
        glEnable (GL_BLEND);
 
826
        GLMatrix  wTransform (*transform);
 
827
        GLboolean glBlendEnabled = glIsEnabled (GL_BLEND);
 
828
 
 
829
        /* just enable blending if it is currently disabled */
 
830
        if (!glBlendEnabled)
 
831
            glEnable (GL_BLEND);
 
832
 
866
833
        glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
867
834
 
 
835
        int   off        = t->offset;
 
836
        float backheight = t->height;   // background/glow height
 
837
        float width      = t->width;
 
838
 
868
839
        if (optionGetWindowLike ())
869
840
        {
870
841
            color[0] = 1;
895
866
        }
896
867
 
897
868
        glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
898
 
        glDisable (GL_BLEND);
 
869
 
 
870
        /* we disable blending only, if it was disabled before */
 
871
        if (!glBlendEnabled)
 
872
            glDisable (GL_BLEND);
899
873
 
900
874
        if (t->text)
901
875
        {
902
 
            float ox = 0.0f;
 
876
            float ox     = 0.0f;
903
877
            float height = backheight + t->text->getHeight () + optionGetTextDistance ();
904
878
 
905
879
            if (t->text->getWidth () < width)
911
885
        gScreen->setTexEnvMode (GL_REPLACE);
912
886
 
913
887
        sAttrib.opacity *= t->opacity;
914
 
        sAttrib.yScale = t->scale;
915
 
        sAttrib.xScale = t->scale;
 
888
        sAttrib.yScale   = t->scale;
 
889
        sAttrib.xScale   = t->scale;
916
890
 
917
891
        sAttrib.xTranslate = wx - w->x () + w->border ().left * sAttrib.xScale;
918
 
        sAttrib.yTranslate = wy - w->y () + w->border ().top * sAttrib.yScale;
919
 
 
 
892
        sAttrib.yTranslate = wy - w->y () + w->border ().top  * sAttrib.yScale;
 
893
 
 
894
        GLenum filter = gScreen->textureFilter ();
 
895
 
 
896
        /* we just need to change the texture filter, if
 
897
         * thumbnail mipmapping is enabled */
920
898
        if (optionGetMipmap ())
921
899
            gScreen->setTextureFilter (GL_LINEAR_MIPMAP_LINEAR);
922
900
 
962
940
    }*/
963
941
 
964
942
    if (showingThumb && thumb.win == pointedWin)
965
 
    {
966
943
        thumb.opacity = MIN (1.0, thumb.opacity + val);
967
 
    }
968
944
 
969
945
    if (!showingThumb || thumb.win != pointedWin)
970
946
    {
971
947
        thumb.opacity = MAX (0.0, thumb.opacity - val);
 
948
 
972
949
        if (thumb.opacity == 0.0)
973
950
            thumb.win = NULL;
974
951
    }
976
953
    if (oldThumb.opacity > 0.0f)
977
954
    {
978
955
        oldThumb.opacity = MAX (0.0, oldThumb.opacity - val);
 
956
 
979
957
        if (oldThumb.opacity == 0.0)
980
958
        {
981
959
            damageThumbRegion (&oldThumb);
999
977
{
1000
978
    std::vector <Thumbnail *> damageThumbs;
1001
979
 
1002
 
    if (thumb.opacity > 0.0)
 
980
    if (thumb.opacity)
1003
981
        damageThumbs.push_back (&thumb);
1004
982
 
1005
 
    if (oldThumb.opacity > 0.0)
 
983
    if (oldThumb.opacity)
1006
984
        damageThumbs.push_back (&oldThumb);
1007
985
 
1008
986
    if (!damageThumbs.empty ())
1021
999
 
1022
1000
bool
1023
1001
ThumbScreen::glPaintOutput (const GLScreenPaintAttrib &attrib,
1024
 
                            const GLMatrix &transform,
1025
 
                            const CompRegion &region,
1026
 
                            CompOutput *output,
1027
 
                            unsigned int mask)
 
1002
                            const GLMatrix            &transform,
 
1003
                            const CompRegion          &region,
 
1004
                            CompOutput                *output,
 
1005
                            unsigned int              mask)
1028
1006
{
1029
 
    bool         status;
1030
1007
    unsigned int newMask = mask;
1031
1008
 
1032
1009
    painted = false;
1035
1012
    y = screen->vp ().y ();
1036
1013
 
1037
1014
    if ((oldThumb.opacity > 0.0 && oldThumb.win) ||
1038
 
        (thumb.opacity > 0.0 && thumb.win))
1039
 
    {
 
1015
        (thumb.opacity > 0.0 && thumb.win))
1040
1016
        newMask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK;
1041
 
    }
1042
1017
 
1043
 
    status = gScreen->glPaintOutput (attrib, transform, region, output, newMask);
 
1018
    bool status = gScreen->glPaintOutput (attrib, transform, region, output, newMask);
1044
1019
 
1045
1020
    if (optionGetAlwaysOnTop () && !painted)
1046
1021
    {
1066
1041
 
1067
1042
void
1068
1043
ThumbScreen::glPaintTransformedOutput (const GLScreenPaintAttrib &attrib,
1069
 
                                       const GLMatrix &transform,
1070
 
                                       const CompRegion &region,
1071
 
                                       CompOutput *output,
1072
 
                                       unsigned int mask)
 
1044
                                       const GLMatrix            &transform,
 
1045
                                       const CompRegion          &region,
 
1046
                                       CompOutput                *output,
 
1047
                                       unsigned int              mask)
1073
1048
{
1074
 
 
1075
1049
    gScreen->glPaintTransformedOutput (attrib, transform, region, output, mask);
1076
1050
 
1077
1051
    if (optionGetAlwaysOnTop () && x == screen->vp ().x () &&
1079
1053
    {
1080
1054
        painted = true;
1081
1055
 
1082
 
        if (oldThumb.opacity > 0.0 && oldThumb.win)
 
1056
        if (oldThumb.opacity && oldThumb.win)
1083
1057
        {
1084
1058
            GLMatrix sTransform = transform;
1085
1059
 
1088
1062
            thumbPaintThumb (&oldThumb, &sTransform);
1089
1063
        }
1090
1064
 
1091
 
        if (thumb.opacity > 0.0 && thumb.win)
 
1065
        if (thumb.opacity && thumb.win)
1092
1066
        {
1093
1067
            GLMatrix sTransform = transform;
1094
1068
 
1101
1075
 
1102
1076
bool
1103
1077
ThumbWindow::glPaint (const GLWindowPaintAttrib &attrib,
1104
 
                      const GLMatrix            &transform,
 
1078
                      const GLMatrix            &transform,
1105
1079
                      const CompRegion          &region,
1106
 
                      unsigned int              mask)
 
1080
                      unsigned int              mask)
1107
1081
{
1108
 
    bool status;
1109
 
 
1110
1082
    THUMB_SCREEN (screen);
1111
1083
 
1112
 
    status = gWindow->glPaint (attrib, transform, region, mask);
 
1084
    bool status = gWindow->glPaint (attrib, transform, region, mask);
1113
1085
 
1114
 
    if (!ts->optionGetAlwaysOnTop () && ts->x == screen->vp ().x () &&
1115
 
                                    ts->y == screen->vp ().y ())
 
1086
    if (!ts->optionGetAlwaysOnTop ()    &&
 
1087
        ts->x == screen->vp ().x ()     &&
 
1088
        ts->y == screen->vp ().y ())
1116
1089
    {
1117
1090
        GLMatrix sTransform = transform;
1118
 
        if (ts->oldThumb.opacity > 0.0 && ts->oldThumb.win &&
 
1091
 
 
1092
        if (ts->oldThumb.opacity    &&
 
1093
            ts->oldThumb.win        &&
1119
1094
            ts->oldThumb.dock == window)
1120
 
        {
1121
1095
            ts->thumbPaintThumb (&ts->oldThumb, &sTransform);
1122
 
        }
1123
1096
 
1124
 
        if (ts->thumb.opacity > 0.0 && ts->thumb.win && ts->thumb.dock == window)
1125
 
        {
 
1097
        if (ts->thumb.opacity   &&
 
1098
            ts->thumb.win       &&
 
1099
            ts->thumb.dock == window)
1126
1100
            ts->thumbPaintThumb (&ts->thumb, &sTransform);
1127
 
        }
1128
1101
    }
1129
1102
 
1130
1103
    return status;
1131
1104
}
1132
1105
 
1133
1106
bool
1134
 
ThumbWindow::damageRect (bool initial,
1135
 
                         const CompRect &rect)
 
1107
ThumbWindow::damageRect (bool           initial,
 
1108
                         const CompRect &rect)
1136
1109
{
1137
1110
    THUMB_SCREEN (screen);
1138
1111
 
1139
 
    if (ts->thumb.win == window && ts->thumb.opacity > 0.0)
 
1112
    if (ts->thumb.win == window && ts->thumb.opacity)
1140
1113
        ts->damageThumbRegion (&ts->thumb);
1141
1114
 
1142
 
    if (ts->oldThumb.win == window && ts->oldThumb.opacity > 0.0)
 
1115
    if (ts->oldThumb.win == window && ts->oldThumb.opacity)
1143
1116
        ts->damageThumbRegion (&ts->oldThumb);
1144
1117
 
1145
1118
    return cWindow->damageRect (initial, rect);
1164
1137
    CompositeScreenInterface::setHandler (cScreen, false);
1165
1138
    GLScreenInterface::setHandler (gScreen, false);
1166
1139
 
1167
 
    thumb.win = NULL;
 
1140
    thumb.win    = NULL;
1168
1141
    oldThumb.win = NULL;
1169
1142
 
1170
 
    thumb.text = NULL;
 
1143
    thumb.text    = NULL;
1171
1144
    oldThumb.text = NULL;
1172
1145
 
1173
 
    thumb.opacity = 0.0f;
 
1146
    thumb.opacity    = 0.0f;
1174
1147
    oldThumb.opacity = 0.0f;
1175
1148
 
1176
1149
    poller.setCallback (boost::bind (&ThumbScreen::positionUpdate, this, _1));
1196
1169
    GLWindowInterface::setHandler (gWindow, false);
1197
1170
}
1198
1171
 
1199
 
 
1200
1172
ThumbWindow::~ThumbWindow ()
1201
1173
{
1202
1174
    THUMB_SCREEN (screen);
1204
1176
    if (ts->thumb.win == window)
1205
1177
    {
1206
1178
        ts->damageThumbRegion (&ts->thumb);
1207
 
        ts->thumb.win = NULL;
 
1179
        ts->thumb.win     = NULL;
1208
1180
        ts->thumb.opacity = 0;
1209
1181
    }
1210
1182
 
1211
1183
    if (ts->oldThumb.win == window)
1212
1184
    {
1213
1185
        ts->damageThumbRegion (&ts->oldThumb);
1214
 
        ts->oldThumb.win = NULL;
 
1186
        ts->oldThumb.win     = NULL;
1215
1187
        ts->oldThumb.opacity = 0;
1216
1188
    }
1217
1189
 
1219
1191
        ts->pointedWin = NULL;
1220
1192
}
1221
1193
 
1222
 
 
1223
1194
bool
1224
1195
ThumbPluginVTable::init ()
1225
1196
{
1226
 
    if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION))
1227
 
        return false;
1228
 
    if (!CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI))
1229
 
        return false;
1230
 
    if (!CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI))
1231
 
        return false;
1232
 
    if (!CompPlugin::checkPluginABI ("mousepoll", COMPIZ_MOUSEPOLL_ABI))
1233
 
        return false;
1234
1197
    if (CompPlugin::checkPluginABI ("text", COMPIZ_TEXT_ABI))
1235
1198
        textPluginLoaded = true;
1236
1199
    else
1237
1200
        textPluginLoaded = false;
1238
1201
 
1239
 
    return true;
 
1202
    if (CompPlugin::checkPluginABI ("core", CORE_ABIVERSION)            &&
 
1203
        CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI)  &&
 
1204
        CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI)        &&
 
1205
        CompPlugin::checkPluginABI ("mousepoll", COMPIZ_MOUSEPOLL_ABI))
 
1206
        return true;
 
1207
 
 
1208
    return false;
1240
1209
}