Merge lp:~smspillaz/compiz/compiz..merge-fix-1075578-workspacenames-flickering-during-display.damage_correctly into lp:compiz/0.9.9

Proposed by Sam Spilsbury
Status: Superseded
Proposed branch: lp:~smspillaz/compiz/compiz..merge-fix-1075578-workspacenames-flickering-during-display.damage_correctly
Merge into: lp:compiz/0.9.9
Diff against target: 224 lines (+82/-39)
2 files modified
plugins/workspacenames/src/workspacenames.cpp (+72/-39)
plugins/workspacenames/src/workspacenames.h (+10/-0)
To merge this branch: bzr merge lp:~smspillaz/compiz/compiz..merge-fix-1075578-workspacenames-flickering-during-display.damage_correctly
Reviewer Review Type Date Requested Status
Compiz Maintainers Pending
Review via email: mp+156263@code.launchpad.net

This proposal has been superseded by a proposal from 2013-03-30.

Commit message

Damage the text area correctly. Extract the method used to determine where the text area was into a separate function and use that to determine where our damage area should be. Also fix a few errors that happened on the last frame of animation.

Description of the change

Damage the text area correctly. Extract the method used to determine where the text area was into a separate function and use that to determine where our damage area should be. Also fix a few errors that happened on the last frame of animation.

