~ps-jenkins/compiz/latestsnapshot-10.9.9daily13.06.1913.04-0ubuntu1

« back to all changes in this revision

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

  • Committer: Tarmac
  • Author(s): Daniel van Vugt
  • Date: 2013-04-02 19:24:11 UTC
  • mfrom: (3643.1.3 back-to-raring)
  • Revision ID: tarmac-20130402192411-8jqkwbion75aazvt
Make lp:compiz/0.9.9 identical to lp:compiz/raring, so we can use it for 
raring maintenance and eliminate lp:compiz/raring.

The changes that this proposal "undoes" have not been lost. They have just
moved to the new development series: lp:compiz/0.9.10 (lp:compiz now points
to this).

Approved by PS Jenkins bot, Sam Spilsbury.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
#include "workspacenames.h"
26
26
 
27
 
namespace
28
 
{
29
 
    const unsigned short TEXT_BORDER = 2;
30
 
}
31
 
 
32
 
 
33
27
CompString
34
28
WSNamesScreen::getCurrentWSName ()
35
29
{
 
30
    int         currentVp;
 
31
    int         listSize;
36
32
    CompString  ret;
37
 
 
38
 
    CompOption::Value::Vector vpNumbers = optionGetViewports ();
39
 
    CompOption::Value::Vector names     = optionGetNames ();
40
 
 
41
 
    int currentVp = screen->vp ().y () * screen->vpSize ().width () +
 
33
    CompOption::Value::Vector names;
 
34
    CompOption::Value::Vector vpNumbers;
 
35
 
 
36
    vpNumbers = optionGetViewports ();
 
37
    names     = optionGetNames ();
 
38
 
 
39
    currentVp = screen->vp ().y () * screen->vpSize ().width () +
42
40
                screen->vp ().x () + 1;
43
 
    int listSize  = MIN (vpNumbers.size (), names.size ());
 
41
    listSize  = MIN (vpNumbers.size (), names.size ());
44
42
 
45
43
    for (int i = 0; i < listSize; i++)
46
44
        if (vpNumbers[i].i () == currentVp)
53
51
WSNamesScreen::renderNameText ()
54
52
{
55
53
    CompText::Attrib attrib;
 
54
    CompString       name;
56
55
 
57
56
    textData.clear ();
58
57
 
59
 
    CompString name = getCurrentWSName ();
 
58
    name = getCurrentWSName ();
60
59
 
61
60
    if (name.empty ())
62
61
        return;
87
86
    textData.renderText (name, attrib);
88
87
}
89
88
 
90
 
CompPoint
91
 
WSNamesScreen::getTextPlacementPosition ()
 
89
void
 
90
WSNamesScreen::drawText (const GLMatrix &matrix)
92
91
{
 
92
    GLfloat  alpha;
 
93
    float    x, y, border = 10.0f;
93
94
    CompRect oe = screen->getCurrentOutputExtents ();
94
 
    float x = oe.centerX () - textData.getWidth () / 2;
95
 
    float y = 0;
96
 
    const float border = TEXT_BORDER;
97
 
 
 
95
 
 
96
    x = oe.centerX () - textData.getWidth () / 2;
 
97
 
 
98
    /* assign y (for the lower corner!) according to the setting */
98
99
    switch (optionGetTextPlacement ())
99
100
    {
100
101
        case WorkspacenamesOptions::TextPlacementCenteredOnScreen:
107
108
 
108
109
                if (optionGetTextPlacement () ==
109
110
                    WorkspacenamesOptions::TextPlacementTopOfScreen)
110
 
                    y = oe.y1 () + workArea.y () +
 
111
                    y = oe.y1 () + workArea.y () +
111
112
                        (2 * border) + textData.getHeight ();
112
113
                else
113
114
                    y = oe.y1 () + workArea.y () +
115
116
            }
116
117
            break;
117
118
        default:
118
 
            return CompPoint (floor (x),
119
 
                              oe.centerY () - textData.getHeight () / 2);
 
119
            return;
120
120
            break;
121
121
    }
122
122
 
123
 
    return CompPoint (floor (x), floor (y));
124
 
}
125
 
 
126
 
