Merge lp:~mc-return/compiz/compiz.merge-thumbnail-improvements into lp:compiz/0.9.10

Proposed by MC Return
Status: Merged
Approved by: MC Return
Approved revision: 3749
Merged at revision: 3759
Proposed branch: lp:~mc-return/compiz/compiz.merge-thumbnail-improvements
Merge into: lp:compiz/0.9.10
Diff against target: 1602 lines (+538/-574)
2 files modified
plugins/thumbnail/src/thumbnail.cpp (+499/-527)
plugins/thumbnail/src/thumbnail.h (+39/-47)
To merge this branch: bzr merge lp:~mc-return/compiz/compiz.merge-thumbnail-improvements
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
MC Return Approve
Sami Jaktholm (community) Approve
Sam Spilsbury Approve
Review via email: mp+170548@code.launchpad.net

Commit message

Thumbnail, cleanup:

Merged if condition checks.
Declaration of variables when they are needed (C++ style).
Removed redundant brackets.
Removed useless "/* Could someone please explain how this works */"
comment.
Removed extern const unsigned short TEXT_DISTANCE, because this
variable does not exist anymore (value is configurable already).
Changed if (something > 0.0) to if (something), 10 times.
Changed pointedWin = 0; to pointedWin = NULL;.
Used centerX () and centerY () abstractions from
compiz::window::Geometry to determine the icon center coordinates.
Added and removed newlines, if appropriate.
Fixed indentation.

Thumbnail, code speedup:

Return ASAP, do not calculate stuff you might not need.
No need for WIN_W (w) and WIN_H (w) macros, removed those and
replaced them with the local variables int winWidth, int winHeight,
int dockWidth and int dockHeight.
No need for WIN_X (w) and WIN_Y (w) macros, replaced those with
int dockX and int dockY.
Introduced int tHeight = thumb.height;, int tWidth = thumb.width;,
int halfTWidth = tWidth / 2; and int halfTHeight =
tHeight / 2; and used those variables in the following calculations.
Use igMidPoint[0] and igMidPoint[1] as arguments in the
screen->outputDeviceForPoint (arg1, arg2) function, instead of re-
calculating the arguments again.

Thumbnail, GL speedup:

Introduced
GLfloat wxPlusWidth = wx + width;,
GLfloat wyPlusHeight = wy + height;,
GLfloat wxPlusWPlusOff = wxPlusWidth + off;,
GLfloat wyPlusHPlusOff = wyPlusHeight + off;,
GLfloat wxMinusOff = wx - off; and
GLfloat wyMinusOff = wy - off;
and used those coordinates in the vertexData arrays. No need to re-
calculate those values multiple times.
Just query optionGetShowDelay () once and use int showDelay later.
We just enable blending if it is currently disabled and disable
blending only, if it was disabled before.

Description of the change

Note:
There is still minor flickering during fade in/out visible with some drivers, which is a regression from r3320 (no bug filed yet).

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) wrote :
Download full text (4.1 KiB)

58 + int x = t->x - t->offset;
59 + int y = t->y - t->offset;
60 + int width = t->width + t->offset * 2;
61 + int height = t->height + t->offset * 2;
62 +
63 + CompRect rect (x, y, width, height);

As 63 does something very different with the data computed from 58 to 61, there is no need for horizontal alignment.

101 - tw->cWindow->damageRectSetEnabled (tw, false);
102 - tw->gWindow->glPaintSetEnabled (tw, false);
103 + tw->cWindow->damageRectSetEnabled (tw, false);
104 + tw->gWindow->glPaintSetEnabled (tw, false);
105 tw->window->resizeNotifySetEnabled (tw, false);

There is no need for horizontal whitespacing here. The variables on these lines are not related at all.

176 + igMidPoint[0] = w->iconGeometry ().x () + w->iconGeometry ().width () / 2;
177 + igMidPoint[1] = w->iconGeometry ().y () + w->iconGeometry ().height () / 2;

Prefer using the centerX () and centerY () abstractions in compiz::window::Geometry

244 + int dockX = dock->x () - dock->border ().left;
245 + int dockY = dock->y () - dock->border ().top;
246 +
247 + int dockWidth = dock->width () + dock->border ().left + dock->border ().right;
248 + int dockHeight = dock->height () + dock->border ().top + dock->border ().bottom;

Consider removing the vertical whitespace if these are related

1115 + GLushort color[4];
1116 + int addWindowGeometryIndex;
1117 + int wx = t->x;
1118 + int wy = t->y;
1119 +
1120 + GLWindowPaintAttrib sAttrib;
1121 + unsigned int mask = PAINT_WINDOW_TRANSFORMED_MASK |
1122 + PAINT_WINDOW_TRANSLUCENT_MASK;
1123 + GLWindow *gWindow = GLWindow::get (w);

A lot of these variables are not related, and so the alignemnt makes no sense. Suggestion:

GLWindow *gWindow = GLWindow::get (window);

GLushort color[4];

int wx = t->x;
int wy = t->y;

GLWindowPaintAttrib sAttrib;
unsigned int mask = PAINT_WINDOW_TRANSFORMED_MASK | PAINT_WINDOW_TRANSLUCENT_MASK
unsigned int addWindowGeometryIndex = gWindow->glAddGeometryGetCurrentIndex ();

1184 + GLenum filter = gScreen->textureFilter ();
1185 + bool filterChanged = false;
202 + /* only set back the global filter
1203 + * if we changed it before */
1204 + if (filterChanged)
1205 + gScreen->setTextureFilter (filter);

This isn't necessary anymore.

1357 + if (ts->thumb.win == window && ts->thumb.opacity > 0.0)

There's no need for all that whitespace between "ts->thumb.win" and "== window" and likewise for "> 0.0"

1373 + gScreen (GLScreen::get (screen)),
1374 + cScreen (CompositeScreen::get (screen)),
1375 + dock (NULL),
1376 + pointedWin (NULL),
1377 + showingThumb (false),
1378 + painted (false),
1379 + glowTexture (GLTexture::imageDataToTexture
1380 + (glowTex, CompSize (32, 32), GL_RGBA, GL_UNSIGNED_BYTE)),

See other comments about whitespace alignment in constructors and how it doesn't make sense.

1414 - WindowInterface::setHandler (window, false);
1415 + WindowInterface::setHandler (window, false);
141...

Read more...

review: Needs Fixing
Revision history for this message
MC Return (mc-return) wrote :
Download full text (5.1 KiB)

> 58 + int x = t->x - t->offset;
> 59 + int y = t->y - t->offset;
> 60 + int width = t->width + t->offset * 2;
> 61 + int height = t->height + t->offset * 2;
> 62 +
> 63 + CompRect rect (x, y, width, height);
>
> As 63 does something very different with the data computed from 58 to 61,
> there is no need for horizontal alignment.
>
Fixed in r3743.

> 101 - tw->cWindow->damageRectSetEnabled (tw, false);
> 102 - tw->gWindow->glPaintSetEnabled (tw, false);
> 103 + tw->cWindow->damageRectSetEnabled (tw, false);
> 104 + tw->gWindow->glPaintSetEnabled (tw, false);
> 105 tw->window->resizeNotifySetEnabled (tw, false);
>
> There is no need for horizontal whitespacing here. The variables on these
> lines are not related at all.
>
Fixed in r3743.

> 176 + igMidPoint[0] = w->iconGeometry ().x () + w->iconGeometry
> ().width () / 2;
> 177 + igMidPoint[1] = w->iconGeometry ().y () + w->iconGeometry
> ().height () / 2;
>
> Prefer using the centerX () and centerY () abstractions in
> compiz::window::Geometry
>
Not yet fixed. TODO.

> 244 + int dockX = dock->x () - dock->border ().left;
> 245 + int dockY = dock->y () - dock->border ().top;
> 246 +
> 247 + int dockWidth = dock->width () + dock->border ().left +
> dock->border ().right;
> 248 + int dockHeight = dock->height () + dock->border ().top +
> dock->border ().bottom;
>
> Consider removing the vertical whitespace if these are related
>
Fixed in r3743.

> 1115 + GLushort color[4];
> 1116 + int addWindowGeometryIndex;
> 1117 + int wx = t->x;
> 1118 + int wy = t->y;
> 1119 +
> 1120 + GLWindowPaintAttrib sAttrib;
> 1121 + unsigned int mask = PAINT_WINDOW_TRANSFORMED_MASK |
> 1122 + PAINT_WINDOW_TRANSLUCENT_MASK;
> 1123 + GLWindow *gWindow = GLWindow::get (w);
>
> A lot of these variables are not related, and so the alignemnt makes no sense.
> Suggestion:
>
> GLWindow *gWindow = GLWindow::get (window);
>
> GLushort color[4];
>
> int wx = t->x;
> int wy = t->y;
>
> GLWindowPaintAttrib sAttrib;
> unsigned int mask = PAINT_WINDOW_TRANSFORMED_MASK |
> PAINT_WINDOW_TRANSLUCENT_MASK
> unsigned int addWindowGeometryIndex =
> gWindow->glAddGeometryGetCurrentIndex ();
>
Fixed in r3743.