To post a comment you must log in.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/workspacenames/src/workspacenames.cpp'
2--- plugins/workspacenames/src/workspacenames.cpp 2012-12-04 15:06:12 +0000
3+++ plugins/workspacenames/src/workspacenames.cpp 2013-03-30 14:34:25 +0000
4@@ -24,21 +24,23 @@
5
6 #include "workspacenames.h"
7
8+namespace
9+{
10+ const float TEXT_BORDER = 10.0f;
11+}
12+
13+
14 CompString
15 WSNamesScreen::getCurrentWSName ()
16 {
17- int currentVp;
18- int listSize;
19 CompString ret;
20- CompOption::Value::Vector names;
21- CompOption::Value::Vector vpNumbers;
22-
23- vpNumbers = optionGetViewports ();
24- names = optionGetNames ();
25-
26- currentVp = screen->vp ().y () * screen->vpSize ().width () +
27+
28+ CompOption::Value::Vector vpNumbers = optionGetViewports ();
29+ CompOption::Value::Vector names = optionGetNames ();
30+
31+ int currentVp = screen->vp ().y () * screen->vpSize ().width () +
32 screen->vp ().x () + 1;
33- listSize = MIN (vpNumbers.size (), names.size ());
34+ int listSize = MIN (vpNumbers.size (), names.size ());
35
36 for (int i = 0; i < listSize; i++)
37 if (vpNumbers[i].i () == currentVp)
38@@ -51,11 +53,10 @@
39 WSNamesScreen::renderNameText ()
40 {
41 CompText::Attrib attrib;
42- CompString name;
43
44 textData.clear ();
45
46- name = getCurrentWSName ();
47+ CompString name = getCurrentWSName ();
48
49 if (name.empty ())
50 return;
51@@ -86,16 +87,14 @@
52 textData.renderText (name, attrib);
53 }
54
55-void
56-WSNamesScreen::drawText (const GLMatrix &matrix)
57+CompPoint
58+WSNamesScreen::getTextPlacementPosition ()
59 {
60- GLfloat alpha;
61- float x, y, border = 10.0f;
62 CompRect oe = screen->getCurrentOutputExtents ();
63-
64- x = oe.centerX () - textData.getWidth () / 2;
65-
66- /* assign y (for the lower corner!) according to the setting */
67+ float x = oe.centerX () - textData.getWidth () / 2;
68+ float y = 0;
69+ const float border = TEXT_BORDER;
70+
71 switch (optionGetTextPlacement ())
72 {
73 case WorkspacenamesOptions::TextPlacementCenteredOnScreen:
74@@ -108,7 +107,7 @@
75
76 if (optionGetTextPlacement () ==
77 WorkspacenamesOptions::TextPlacementTopOfScreen)
78- y = oe.y1 () + workArea.y () +
79+ y = oe.y1 () + workArea.y () +
80 (2 * border) + textData.getHeight ();
81 else
82 y = oe.y1 () + workArea.y () +
83@@ -116,16 +115,49 @@
84 }
85 break;
86 default:
87- return;
88+ return CompPoint (floor (x),
89+ oe.centerY () - textData.getHeight () / 2);
90 break;
91 }
92
93+ return CompPoint (floor (x), floor (y));
94+}
95+
96+void
97+WSNamesScreen::damageTextArea ()
98+{
99+ const CompPoint pos (getTextPlacementPosition ());
100+
101+ /* The placement position is from the lower corner, so we
102+ * need to move it back up by height */
103+ CompRect area (pos.x () - TEXT_BORDER,
104+ pos.y () - TEXT_BORDER - textData.getHeight () ,
105+ textData.getWidth () + TEXT_BORDER * 2,
106+ textData.getHeight () + TEXT_BORDER * 2);
107+
108+ cScreen->damageRegion (area);
109+}
110+
111+void
112+WSNamesScreen::drawText (const GLMatrix &matrix)
113+{
114+ GLfloat alpha = 0.0f;
115+
116+ /* assign y (for the lower corner!) according to the setting */
117+ const CompPoint p = getTextPlacementPosition ();
118+
119 if (timer)
120 alpha = timer / (optionGetFadeTime () * 1000.0f);
121- else
122+ else if (timeoutHandle.active ())
123 alpha = 1.0f;
124
125- textData.draw (matrix, floor (x), floor (y), alpha);
126+ textData.draw (matrix, p.x (), p.y (), alpha);
127+}
128+
129+bool
130+WSNamesScreen::shouldDrawText ()
131+{
132+ return textData.getWidth () && textData.getHeight ();
133 }
134
135 bool
136@@ -135,11 +167,9 @@
137 CompOutput *output,
138 unsigned int mask)
139 {
140- bool status;
141-
142- status = gScreen->glPaintOutput (attrib, transform, region, output, mask);
143-
144- if (textData.getWidth () && textData.getHeight ())
145+ bool status = gScreen->glPaintOutput (attrib, transform, region, output, mask);
146+
147+ if (shouldDrawText ())
148 {
149 GLMatrix sTransform (transform);
150
151@@ -158,9 +188,6 @@
152 {
153 timer -= msSinceLastPaint;
154 timer = MAX (timer, 0);
155-
156- if (!timer)
157- textData.clear ();
158 }
159
160 cScreen->preparePaint (msSinceLastPaint);
161@@ -169,21 +196,27 @@
162 void
163 WSNamesScreen::donePaint ()
164 {
165- /* FIXME: better only damage paint region */
166- if (timer)
167- cScreen->damageScreen ();
168+ /* Only damage when the */
169+ if (shouldDrawText ())
170+ damageTextArea ();
171+
172+ cScreen->donePaint ();
173
174- cScreen->donePaint ();
175+ /* Clear text data if done with fadeout */
176+ if (!timer && !timeoutHandle.active ())
177+ textData.clear ();
178 }
179
180 bool
181 WSNamesScreen::hideTimeout ()
182 {
183 timer = optionGetFadeTime () * 1000;
184+
185+ /* Clear immediately if there is no fadeout */
186 if (!timer)
187 textData.clear ();
188-
189- cScreen->damageScreen ();
190+
191+ damageTextArea ();
192
193 timeoutHandle.stop ();
194
195@@ -209,7 +242,7 @@
196 renderNameText ();
197 timeoutHandle.start (timeout, timeout + 200);
198
199- cScreen->damageScreen ();
200+ damageTextArea ();
201 }
202 }
203
204
205=== modified file 'plugins/workspacenames/src/workspacenames.h'
206--- plugins/workspacenames/src/workspacenames.h 2012-06-22 12:27:42 +0000
207+++ plugins/workspacenames/src/workspacenames.h 2013-03-30 14:34:25 +0000
208@@ -79,6 +79,16 @@
209
210 void
211 handleEvent (XEvent *);
212+
213+ CompPoint
214+ getTextPlacementPosition ();
215+
216+ void
217+ damageTextArea ();
218+
219+ private:
220+
221+ bool shouldDrawText ();
222 };
223
224 class WorkspacenamesPluginVTable :

Subscribers

People subscribed via source and target branches