void
127
 
WSNamesScreen::damageTextArea ()
128
 
{
129
 
    const CompPoint pos (getTextPlacementPosition ());
130
 
 
131
 
    /* The placement position is from the lower corner, so we
132
 
     * need to move it back up by height */
133
 
    CompRect        area (pos.x () - TEXT_BORDER,
134
 
                          pos.y () - TEXT_BORDER - textData.getHeight () ,
135
 
                          textData.getWidth () + TEXT_BORDER * 2,
136
 
                          textData.getHeight () + TEXT_BORDER * 2);
137
 
 
138
 
    cScreen->damageRegion (area);
139
 
}
140
 
 
141
 
void
142
 
WSNamesScreen::drawText (const GLMatrix &matrix)
143
 
{
144
 
    GLfloat  alpha = 0.0f;
145
 
 
146
 
    /* assign y (for the lower corner!) according to the setting */
147
 
    const CompPoint p = getTextPlacementPosition ();
148
 
 
149
123
    if (timer)
150
124
        alpha = timer / (optionGetFadeTime () * 1000.0f);
151
 
    else if (timeoutHandle.active ())
 
125
    else
152
126
        alpha = 1.0f;
153
127
 
154
 
    textData.draw (matrix, p.x (), p.y (), alpha);
155
 
}
156
 
 
157
 
bool
158
 
WSNamesScreen::shouldDrawText ()
159
 
{
160
 
    return textData.getWidth () && textData.getHeight ();
 
128
    textData.draw (matrix, floor (x), floor (y), alpha);
161
129
}
162
130
 
163
131
bool
167
135
                              CompOutput                *output,
168
136
                              unsigned int              mask)
169
137
{
170
 
    bool status = gScreen->glPaintOutput (attrib, transform, region, output, mask);
171
 
 
172
 
    if (shouldDrawText ())
 
138
    bool status;
 
139
 
 
140
    status = gScreen->glPaintOutput (attrib, transform, region, output, mask);
 
141
 
 
142
    if (textData.getWidth () && textData.getHeight ())
173
143
    {
174
144
        GLMatrix sTransform (transform);
175
145
 
188
158
    {
189
159
        timer -= msSinceLastPaint;
190
160
        timer = MAX (timer, 0);
 
161
 
 
162
        if (!timer)
 
163
            textData.clear ();
191
164
    }
192
165
 
193
166
    cScreen->preparePaint (msSinceLastPaint);
196
169
void
197
170
WSNamesScreen::donePaint ()
198
171
{
199
 
    /* Only damage when the */
200
 
    if (shouldDrawText ())
201
 
        damageTextArea ();
202
 
 
203
 
     cScreen->donePaint ();
 
172
    /* FIXME: better only damage paint region */
 
173
    if (timer)
 
174
        cScreen->damageScreen ();
204
175
 
205
 
    /* Clear text data if done with fadeout */
206
 
    if (!timer && !timeoutHandle.active ())
207
 
        textData.clear ();
 
176
    cScreen->donePaint ();
208
177
}
209
178
 
210
179
bool
211
180
WSNamesScreen::hideTimeout ()
212
181
{
213
182
    timer = optionGetFadeTime () * 1000;
214
 
 
215
 
    /* Clear immediately if there is no fadeout */
216
183
    if (!timer)
217
184
        textData.clear ();
218
 
 
219
 
    damageTextArea ();
 
185
 
 
186
    cScreen->damageScreen ();
220
187
 
221
188
    timeoutHandle.stop ();
222
189
 
242
209
        renderNameText ();
243
210
        timeoutHandle.start (timeout, timeout + 200);
244
211
 
245
 
        damageTextArea ();
 
212
        cScreen->damageScreen ();
246
213
    }
247
214
}
248
215