> 1184 + GLenum filter = gScreen->textureFilter ();
> 1185 + bool filterChanged = false;
> 202 + /* only set back the global filter
> 1203 + * if we changed it before */
> 1204 + if (filterChanged)
> 1205 + gScreen->setTextureFilter (filter);
>
> This isn't necessary anymore.
>
Question: Why ? How do we set back the GL_filter state if we changed it ?
I am sorry that I still don't fully get it, it seems...

> 1357 + if (ts->thumb.win == window && ts->thumb.opacity > 0.0)
>
> There's no need for all that whitespace between "ts->thumb.win" and "==
> window" and likewise for "> ...

Read more...

Revision history for this message
MC Return (mc-return) wrote :

I'll try to further improve thumbnail as there is still some room for optimization...

Revision history for this message
MC Return (mc-return) wrote :

> 1184 + GLenum filter = gScreen->textureFilter ();
> 1185 + bool filterChanged = false;
> 202 + /* only set back the global filter
> 1203 + * if we changed it before */
> 1204 + if (filterChanged)
> 1205 + gScreen->setTextureFilter (filter);
>
> This isn't necessary anymore.
>
Question: Why ? How do we set back the GL_filter state if we changed it ?
I am sorry that I still don't fully get it, it seems...

review: Needs Information
Revision history for this message
MC Return (mc-return) wrote :

Sam, I think I got them all now (except the filter-change that still needs info)... ;)

review: Needs Resubmitting
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Re: filter. As I mentioned earlier, the filter is only changed at the time a texture is bound. As such calling setTextureFilter does not result in any calls into opengl.

Revision history for this message
MC Return (mc-return) wrote :

> Re: filter. As I mentioned earlier, the filter is only changed at the time a
> texture is bound. As such calling setTextureFilter does not result in any
> calls into opengl.

I guess I need some example code to understand. Even if the filter change will just get applied the next time a texture gets bound, we still need to set back the filter to its previous state, or otherwise we would mess with the user's OpenGL filter settings...
Btw, here you approved the same solution: http://bazaar.launchpad.net/~compiz-team/compiz/0.9.10/revision/3740

To me that makes sense, we cannot simply change the filter on a per-plugin basis, if we do not know what the global filter is set to... but maybe I still do not get it, maybe just those open bug reports about broken mipmapping are making me nervous, see:

bug #1020818 [regression][GLES] mipmapping doesn't work at all any more
bug #1016364 Mipmap support broken

or

bug #913521 After using mipmaps for effects, windows stop refreshing

At least I cannot reproduce the last one of them for sure, not sure about the former 2 though...

review: Needs Information
Revision history for this message
MC Return (mc-return) wrote :

/offtopic on

Sam, another unrelated, but open quite important question I have is how to find out if a specific plugin is enabled/running, something like:

bool
isPluginRunning (name)

Do we have something like this ?

/offtopic off

review: Needs Information
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
MC Return (mc-return) wrote :

99% tests passed, 1 tests failed out of 1500

Total Test time (real) = 2562.04 sec

The following tests FAILED:
 1478 - CompizXorgSystemStackingTest.TestCreateWindowsAndRestackRelativeToEachOtherDockAlwaysOnTop (Failed)

This has nothing to do with this branch, Jenkins...

review: Needs Resubmitting
Revision history for this message
Sam Spilsbury (smspillaz) wrote :
Download full text (4.5 KiB)

As I've mentioned before, all these changes are fine. The only one that needs to be removed is the filter-save-restore as it is redundant.

1247 + GLenum filter = gScreen->textureFilter ();
1248 + bool filterChanged = false;
1249 +
1250 + /* we just need to change the texture filter, if
1251 + * thumbnail mipmapping is enabled */
1252 if (optionGetMipmap ())
1253 + {
1254 gScreen->setTextureFilter (GL_LINEAR_MIPMAP_LINEAR);
1255 + filterChanged = true;
1256 + }
1257
1258 wTransform.translate (w->x (), w->y (), 0.0f);
1259 wTransform.scale (sAttrib.xScale, sAttrib.yScale, 1.0f);
1260 @@ -932,7 +914,10 @@
1261 gWindow->glAddGeometrySetCurrentIndex (MAXSHORT);
1262 gWindow->glDraw (wTransform, sAttrib, infiniteRegion, mask);
1263
1264 - gScreen->setTextureFilter (filter);
1265 + /* only set back the global filter
1266 + * if we changed it before */
1267 + if (filterChanged)
1268 + gScreen->setTextureFilter (filter);

Answering your other questions

> 99% tests passed, 1 tests failed out of 1500

> Total Test time (real) = 2562.04 sec

> The following tests FAILED:
> 1478 - CompizXorgSystemStackingTest.TestCreateWindowsAndRestackRelativeToEachOtherDockAlwaysOnTop (Failed)

> This has nothing to do with this branch, Jenkins...

Unfortunately there is a race condition in our jenkins infrastructure which makes sporadic failures of these tests possible. The tests are not sandboxed and instead run on the same worker in parallel. Our testing framework does the best it can to avoid this by selecting another X connection to run on if there is already a server running on the selected display - but it is not perfect as test runs 1 and 2 can pick the same display number if neither of them saw that the display was in use at the same time. This generally causes one of the servers to either crash, or causes both tests to interfere with each other.

Just resubmit if that happens and jenkins will run again.

> I guess I need some example code to understand. Even if the filter change will just get applied the next time a texture gets bound, we still need to set back the filter to its previous state, or otherwise we would mess with the user's OpenGL filter settings...

We already do that.

GLint filter = gScreen->textureFilter ();

...
gScreen->setTextureFilter (GL_LINEAR_MIPMAP_LINEAR);
...
gScreen->setTextureFilter (filter);

The point I'm trying to make is this - you don't need to check if the filter has changed in order to change it back. Just change it back. setTextureFilter does not result in any calls to OpenGL. The call is delayed until the point at which a texture is bound. This means that the following:

gScreen->setTextureFilter (...)
texture->activate (); <-
gScreen->setTextureFilter (...)

Will only result in a single call to OpenGL, because the desired state is cached and applied only at the bind point.

> Btw, here you approved the same solution: http://bazaar.launchpad.net/~compiz-team/compiz/0.9.10/revision/3740

That was a mistake on my behalf. A mostly harmless mistake, but a mistake nonetheless.

> To me that makes sense, we cannot simply change the filter on a per-plugin basis, if we do not know what the ...

Read more...

review: Needs Fixing
Revision history for this message
MC Return (mc-return) wrote :

Thanks a lot 4 taking the time and explaining the mipmap stuff in detail. Now this makes a lot more sense to me.

I will fix the mipmap stuff accordingly in this MP and will propose another MP fixing the wrong mipmap handling of Expo.

Revision history for this message
MC Return (mc-return) :
review: Needs Resubmitting
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Will merge this after 0.9.10

review: Approve
Revision history for this message
MC Return (mc-return) wrote :

> Will merge this after 0.9.10

Now it seems to me that the release is not far away ?
Our blueprint for 0.9.10 says it is still a long and winding road to 0.9.10 (still a lot of bugs open there)...
My impression from my past involvement was that the release would happen around end of August or some time in September ?

/me is confused a bit now...

review: Needs Information
Revision history for this message
MC Return (mc-return) wrote :

Note:
Sam, you reviewed this already up to r3747.
All I did afterwards was fixing the filter stuff according to my new understanding of things (thanks again 4 your explanations).
I do not think that Compiz really has time for delays...

Also (regarding the release):
I do not agree that we ship/release stuff that we know is broken, examples for this are: td, session, dbus.
We should exclude those from compilation, before we release. It makes no sense to release broken stuff.

Revision history for this message
Sami Jaktholm (sjakthol) wrote :

No functional changes. Can't test this is action but the changes look good to me.

review: Approve
Revision history for this message
MC Return (mc-return) wrote :

Thanks, Sami. Merging it.

Revision history for this message
MC Return (mc-return) wrote :

No, I'll wait for Sam, because of his comment above...

Revision history for this message
MC Return (mc-return) wrote :

