25
25
#include "workspacenames.h"
29
const unsigned short TEXT_BORDER = 2;
34
28
WSNamesScreen::getCurrentWSName ()
38
CompOption::Value::Vector vpNumbers = optionGetViewports ();
39
CompOption::Value::Vector names = optionGetNames ();
41
int currentVp = screen->vp ().y () * screen->vpSize ().width () +
33
CompOption::Value::Vector names;
34
CompOption::Value::Vector vpNumbers;
36
vpNumbers = optionGetViewports ();
37
names = optionGetNames ();
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 ());
45
43
for (int i = 0; i < listSize; i++)
46
44
if (vpNumbers[i].i () == currentVp)
87
86
textData.renderText (name, attrib);
91
WSNamesScreen::getTextPlacementPosition ()
90
WSNamesScreen::drawText (const GLMatrix &matrix)
93
float x, y, border = 10.0f;
93
94
CompRect oe = screen->getCurrentOutputExtents ();
94
float x = oe.centerX () - textData.getWidth () / 2;
96
const float border = TEXT_BORDER;
96
x = oe.centerX () - textData.getWidth () / 2;
98
/* assign y (for the lower corner!) according to the setting */
98
99
switch (optionGetTextPlacement ())
100
101
case WorkspacenamesOptions::TextPlacementCenteredOnScreen:
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 ();
113
114
y = oe.y1 () + workArea.y () +
118
return CompPoint (floor (x),
119
oe.centerY () - textData.getHeight () / 2);
123
return CompPoint (floor (x), floor (y));
127
WSNamesScreen::damageTextArea ()
129
const CompPoint pos (getTextPlacementPosition ());
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);
138
cScreen->damageRegion (area);
142
WSNamesScreen::drawText (const GLMatrix &matrix)
144
GLfloat alpha = 0.0f;
146
/* assign y (for the lower corner!) according to the setting */
147
const CompPoint p = getTextPlacementPosition ();
150
124
alpha = timer / (optionGetFadeTime () * 1000.0f);
151
else if (timeoutHandle.active ())
154
textData.draw (matrix, p.x (), p.y (), alpha);
158
WSNamesScreen::shouldDrawText ()
160
return textData.getWidth () && textData.getHeight ();
128
textData.draw (matrix, floor (x), floor (y), alpha);
167
135
CompOutput *output,
168
136
unsigned int mask)
170
bool status = gScreen->glPaintOutput (attrib, transform, region, output, mask);
172
if (shouldDrawText ())
140
status = gScreen->glPaintOutput (attrib, transform, region, output, mask);
142
if (textData.getWidth () && textData.getHeight ())
174
144
GLMatrix sTransform (transform);
197
170
WSNamesScreen::donePaint ()
199
/* Only damage when the */
200
if (shouldDrawText ())
203
cScreen->donePaint ();
172
/* FIXME: better only damage paint region */
174
cScreen->damageScreen ();
205
/* Clear text data if done with fadeout */
206
if (!timer && !timeoutHandle.active ())
176
cScreen->donePaint ();
211
180
WSNamesScreen::hideTimeout ()
213
182
timer = optionGetFadeTime () * 1000;
215
/* Clear immediately if there is no fadeout */
217
184
textData.clear ();
186
cScreen->damageScreen ();
221
188
timeoutHandle.stop ();