Trunk is unblocked.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/thumbnail/src/thumbnail.cpp'
2--- plugins/thumbnail/src/thumbnail.cpp 2013-05-09 13:43:07 +0000
3+++ plugins/thumbnail/src/thumbnail.cpp 2013-06-28 14:26:23 +0000
4@@ -33,7 +33,7 @@
5 COMPIZ_PLUGIN_20090315 (thumbnail, ThumbPluginVTable);
6
7 void
8-ThumbScreen::freeThumbText (Thumbnail *t)
9+ThumbScreen::freeThumbText (Thumbnail *t)
10 {
11 if (!t->text)
12 return;
13@@ -43,20 +43,20 @@
14 }
15
16 void
17-ThumbScreen::renderThumbText (Thumbnail *t,
18- bool freeThumb)
19+ThumbScreen::renderThumbText (Thumbnail *t,
20+ bool freeThumb)
21 {
22 if (!textPluginLoaded)
23 return;
24
25- CompText::Attrib tA;
26-
27 if (freeThumb || !t->text)
28 {
29 freeThumbText (t);
30 t->text = new CompText ();
31 }
32
33+ CompText::Attrib tA;
34+
35 tA.maxWidth = t->width;
36 tA.maxHeight = 100;
37
38@@ -74,8 +74,10 @@
39 tA.color[2] = optionGetFontColorBlue ();
40 tA.color[3] = optionGetFontColorAlpha ();
41 tA.flags = CompText::WithBackground | CompText::Ellipsized;
42+
43 if (optionGetFontBold ())
44 tA.flags |= CompText::StyleBold;
45+
46 tA.family = "Sans";
47
48 t->textValid = t->text->renderWindowTitle (t->win->id (), false, tA);
49@@ -84,11 +86,12 @@
50 void
51 ThumbScreen::damageThumbRegion (Thumbnail *t)
52 {
53- int x = t->x - t->offset;
54- int y = t->y - t->offset;
55- int width = t->width + (t->offset * 2);
56- int height = t->height + (t->offset * 2);
57- CompRect rect (x, y, width, height);
58+ int x = t->x - t->offset;
59+ int y = t->y - t->offset;
60+ int width = t->width + t->offset * 2;
61+ int height = t->height + t->offset * 2;
62+
63+ CompRect rect (x, y, width, height);
64
65 if (t->text)
66 rect.setHeight (rect.height () + t->text->getHeight () + optionGetTextDistance ());
67@@ -105,20 +108,8 @@
68 void
69 ThumbScreen::thumbUpdateThumbnail ()
70 {
71- int igMidPoint[2], tMidPoint[2];
72- int tPos[2], tmpPos[2];
73- float distance = 1000000;
74- int off, oDev, tHeight;
75- CompRect oGeom;
76- float maxSize = optionGetThumbSize ();
77- double scale = 1.0;
78- ThumbWindow *tw;
79- CompWindow *w;
80-
81- if (thumb.win == pointedWin)
82- return;
83-
84- if (thumb.opacity > 0.0 && oldThumb.opacity > 0.0)
85+ if (thumb.win == pointedWin ||
86+ (thumb.opacity && oldThumb.opacity))
87 return;
88
89 if (thumb.win)
90@@ -126,6 +117,8 @@
91
92 freeThumbText (&oldThumb);
93
94+ ThumbWindow *tw;
95+
96 if (oldThumb.win)
97 {
98 tw = ThumbWindow::get (oldThumb.win);
99@@ -136,36 +129,42 @@
100 tw->window->resizeNotifySetEnabled (tw, false);
101 }
102
103- oldThumb = thumb;
104- thumb.text = NULL;
105- thumb.win = pointedWin;
106- thumb.dock = dock;
107+ oldThumb = thumb;
108+ thumb.text = NULL;
109+ thumb.win = pointedWin;
110+ thumb.dock = dock;
111
112 if (!thumb.win || !dock)
113 {
114 thumb.win = NULL;
115- thumb.dock = NULL;
116+ thumb.dock = NULL;
117 return;
118 }
119
120- w = thumb.win;
121+ CompWindow *w = thumb.win;
122 tw = ThumbWindow::get (w);
123
124 tw->cWindow->damageRectSetEnabled (tw, true);
125 tw->gWindow->glPaintSetEnabled (tw, true);
126 tw->window->resizeNotifySetEnabled (tw, true);
127
128- /* do we nee to scale the window down? */
129- if (WIN_W (w) > maxSize || WIN_H (w) > maxSize)
130+ float maxSize = optionGetThumbSize ();
131+ double scale = 1.0;
132+
133+ int winWidth = w->width () + w->border ().left + w->border ().right;
134+ int winHeight = w->height () + w->border ().top + w->border ().bottom;
135+
136+ /* do we need to scale the window down? */
137+ if (winWidth > maxSize || winHeight > maxSize)
138 {
139- if (WIN_W (w) >= WIN_H (w))
140- scale = maxSize / WIN_W (w);
141+ if (winWidth >= winHeight)
142+ scale = maxSize / winWidth;
143 else
144- scale = maxSize / WIN_H (w);
145+ scale = maxSize / winHeight;
146 }
147
148- thumb.width = WIN_W (w)* scale;
149- thumb.height = WIN_H (w) * scale;
150+ thumb.width = winWidth * scale;
151+ thumb.height = winHeight * scale;
152 thumb.scale = scale;
153
154 if (optionGetTitleEnabled ())
155@@ -173,33 +172,35 @@
156 else
157 freeThumbText (&thumb);
158
159- igMidPoint[0] = w->iconGeometry ().x () + (w->iconGeometry ().width () / 2);
160- igMidPoint[1] = w->iconGeometry ().y () + (w->iconGeometry ().height () / 2);
161-
162- off = optionGetBorder ();
163- oDev = screen->outputDeviceForPoint (w->iconGeometry ().x () +
164- (w->iconGeometry ().width () / 2),
165- w->iconGeometry ().y () +
166- (w->iconGeometry ().height () / 2));
167+ int igMidPoint[2], tMidPoint[2];
168+
169+ igMidPoint[0] = w->iconGeometry ().centerX ();
170+ igMidPoint[1] = w->iconGeometry ().centerY ();
171+
172+ int off = optionGetBorder ();
173+ int oDev = screen->outputDeviceForPoint (igMidPoint[0],
174+ igMidPoint[1]);
175+
176+ CompRect oGeom;
177
178 if (screen->outputDevs ().size () == 1 ||
179- (unsigned int) oDev > screen->outputDevs ().size ())
180- {
181+ (unsigned int) oDev > screen->outputDevs ().size ())
182 oGeom.setGeometry (0, 0, screen->width (), screen->height ());
183- }
184 else
185- {
186 oGeom = screen->outputDevs ()[oDev];
187- }
188-
189- tHeight = thumb.height;
190+
191+ int tHeight = thumb.height;
192+ int tWidth = thumb.width;
193+
194 if (thumb.text)
195 tHeight += thumb.text->getHeight () + optionGetTextDistance ();
196
197- /* Could someone please explain how this works */
198+ int halfTWidth = tWidth / 2;
199+ int halfTHeight = tHeight / 2;
200+ int tPos[2], tmpPos[2];
201
202 // failsave position
203- tPos[0] = igMidPoint[0] - (thumb.width / 2.0);
204+ tPos[0] = igMidPoint[0] - halfTWidth;
205
206 if (w->iconGeometry ().y () - tHeight >= 0)
207 tPos[1] = w->iconGeometry ().y () - tHeight;
208@@ -207,23 +208,30 @@
209 tPos[1] = w->iconGeometry ().y () + w->iconGeometry ().height ();
210
211 // above
212- tmpPos[0] = igMidPoint[0] - (thumb.width / 2.0);
213+ tmpPos[0] = igMidPoint[0] - halfTWidth;
214
215 if (tmpPos[0] - off < oGeom.x1 ())
216 tmpPos[0] = oGeom.x1 () + off;
217
218- if (tmpPos[0] + off + thumb.width > oGeom.x2 ())
219+ if (tmpPos[0] + off + tWidth > oGeom.x2 ())
220 {
221- if (thumb.width + (2 * off) <= oGeom.width ())
222- tmpPos[0] = oGeom.x2 () - thumb.width - off;
223+ if (tWidth + (2 * off) <= oGeom.width ())
224+ tmpPos[0] = oGeom.x2 () - tWidth - off;
225 else
226 tmpPos[0] = oGeom.x1 () + off;
227 }
228
229- tMidPoint[0] = tmpPos[0] + (thumb.width / 2.0);
230-
231- tmpPos[1] = WIN_Y (dock) - tHeight - off;
232- tMidPoint[1] = tmpPos[1] + (tHeight / 2.0);
233+ tMidPoint[0] = tmpPos[0] + halfTWidth;
234+
235+ int dockX = dock->x () - dock->border ().left;
236+ int dockY = dock->y () - dock->border ().top;
237+ int dockWidth = dock->width () + dock->border ().left + dock->border ().right;
238+ int dockHeight = dock->height () + dock->border ().top + dock->border ().bottom;
239+
240+ tmpPos[1] = dockY - tHeight - off;
241+ tMidPoint[1] = tmpPos[1] + halfTHeight;
242+
243+ float distance = 1000000;
244
245 if (tmpPos[1] > oGeom.y1 ())
246 {
247@@ -233,9 +241,9 @@
248 }
249
250 // below
251- tmpPos[1] = WIN_Y (dock) + WIN_H (dock) + off;
252+ tmpPos[1] = dockY + dockHeight + off;
253
254- tMidPoint[1] = tmpPos[1] + (tHeight / 2.0);
255+ tMidPoint[1] = tmpPos[1] + halfTHeight;
256
257 if (tmpPos[1] + tHeight + off < oGeom.y2 () &&
258 GET_DISTANCE (igMidPoint, tMidPoint) < distance)
259@@ -246,7 +254,7 @@
260 }
261
262 // left
263- tmpPos[1] = igMidPoint[1] - (tHeight / 2.0);
264+ tmpPos[1] = igMidPoint[1] - halfTHeight;
265
266 if (tmpPos[1] - off < oGeom.y1 ())
267 tmpPos[1] = oGeom.y1 () + off;
268@@ -254,15 +262,14 @@
269 if (tmpPos[1] + off + tHeight > oGeom.y2 ())
270 {
271 if (tHeight + (2 * off) <= oGeom.height ())
272- tmpPos[1] = oGeom.y2 () - thumb.height - off;
273+ tmpPos[1] = oGeom.y2 () - tHeight - off;
274 else
275 tmpPos[1] = oGeom.y1 () + off;
276 }
277
278- tMidPoint[1] = tmpPos[1] + (tHeight / 2.0);
279-
280- tmpPos[0] = WIN_X (dock) - thumb.width - off;
281- tMidPoint[0] = tmpPos[0] + (thumb.width / 2.0);
282+ tMidPoint[1] = tmpPos[1] + halfTHeight;
283+ tmpPos[0] = dockX - tWidth - off;
284+ tMidPoint[0] = tmpPos[0] + halfTWidth;
285
286 if (tmpPos[0] > oGeom.x1 () && GET_DISTANCE (igMidPoint, tMidPoint) < distance)
287 {
288@@ -272,11 +279,11 @@
289 }
290
291 // right
292- tmpPos[0] = WIN_X (dock) + WIN_W (dock) + off;
293-
294- tMidPoint[0] = tmpPos[0] + (thumb.width / 2.0);
295-
296- if (tmpPos[0] + thumb.width + off < oGeom.x2 () &&
297+ tmpPos[0] = dockX + dockWidth + off;
298+
299+ tMidPoint[0] = tmpPos[0] + halfTWidth;
300+
301+ if (tmpPos[0] + tWidth + off < oGeom.x2 () &&
302 GET_DISTANCE (igMidPoint, tMidPoint) < distance)
303 {
304 tPos[0] = tmpPos[0];
305@@ -298,7 +305,7 @@
306 bool
307 ThumbScreen::thumbShowThumbnail ()
308 {
309- showingThumb = true;
310+ showingThumb = true;
311
312 thumbUpdateThumbnail ();
313 damageThumbRegion (&thumb);
314@@ -310,15 +317,11 @@
315 ThumbScreen::checkPosition (CompWindow *w)
316 {
317 if (optionGetCurrentViewport ())
318- {
319- if (w->serverX () >= screen->width () ||
320- w->serverX () + w->serverWidth () <= 0 ||
321- w->serverY () >= screen->height () ||
322+ if (w->serverX () >= screen->width () ||
323+ w->serverX () + w->serverWidth () <= 0 ||
324+ w->serverY () >= screen->height () ||
325 w->serverY () + w->serverHeight () <= 0)
326- {
327 return false;
328- }
329- }
330
331 return true;
332 }
333@@ -332,25 +335,13 @@
334 {
335 THUMB_WINDOW (cw);
336
337- if (cw->destroyed ())
338- continue;
339-
340- if (cw->iconGeometry ().isEmpty ())
341- continue;
342-
343- if (!cw->isMapped ())
344- continue;
345-
346- if (cw->state () & CompWindowStateSkipTaskbarMask)
347- continue;
348-
349- if (cw->state () & CompWindowStateSkipPagerMask)
350- continue;
351-
352- if (!cw->managed ())
353- continue;
354-
355- if (!tw->cWindow->pixmap ())
356+ if (cw->destroyed () ||
357+ cw->iconGeometry ().isEmpty () ||
358+ !cw->isMapped () ||
359+ cw->state () & CompWindowStateSkipTaskbarMask ||
360+ cw->state () & CompWindowStateSkipPagerMask ||
361+ !cw->managed () ||
362+ !tw->cWindow->pixmap ())
363 continue;
364
365 if (cw->iconGeometry ().contains (p) &&
366@@ -363,41 +354,35 @@
367
368 if (found)
369 {
370+ int showDelay = optionGetShowDelay ();
371+
372 if (!showingThumb &&
373 !(thumb.opacity != 0.0 && thumb.win == found))
374 {
375 if (displayTimeout.active ())
376-
377 {
378 if (pointedWin != found)
379 {
380 displayTimeout.stop ();
381- displayTimeout.start (boost::bind
382- (&ThumbScreen::thumbShowThumbnail,
383- this),
384- optionGetShowDelay (),
385- optionGetShowDelay () + 500);
386+ displayTimeout.start (boost::bind (&ThumbScreen::thumbShowThumbnail,
387+ this), showDelay, showDelay + 500);
388 }
389 }
390 else
391 {
392- displayTimeout.stop ();
393- displayTimeout.start (boost::bind (&ThumbScreen::thumbShowThumbnail,
394- this),
395- optionGetShowDelay (),
396- optionGetShowDelay () + 500);
397+ displayTimeout.stop ();
398+ displayTimeout.start (boost::bind (&ThumbScreen::thumbShowThumbnail,
399+ this), showDelay, showDelay + 500);
400 }
401- }
402+ }
403
404- pointedWin = found;
405- thumbUpdateThumbnail ();
406+ pointedWin = found;
407+ thumbUpdateThumbnail ();
408 }
409 else
410 {
411 if (displayTimeout.active ())
412- {
413 displayTimeout.stop ();
414- }
415
416 pointedWin = NULL;
417 showingThumb = false;
418@@ -407,12 +392,11 @@
419 }
420 }
421
422-
423 void
424-ThumbWindow::resizeNotify (int dx,
425- int dy,
426- int dwidth,
427- int dheight)
428+ThumbWindow::resizeNotify (int dx,
429+ int dy,
430+ int dwidth,
431+ int dheight)
432 {
433 THUMB_SCREEN (screen);
434
435@@ -422,96 +406,82 @@
436 }
437
438 void
439-ThumbScreen::handleEvent (XEvent * event)
440+ThumbScreen::handleEvent (XEvent *event)
441 {
442-
443 screen->handleEvent (event);
444
445 CompWindow *w;
446
447 switch (event->type)
448 {
449- case PropertyNotify:
450- if (event->xproperty.atom == Atoms::wmName)
451- {
452- w = screen->findWindow (event->xproperty.window);
453+ case PropertyNotify:
454+ if (event->xproperty.atom == Atoms::wmName)
455+ {
456+ w = screen->findWindow (event->xproperty.window);
457
458- if (w)
459- {
460- if (thumb.win == w && optionGetTitleEnabled ())
461+ if (w && thumb.win == w && optionGetTitleEnabled ())
462 renderThumbText (&thumb, true);
463 }
464- }
465- break;
466-
467- case ButtonPress:
468+
469+ break;
470+
471+ case ButtonPress:
472 {
473-
474 if (displayTimeout.active ())
475- {
476 displayTimeout.stop ();
477- }
478
479- pointedWin = 0;
480+ pointedWin = NULL;
481 showingThumb = false;
482 }
483- break;
484-
485- case EnterNotify:
486- w = screen->findWindow (event->xcrossing.window);
487- if (w)
488- {
489- if (w->wmType () & CompWindowTypeDockMask)
490+ break;
491+
492+ case EnterNotify:
493+ w = screen->findWindow (event->xcrossing.window);
494+
495+ if (w)
496 {
497- if (dock != w)
498- {
499- dock = w;
500+ if (w->wmType () & CompWindowTypeDockMask)
501+ {
502+ if (dock != w)
503+ {
504+ dock = w;
505+
506+ if (displayTimeout.active ())
507+ displayTimeout.stop ();
508+
509+ pointedWin = NULL;
510+ showingThumb = false;
511+ }
512+
513+ if (!poller.active ())
514+ poller.start ();
515+ }
516+ else
517+ {
518+ dock = NULL;
519
520 if (displayTimeout.active ())
521- {
522 displayTimeout.stop ();
523- }
524
525 pointedWin = NULL;
526 showingThumb = false;
527- }
528-
529- if (!poller.active ())
530- {
531- poller.start ();
532- }
533- }
534- else
535- {
536- dock = NULL;
537-
538- if (displayTimeout.active ())
539- {
540- displayTimeout.stop ();
541- }
542-
543- pointedWin = NULL;
544- showingThumb = false;
545-
546- if (poller.active ())
547- {
548- poller.stop ();
549- }
550- }
551- }
552- break;
553- case LeaveNotify:
554- w = screen->findWindow (event->xcrossing.window);
555- if (w)
556- {
557- if (w->wmType () & CompWindowTypeDockMask)
558- {
559- dock = NULL;
560-
561- if (displayTimeout.active ())
562- {
563- displayTimeout.stop ();
564- }
565+
566+ if (poller.active ())
567+ poller.stop ();
568+ }
569+ }
570+
571+ break;
572+
573+ case LeaveNotify:
574+ w = screen->findWindow (event->xcrossing.window);
575+
576+ if (w && (w->wmType () & CompWindowTypeDockMask))
577+ {
578+ dock = NULL;
579+
580+ if (displayTimeout.active ())
581+ displayTimeout.stop ();
582
583 pointedWin = NULL;
584 showingThumb = false;
585@@ -520,32 +490,35 @@
586 cScreen->donePaintSetEnabled (this, true);
587
588 if (poller.active ())
589- {
590 poller.stop ();
591- }
592-
593-
594 }
595- }
596- break;
597-
598- default:
599- break;
600+
601+ break;
602+
603+ default:
604+ break;
605 }
606 }
607
608-
609 void
610 ThumbScreen::paintTexture (const GLMatrix &transform,
611- GLushort *color,
612- int wx,
613- int wy,
614- int width,
615- int height,
616- int off)
617+ GLushort *color,
618+ int wx,
619+ int wy,
620+ int width,
621+ int height,
622+ int off)
623 {
624- GLfloat textureData[8];
625- GLfloat vertexData[12];
626+ GLfloat textureData[8];
627+ GLfloat vertexData[12];
628+
629+ GLfloat wxPlusWidth = wx + width;
630+ GLfloat wyPlusHeight = wy + height;
631+ GLfloat wxPlusWPlusOff = wxPlusWidth + off;
632+ GLfloat wyPlusHPlusOff = wyPlusHeight + off;
633+ GLfloat wxMinusOff = wx - off;
634+ GLfloat wyMinusOff = wy - off;
635+
636 GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
637
638 streamingBuffer->begin (GL_TRIANGLE_STRIP);
639@@ -557,13 +530,13 @@
640 vertexData[1] = wy;
641 vertexData[2] = 0;
642 vertexData[3] = wx;
643- vertexData[4] = wy + height;
644+ vertexData[4] = wyPlusHeight;
645 vertexData[5] = 0;
646- vertexData[6] = wx + width;
647+ vertexData[6] = wxPlusWidth;
648 vertexData[7] = wy;
649 vertexData[8] = 0;
650- vertexData[9] = wx + width;
651- vertexData[10] = wy + height;
652+ vertexData[9] = wxPlusWidth;
653+ vertexData[10] = wyPlusHeight;
654 vertexData[11] = 0;
655
656 streamingBuffer->addTexCoords (0, 1, textureData);
657@@ -573,253 +546,245 @@
658 streamingBuffer->end ();
659 streamingBuffer->render (transform);
660
661-
662- streamingBuffer->begin (GL_TRIANGLE_STRIP);
663-
664- textureData[0] = 0;
665- textureData[1] = 0;
666- textureData[2] = 0;
667- textureData[3] = 1;
668- textureData[4] = 1;
669- textureData[5] = 0;
670- textureData[6] = 1;
671- textureData[7] = 1;
672-
673- vertexData[0] = wx - off;
674- vertexData[1] = wy - off;
675- vertexData[2] = 0;
676- vertexData[3] = wx - off;
677- vertexData[4] = wy;
678- vertexData[5] = 0;
679- vertexData[6] = wx;
680- vertexData[7] = wy - off;
681- vertexData[8] = 0;
682- vertexData[9] = wx;
683- vertexData[10] = wy;
684- vertexData[11] = 0;
685-
686- streamingBuffer->addTexCoords (0, 4, textureData);
687- streamingBuffer->addVertices (4, vertexData);
688- streamingBuffer->addColors (1, color);
689-
690- streamingBuffer->end ();
691- streamingBuffer->render (transform);
692-
693-
694- streamingBuffer->begin (GL_TRIANGLE_STRIP);
695-
696- textureData[0] = 1;
697- textureData[1] = 0;
698- textureData[2] = 1;
699- textureData[3] = 1;
700- textureData[4] = 0;
701- textureData[5] = 0;
702- textureData[6] = 0;
703- textureData[7] = 1;
704-
705- vertexData[0] = wx + width;
706- vertexData[1] = wy - off;
707- vertexData[2] = 0;
708- vertexData[3] = wx + width;
709- vertexData[4] = wy;
710- vertexData[5] = 0;
711- vertexData[6] = wx + width + off;
712- vertexData[7] = wy - off;
713- vertexData[8] = 0;
714- vertexData[9] = wx + width + off;
715- vertexData[10] = wy;
716- vertexData[11] = 0;
717-
718- streamingBuffer->addTexCoords (0, 4, textureData);
719- streamingBuffer->addVertices (4, vertexData);
720- streamingBuffer->addColors (1, color);
721-
722- streamingBuffer->end ();
723- streamingBuffer->render (transform);
724-
725-
726- streamingBuffer->begin (GL_TRIANGLE_STRIP);
727-
728- textureData[0] = 0;
729- textureData[1] = 1;
730- textureData[2] = 0;
731- textureData[3] = 0;
732- textureData[4] = 1;
733- textureData[5] = 1;
734- textureData[6] = 1;
735- textureData[7] = 0;
736-
737- vertexData[0] = wx - off;
738- vertexData[1] = wy + height;
739- vertexData[2] = 0;
740- vertexData[3] = wx - off;
741- vertexData[4] = wy + height + off;
742- vertexData[5] = 0;
743- vertexData[6] = wx;
744- vertexData[7] = wy + height;
745- vertexData[8] = 0;
746- vertexData[9] = wx;
747- vertexData[10] = wy + height + off;
748- vertexData[11] = 0;
749-
750- streamingBuffer->addTexCoords (0, 4, textureData);
751- streamingBuffer->addVertices (4, vertexData);
752- streamingBuffer->addColors (1, color);
753-
754- streamingBuffer->end ();
755- streamingBuffer->render (transform);
756-
757-
758- streamingBuffer->begin (GL_TRIANGLE_STRIP);
759-
760- textureData[0] = 1;
761- textureData[1] = 1;
762- textureData[2] = 1;
763- textureData[3] = 0;
764- textureData[4] = 0;
765- textureData[5] = 1;
766- textureData[6] = 0;
767- textureData[7] = 0;
768-
769- vertexData[0] = wx + width;
770- vertexData[1] = wy + height;
771- vertexData[2] = 0;
772- vertexData[3] = wx + width;
773- vertexData[4] = wy + height + off;
774- vertexData[5] = 0;
775- vertexData[6] = wx + width + off;
776- vertexData[7] = wy + height;
777- vertexData[8] = 0;
778- vertexData[9] = wx + width + off;
779- vertexData[10] = wy + height + off;
780- vertexData[11] = 0;
781-
782- streamingBuffer->addTexCoords (0, 4, textureData);
783- streamingBuffer->addVertices (4, vertexData);
784- streamingBuffer->addColors (1, color);
785-
786- streamingBuffer->end ();
787- streamingBuffer->render (transform);
788-
789-
790- streamingBuffer->begin (GL_TRIANGLE_STRIP);
791-
792- textureData[0] = 1;
793- textureData[1] = 0;
794- textureData[2] = 1;
795- textureData[3] = 1;
796- textureData[4] = 1;
797- textureData[5] = 0;
798- textureData[6] = 1;
799- textureData[7] = 1;
800-
801- vertexData[0] = wx;
802- vertexData[1] = wy - off;
803- vertexData[2] = 0;
804- vertexData[3] = wx;
805- vertexData[4] = wy;
806- vertexData[5] = 0;
807- vertexData[6] = wx + width;
808- vertexData[7] = wy - off;
809- vertexData[8] = 0;
810- vertexData[9] = wx + width;
811- vertexData[10] = wy;
812- vertexData[11] = 0;
813-
814- streamingBuffer->addTexCoords (0, 4, textureData);
815- streamingBuffer->addVertices (4, vertexData);
816- streamingBuffer->addColors (1, color);
817-
818- streamingBuffer->end ();
819- streamingBuffer->render (transform);
820-
821-
822- streamingBuffer->begin (GL_TRIANGLE_STRIP);
823-
824- textureData[0] = 1;
825- textureData[1] = 1;
826- textureData[2] = 1;
827- textureData[3] = 0;
828- textureData[4] = 1;
829- textureData[5] = 1;
830- textureData[6] = 1;
831- textureData[7] = 0;
832-
833- vertexData[0] = wx;
834- vertexData[1] = wy + height;
835- vertexData[2] = 0;
836- vertexData[3] = wx;
837- vertexData[4] = wy + height + off;
838- vertexData[5] = 0;
839- vertexData[6] = wx + width;
840- vertexData[7] = wy + height;
841- vertexData[8] = 0;
842- vertexData[9] = wx + width;
843- vertexData[10] = wy + height + off;
844- vertexData[11] = 0;
845-
846- streamingBuffer->addTexCoords (0, 4, textureData);
847- streamingBuffer->addVertices (4, vertexData);
848- streamingBuffer->addColors (1, color);
849-
850- streamingBuffer->end ();
851- streamingBuffer->render (transform);
852-
853-
854- streamingBuffer->begin (GL_TRIANGLE_STRIP);
855-
856- textureData[0] = 0;
857- textureData[1] = 1;
858- textureData[2] = 0;
859- textureData[3] = 1;
860- textureData[4] = 1;
861- textureData[5] = 1;
862- textureData[6] = 1;
863- textureData[7] = 1;
864-
865- vertexData[0] = wx - off;
866- vertexData[1] = wy;
867- vertexData[2] = 0;
868- vertexData[3] = wx - off;
869- vertexData[4] = wy + height;
870- vertexData[5] = 0;
871- vertexData[6] = wx;
872- vertexData[7] = wy;
873- vertexData[8] = 0;
874- vertexData[9] = wx;
875- vertexData[10] = wy + height;
876- vertexData[11] = 0;
877-
878- streamingBuffer->addTexCoords (0, 4, textureData);
879- streamingBuffer->addVertices (4, vertexData);
880- streamingBuffer->addColors (1, color);
881-
882- streamingBuffer->end ();
883- streamingBuffer->render (transform);
884-
885-
886- streamingBuffer->begin (GL_TRIANGLE_STRIP);
887-
888- textureData[0] = 1;
889- textureData[1] = 1;
890- textureData[2] = 1;
891- textureData[3] = 1;
892- textureData[4] = 0;
893- textureData[5] = 1;
894- textureData[6] = 0;
895- textureData[7] = 1;
896-
897- vertexData[0] = wx + width;
898- vertexData[1] = wy;
899- vertexData[2] = 0;
900- vertexData[3] = wx + width;
901- vertexData[4] = wy + height;
902- vertexData[5] = 0;
903- vertexData[6] = wx + width + off;
904- vertexData[7] = wy;
905- vertexData[8] = 0;
906- vertexData[9] = wx + width + off;
907- vertexData[10] = wy + height;
908+ streamingBuffer->begin (GL_TRIANGLE_STRIP);
909+
910+ textureData[0] = 0;
911+ textureData[1] = 0;
912+ textureData[2] = 0;
913+ textureData[3] = 1;
914+ textureData[4] = 1;
915+ textureData[5] = 0;
916+ textureData[6] = 1;
917+ textureData[7] = 1;
918+
919+ vertexData[0] = wxMinusOff;
920+ vertexData[1] = wyMinusOff;
921+ vertexData[2] = 0;
922+ vertexData[3] = wxMinusOff;
923+ vertexData[4] = wy;
924+ vertexData[5] = 0;
925+ vertexData[6] = wx;
926+ vertexData[7] = wyMinusOff;
927+ vertexData[8] = 0;
928+ vertexData[9] = wx;
929+ vertexData[10] = wy;
930+ vertexData[11] = 0;
931+
932+ streamingBuffer->addTexCoords (0, 4, textureData);
933+ streamingBuffer->addVertices (4, vertexData);
934+ streamingBuffer->addColors (1, color);
935+
936+ streamingBuffer->end ();
937+ streamingBuffer->render (transform);
938+
939+ streamingBuffer->begin (GL_TRIANGLE_STRIP);
940+
941+ textureData[0] = 1;
942+ textureData[1] = 0;
943+ textureData[2] = 1;
944+ textureData[3] = 1;
945+ textureData[4] = 0;
946+ textureData[5] = 0;
947+ textureData[6] = 0;
948+ textureData[7] = 1;
949+
950+ vertexData[0] = wxPlusWidth;
951+ vertexData[1] = wyMinusOff;
952+ vertexData[2] = 0;
953+ vertexData[3] = wxPlusWidth;
954+ vertexData[4] = wy;
955+ vertexData[5] = 0;
956+ vertexData[6] = wxPlusWPlusOff;
957+ vertexData[7] = wyMinusOff;
958+ vertexData[8] = 0;
959+ vertexData[9] = wxPlusWPlusOff;
960+ vertexData[10] = wy;
961+ vertexData[11] = 0;
962+
963+ streamingBuffer->addTexCoords (0, 4, textureData);
964+ streamingBuffer->addVertices (4, vertexData);
965+ streamingBuffer->addColors (1, color);
966+
967+ streamingBuffer->end ();
968+ streamingBuffer->render (transform);
969+
970+ streamingBuffer->begin (GL_TRIANGLE_STRIP);
971+
972+ textureData[0] = 0;
973+ textureData[1] = 1;
974+ textureData[2] = 0;
975+ textureData[3] = 0;
976+ textureData[4] = 1;
977+ textureData[5] = 1;
978+ textureData[6] = 1;
979+ textureData[7] = 0;
980+
981+ vertexData[0] = wxMinusOff;
982+ vertexData[1] = wyPlusHeight;
983+ vertexData[2] = 0;
984+ vertexData[3] = wxMinusOff;
985+ vertexData[4] = wyPlusHPlusOff;
986+ vertexData[5] = 0;
987+ vertexData[6] = wx;
988+ vertexData[7] = wyPlusHeight;
989+ vertexData[8] = 0;
990+ vertexData[9] = wx;
991+ vertexData[10] = wyPlusHPlusOff;
992+ vertexData[11] = 0;
993+
994+ streamingBuffer->addTexCoords (0, 4, textureData);
995+ streamingBuffer->addVertices (4, vertexData);
996+ streamingBuffer->addColors (1, color);
997+
998+ streamingBuffer->end ();
999+ streamingBuffer->render (transform);
1000+
1001+ streamingBuffer->begin (GL_TRIANGLE_STRIP);
1002+
1003+ textureData[0] = 1;
1004+ textureData[1] = 1;
1005+ textureData[2] = 1;
1006+ textureData[3] = 0;
1007+ textureData[4] = 0;
1008+ textureData[5] = 1;
1009+ textureData[6] = 0;
1010+ textureData[7] = 0;
1011+
1012+ vertexData[0] = wxPlusWidth;
1013+ vertexData[1] = wyPlusHeight;
1014+ vertexData[2] = 0;
1015+ vertexData[3] = wxPlusWidth;
1016+ vertexData[4] = wyPlusHPlusOff;
1017+ vertexData[5] = 0;
1018+ vertexData[6] = wxPlusWPlusOff;
1019+ vertexData[7] = wyPlusHeight;
1020+ vertexData[8] = 0;
1021+ vertexData[9] = wxPlusWPlusOff;
1022+ vertexData[10] = wyPlusHPlusOff;
1023+ vertexData[11] = 0;
1024+
1025+ streamingBuffer->addTexCoords (0, 4, textureData);
1026+ streamingBuffer->addVertices (4, vertexData);
1027+ streamingBuffer->addColors (1, color);
1028+
1029+ streamingBuffer->end ();
1030+ streamingBuffer->render (transform);
1031+
1032+ streamingBuffer->begin (GL_TRIANGLE_STRIP);
1033+
1034+ textureData[0] = 1;
1035+ textureData[1] = 0;
1036+ textureData[2] = 1;
1037+ textureData[3] = 1;
1038+ textureData[4] = 1;
1039+ textureData[5] = 0;
1040+ textureData[6] = 1;
1041+ textureData[7] = 1;
1042+
1043+ vertexData[0] = wx;
1044+ vertexData[1] = wyMinusOff;
1045+ vertexData[2] = 0;
1046+ vertexData[3] = wx;
1047+ vertexData[4] = wy;
1048+ vertexData[5] = 0;
1049+ vertexData[6] = wxPlusWidth;
1050+ vertexData[7] = wyMinusOff;
1051+ vertexData[8] = 0;
1052+ vertexData[9] = wxPlusWidth;
1053+ vertexData[10] = wy;
1054+ vertexData[11] = 0;
1055+
1056+ streamingBuffer->addTexCoords (0, 4, textureData);
1057+ streamingBuffer->addVertices (4, vertexData);
1058+ streamingBuffer->addColors (1, color);
1059+
1060+ streamingBuffer->end ();
1061+ streamingBuffer->render (transform);
1062+
1063+ streamingBuffer->begin (GL_TRIANGLE_STRIP);
1064+
1065+ textureData[0] = 1;
1066+ textureData[1] = 1;
1067+ textureData[2] = 1;
1068+ textureData[3] = 0;
1069+ textureData[4] = 1;
1070+ textureData[5] = 1;
1071+ textureData[6] = 1;
1072+ textureData[7] = 0;
1073+
1074+ vertexData[0] = wx;
1075+ vertexData[1] = wyPlusHeight;
1076+ vertexData[2] = 0;
1077+ vertexData[3] = wx;
1078+ vertexData[4] = wyPlusHPlusOff;
1079+ vertexData[5] = 0;
1080+ vertexData[6] = wxPlusWidth;
1081+ vertexData[7] = wyPlusHeight;
1082+ vertexData[8] = 0;
1083+ vertexData[9] = wxPlusWidth;
1084+ vertexData[10] = wyPlusHPlusOff;
1085+ vertexData[11] = 0;
1086+
1087+ streamingBuffer->addTexCoords (0, 4, textureData);
1088+ streamingBuffer->addVertices (4, vertexData);
1089+ streamingBuffer->addColors (1, color);
1090+
1091+ streamingBuffer->end ();
1092+ streamingBuffer->render (transform);
1093+
1094+ streamingBuffer->begin (GL_TRIANGLE_STRIP);
1095+
1096+ textureData[0] = 0;
1097+ textureData[1] = 1;
1098+ textureData[2] = 0;
1099+ textureData[3] = 1;
1100+ textureData[4] = 1;
1101+ textureData[5] = 1;
1102+ textureData[6] = 1;
1103+ textureData[7] = 1;
1104+
1105+ vertexData[0] = wxMinusOff;
1106+ vertexData[1] = wy;
1107+ vertexData[2] = 0;
1108+ vertexData[3] = wxMinusOff;
1109+ vertexData[4] = wyPlusHeight;
1110+ vertexData[5] = 0;
1111+ vertexData[6] = wx;
1112+ vertexData[7] = wy;
1113+ vertexData[8] = 0;
1114+ vertexData[9] = wx;
1115+ vertexData[10] = wyPlusHeight;
1116+ vertexData[11] = 0;
1117+
1118+ streamingBuffer->addTexCoords (0, 4, textureData);
1119+ streamingBuffer->addVertices (4, vertexData);
1120+ streamingBuffer->addColors (1, color);
1121+
1122+ streamingBuffer->end ();
1123+ streamingBuffer->render (transform);
1124+
1125+ streamingBuffer->begin (GL_TRIANGLE_STRIP);
1126+
1127+ textureData[0] = 1;
1128+ textureData[1] = 1;
1129+ textureData[2] = 1;
1130+ textureData[3] = 1;
1131+ textureData[4] = 0;
1132+ textureData[5] = 1;
1133+ textureData[6] = 0;
1134+ textureData[7] = 1;
1135+
1136+ vertexData[0] = wxPlusWidth;
1137+ vertexData[1] = wy;
1138+ vertexData[2] = 0;
1139+ vertexData[3] = wxPlusWidth;
1140+ vertexData[4] = wyPlusHeight;
1141+ vertexData[5] = 0;
1142+ vertexData[6] = wxPlusWPlusOff;
1143+ vertexData[7] = wy;
1144+ vertexData[8] = 0;
1145+ vertexData[9] = wxPlusWPlusOff;
1146+ vertexData[10] = wyPlusHeight;
1147 vertexData[11] = 0;
1148
1149 streamingBuffer->addTexCoords (0, 4, textureData);
1150@@ -831,40 +796,46 @@
1151 }
1152
1153 void
1154-ThumbScreen::thumbPaintThumb (Thumbnail *t,
1155+ThumbScreen::thumbPaintThumb (Thumbnail *t,
1156 const GLMatrix *transform)
1157 {
1158- GLushort color[4];
1159- int addWindowGeometryIndex;
1160- CompWindow *w = t->win;
1161- int wx = t->x;
1162- int wy = t->y;
1163- float width = t->width;
1164- float backheight = t->height; // background/glow height
1165- GLWindowPaintAttrib sAttrib;
1166- unsigned int mask = PAINT_WINDOW_TRANSFORMED_MASK |
1167- PAINT_WINDOW_TRANSLUCENT_MASK;
1168- GLWindow *gWindow = GLWindow::get (w);
1169+ CompWindow *w = t->win;
1170
1171 if (!w)
1172 return;
1173
1174+ GLWindow *gWindow = GLWindow::get (w);
1175+
1176+ GLushort color[4];
1177+
1178+ int wx = t->x;
1179+ int wy = t->y;
1180+
1181+ GLWindowPaintAttrib sAttrib;
1182+ unsigned int mask = PAINT_WINDOW_TRANSFORMED_MASK |
1183+ PAINT_WINDOW_TRANSLUCENT_MASK;
1184+
1185 sAttrib = gWindow->paintAttrib ();
1186
1187 /* Wrap drawWindowGeometry to make sure the general
1188 drawWindowGeometry function is used */
1189- addWindowGeometryIndex =
1190- gWindow->glAddGeometryGetCurrentIndex ();
1191+ unsigned int addWindowGeometryIndex = gWindow->glAddGeometryGetCurrentIndex ();
1192
1193 if (!gWindow->textures ().empty ())
1194 {
1195- int off = t->offset;
1196- GLenum filter = gScreen->textureFilter ();
1197- GLMatrix wTransform (*transform);
1198-
1199- glEnable (GL_BLEND);
1200+ GLMatrix wTransform (*transform);
1201+ GLboolean glBlendEnabled = glIsEnabled (GL_BLEND);
1202+
1203+ /* just enable blending if it is currently disabled */
1204+ if (!glBlendEnabled)
1205+ glEnable (GL_BLEND);
1206+
1207 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1208
1209+ int off = t->offset;
1210+ float backheight = t->height; // background/glow height
1211+ float width = t->width;
1212+
1213 if (optionGetWindowLike ())
1214 {
1215 color[0] = 1;
1216@@ -895,11 +866,14 @@
1217 }
1218
1219 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
1220- glDisable (GL_BLEND);
1221+
1222+ /* we disable blending only, if it was disabled before */
1223+ if (!glBlendEnabled)
1224+ glDisable (GL_BLEND);
1225
1226 if (t->text)
1227 {
1228- float ox = 0.0f;
1229+ float ox = 0.0f;
1230 float height = backheight + t->text->getHeight () + optionGetTextDistance ();
1231
1232 if (t->text->getWidth () < width)
1233@@ -911,12 +885,16 @@
1234 gScreen->setTexEnvMode (GL_REPLACE);
1235
1236 sAttrib.opacity *= t->opacity;
1237- sAttrib.yScale = t->scale;
1238- sAttrib.xScale = t->scale;
1239+ sAttrib.yScale = t->scale;
1240+ sAttrib.xScale = t->scale;
1241
1242 sAttrib.xTranslate = wx - w->x () + w->border ().left * sAttrib.xScale;
1243- sAttrib.yTranslate = wy - w->y () + w->border ().top * sAttrib.yScale;
1244-
1245+ sAttrib.yTranslate = wy - w->y () + w->border ().top * sAttrib.yScale;
1246+
1247+ GLenum filter = gScreen->textureFilter ();
1248+
1249+ /* we just need to change the texture filter, if
1250+ * thumbnail mipmapping is enabled */
1251 if (optionGetMipmap ())
1252 gScreen->setTextureFilter (GL_LINEAR_MIPMAP_LINEAR);
1253
1254@@ -962,13 +940,12 @@
1255 }*/
1256
1257 if (showingThumb && thumb.win == pointedWin)
1258- {
1259 thumb.opacity = MIN (1.0, thumb.opacity + val);
1260- }
1261
1262 if (!showingThumb || thumb.win != pointedWin)
1263 {
1264 thumb.opacity = MAX (0.0, thumb.opacity - val);
1265+
1266 if (thumb.opacity == 0.0)
1267 thumb.win = NULL;
1268 }
1269@@ -976,6 +953,7 @@
1270 if (oldThumb.opacity > 0.0f)
1271 {
1272 oldThumb.opacity = MAX (0.0, oldThumb.opacity - val);
1273+
1274 if (oldThumb.opacity == 0.0)
1275 {
1276 damageThumbRegion (&oldThumb);
1277@@ -999,10 +977,10 @@
1278 {
1279 std::vector <Thumbnail *> damageThumbs;
1280
1281- if (thumb.opacity > 0.0)
1282+ if (thumb.opacity)
1283 damageThumbs.push_back (&thumb);
1284
1285- if (oldThumb.opacity > 0.0)
1286+ if (oldThumb.opacity)
1287 damageThumbs.push_back (&oldThumb);
1288
1289 if (!damageThumbs.empty ())
1290@@ -1021,12 +999,11 @@
1291
1292 bool
1293 ThumbScreen::glPaintOutput (const GLScreenPaintAttrib &attrib,
1294- const GLMatrix &transform,
1295- const CompRegion &region,
1296- CompOutput *output,
1297- unsigned int mask)
1298+ const GLMatrix &transform,
1299+ const CompRegion &region,
1300+ CompOutput *output,
1301+ unsigned int mask)
1302 {
1303- bool status;
1304 unsigned int newMask = mask;
1305
1306 painted = false;
1307@@ -1035,12 +1012,10 @@
1308 y = screen->vp ().y ();
1309
1310 if ((oldThumb.opacity > 0.0 && oldThumb.win) ||
1311- (thumb.opacity > 0.0 && thumb.win))
1312- {
1313+ (thumb.opacity > 0.0 && thumb.win))
1314 newMask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK;
1315- }
1316
1317- status = gScreen->glPaintOutput (attrib, transform, region, output, newMask);
1318+ bool status = gScreen->glPaintOutput (attrib, transform, region, output, newMask);
1319
1320 if (optionGetAlwaysOnTop () && !painted)
1321 {
1322@@ -1066,12 +1041,11 @@
1323
1324 void
1325 ThumbScreen::glPaintTransformedOutput (const GLScreenPaintAttrib &attrib,
1326- const GLMatrix &transform,
1327- const CompRegion &region,
1328- CompOutput *output,
1329- unsigned int mask)
1330+ const GLMatrix &transform,
1331+ const CompRegion &region,
1332+ CompOutput *output,
1333+ unsigned int mask)
1334 {
1335-
1336 gScreen->glPaintTransformedOutput (attrib, transform, region, output, mask);
1337
1338 if (optionGetAlwaysOnTop () && x == screen->vp ().x () &&
1339@@ -1079,7 +1053,7 @@
1340 {
1341 painted = true;
1342
1343- if (oldThumb.opacity > 0.0 && oldThumb.win)
1344+ if (oldThumb.opacity && oldThumb.win)
1345 {
1346 GLMatrix sTransform = transform;
1347
1348@@ -1088,7 +1062,7 @@
1349 thumbPaintThumb (&oldThumb, &sTransform);
1350 }
1351
1352- if (thumb.opacity > 0.0 && thumb.win)
1353+ if (thumb.opacity && thumb.win)
1354 {
1355 GLMatrix sTransform = transform;
1356
1357@@ -1101,45 +1075,44 @@
1358
1359 bool
1360 ThumbWindow::glPaint (const GLWindowPaintAttrib &attrib,
1361- const GLMatrix &transform,
1362+ const GLMatrix &transform,
1363 const CompRegion &region,
1364- unsigned int mask)
1365+ unsigned int mask)
1366 {
1367- bool status;
1368-
1369 THUMB_SCREEN (screen);
1370
1371- status = gWindow->glPaint (attrib, transform, region, mask);
1372+ bool status = gWindow->glPaint (attrib, transform, region, mask);
1373
1374- if (!ts->optionGetAlwaysOnTop () && ts->x == screen->vp ().x () &&
1375- ts->y == screen->vp ().y ())
1376+ if (!ts->optionGetAlwaysOnTop () &&
1377+ ts->x == screen->vp ().x () &&
1378+ ts->y == screen->vp ().y ())
1379 {
1380 GLMatrix sTransform = transform;
1381- if (ts->oldThumb.opacity > 0.0 && ts->oldThumb.win &&
1382+
1383+ if (ts->oldThumb.opacity &&
1384+ ts->oldThumb.win &&
1385 ts->oldThumb.dock == window)
1386- {
1387 ts->thumbPaintThumb (&ts->oldThumb, &sTransform);
1388- }
1389
1390- if (ts->thumb.opacity > 0.0 && ts->thumb.win && ts->thumb.dock == window)
1391- {
1392+ if (ts->thumb.opacity &&
1393+ ts->thumb.win &&
1394+ ts->thumb.dock == window)
1395 ts->thumbPaintThumb (&ts->thumb, &sTransform);
1396- }
1397 }
1398
1399 return status;
1400 }
1401
1402 bool
1403-ThumbWindow::damageRect (bool initial,
1404- const CompRect &rect)
1405+ThumbWindow::damageRect (bool initial,
1406+ const CompRect &rect)
1407 {
1408 THUMB_SCREEN (screen);
1409
1410- if (ts->thumb.win == window && ts->thumb.opacity > 0.0)
1411+ if (ts->thumb.win == window && ts->thumb.opacity)
1412 ts->damageThumbRegion (&ts->thumb);
1413
1414- if (ts->oldThumb.win == window && ts->oldThumb.opacity > 0.0)
1415+ if (ts->oldThumb.win == window && ts->oldThumb.opacity)
1416 ts->damageThumbRegion (&ts->oldThumb);
1417
1418 return cWindow->damageRect (initial, rect);
1419@@ -1164,13 +1137,13 @@
1420 CompositeScreenInterface::setHandler (cScreen, false);
1421 GLScreenInterface::setHandler (gScreen, false);
1422
1423- thumb.win = NULL;
1424+ thumb.win = NULL;
1425 oldThumb.win = NULL;
1426
1427- thumb.text = NULL;
1428+ thumb.text = NULL;
1429 oldThumb.text = NULL;
1430
1431- thumb.opacity = 0.0f;
1432+ thumb.opacity = 0.0f;
1433 oldThumb.opacity = 0.0f;
1434
1435 poller.setCallback (boost::bind (&ThumbScreen::positionUpdate, this, _1));
1436@@ -1196,7 +1169,6 @@
1437 GLWindowInterface::setHandler (gWindow, false);
1438 }
1439
1440-
1441 ThumbWindow::~ThumbWindow ()
1442 {
1443 THUMB_SCREEN (screen);
1444@@ -1204,14 +1176,14 @@
1445 if (ts->thumb.win == window)
1446 {
1447 ts->damageThumbRegion (&ts->thumb);
1448- ts->thumb.win = NULL;
1449+ ts->thumb.win = NULL;
1450 ts->thumb.opacity = 0;
1451 }
1452
1453 if (ts->oldThumb.win == window)
1454 {
1455 ts->damageThumbRegion (&ts->oldThumb);
1456- ts->oldThumb.win = NULL;
1457+ ts->oldThumb.win = NULL;
1458 ts->oldThumb.opacity = 0;
1459 }
1460
1461
1462=== modified file 'plugins/thumbnail/src/thumbnail.h'
1463--- plugins/thumbnail/src/thumbnail.h 2012-09-07 23:56:21 +0000
1464+++ plugins/thumbnail/src/thumbnail.h 2013-06-28 14:26:23 +0000
1465@@ -53,24 +53,17 @@
1466 #define THUMB_WINDOW(w) \
1467 ThumbWindow *tw = ThumbWindow::get (w)
1468
1469-#define WIN_X(w) ((w)->x () - (w)->border ().left)
1470-#define WIN_Y(w) ((w)->y () - (w)->border ().top)
1471-#define WIN_W(w) ((w)->width () + (w)->border ().left + (w)->border ().right)
1472-#define WIN_H(w) ((w)->height () + (w)->border ().top + (w)->border ().bottom)
1473-
1474-extern const unsigned short TEXT_DISTANCE;
1475-
1476 bool textPluginLoaded;
1477
1478 typedef struct _Thumbnail
1479 {
1480- int x;
1481- int y;
1482- int width;
1483- int height;
1484- float scale;
1485- float opacity;
1486- int offset;
1487+ int x;
1488+ int y;
1489+ int width;
1490+ int height;
1491+ float scale;
1492+ float opacity;
1493+ int offset;
1494
1495 CompWindow *win;
1496 CompWindow *dock;
1497@@ -97,30 +90,30 @@
1498
1499 bool
1500 glPaintOutput (const GLScreenPaintAttrib &,
1501- const GLMatrix &,
1502- const CompRegion &,
1503- CompOutput *,
1504- unsigned int);
1505+ const GLMatrix &,
1506+ const CompRegion &,
1507+ CompOutput *,
1508+ unsigned int );
1509
1510 void
1511 donePaint ();
1512
1513 void
1514 glPaintTransformedOutput (const GLScreenPaintAttrib &,
1515- const GLMatrix &,
1516- const CompRegion &,
1517- CompOutput *,
1518- unsigned int);
1519-
1520- void
1521- freeThumbText (Thumbnail *t);
1522-
1523- void
1524- renderThumbText (Thumbnail *t,
1525- bool freeThumb);
1526-
1527- void
1528- damageThumbRegion (Thumbnail *t);
1529+ const GLMatrix &,
1530+ const CompRegion &,
1531+ CompOutput *,
1532+ unsigned int );
1533+
1534+ void
1535+ freeThumbText (Thumbnail *t);
1536+
1537+ void
1538+ renderThumbText (Thumbnail *t,
1539+ bool freeThumb);
1540+
1541+ void
1542+ damageThumbRegion (Thumbnail *t);
1543
1544 void
1545 thumbUpdateThumbnail ();
1546@@ -136,19 +129,18 @@
1547
1548 void
1549 paintTexture (const GLMatrix &transform,
1550- GLushort *color,
1551- int wx,
1552- int wy,
1553- int width,
1554- int height,
1555- int off);
1556+ GLushort *color,
1557+ int wx,
1558+ int wy,
1559+ int width,
1560+ int height,
1561+ int off);
1562
1563 void
1564- thumbPaintThumb (Thumbnail *t,
1565+ thumbPaintThumb (Thumbnail *t,
1566 const GLMatrix *transform);
1567
1568-
1569- GLScreen *gScreen;
1570+ GLScreen *gScreen;
1571 CompositeScreen *cScreen;
1572
1573 CompWindow *dock;
1574@@ -181,15 +173,15 @@
1575 ThumbWindow (CompWindow *window);
1576 ~ThumbWindow ();
1577
1578- CompWindow *window;
1579+ CompWindow *window;
1580 CompositeWindow *cWindow;
1581- GLWindow *gWindow;
1582+ GLWindow *gWindow;
1583
1584 bool
1585 glPaint (const GLWindowPaintAttrib &attrib,
1586- const GLMatrix &transform,
1587- const CompRegion &region,
1588- unsigned int mask);
1589+ const GLMatrix &transform,
1590+ const CompRegion &region,
1591+ unsigned int mask);
1592
1593 void
1594 resizeNotify (int dx,
1595@@ -198,7 +190,7 @@
1596 int dheight);
1597
1598 bool
1599- damageRect (bool initial,
1600+ damageRect (bool initial,
1601 const CompRect &rect);
1602 };
1603

Subscribers

People subscribed via source and target branches

to all changes: