Merge lp:~mc-return/compiz/compiz.merge-fix1099100-thumbnail-title-text-issues.0 into lp:compiz/0.9.9

Proposed by MC Return
Status: Merged
Approved by: Brandon Schaefer
Approved revision: 3587
Merged at revision: 3593
Proposed branch: lp:~mc-return/compiz/compiz.merge-fix1099100-thumbnail-title-text-issues.0
Merge into: lp:compiz/0.9.9
Diff against target: 155 lines (+37/-16)
2 files modified
plugins/thumbnail/src/thumbnail.cpp (+19/-15)
plugins/thumbnail/thumbnail.xml.in (+18/-1)
To merge this branch: bzr merge lp:~mc-return/compiz/compiz.merge-fix1099100-thumbnail-title-text-issues.0
Reviewer Review Type Date Requested Status
Brandon Schaefer (community) Approve
Sam Spilsbury Approve
MC Return Needs Resubmitting
PS Jenkins bot continuous-integration Pending
Review via email: mp+144954@code.launchpad.net

Commit message

Thumbnail plugin, new features:

Added a rounded background to the window title text.

Made the distance between text and thumbnail configurable.

Window-like-background or glow are now rendered around
the thumbnail live preview only, excluding the text.
This ensures no transparent hole is generated anymore and
fixes the look of the window title text rendering, while
enhancing the possibility for customization.

Code cleanup:

Return ASAP if the text plugin is not loaded.
No need to check if (t->text) twice.
Improved height calculation.

thumbnail.xml.in changes:

Added options to adjust the text distance (pixel between
thumbnail and window title text) and font background color
and opacity.

Made the window title text font white and fully opaque
to create a sane default, otherwise it would not be
visible on a transparent black background (alpha and color
are the same like the default background/glow color).

(LP: #1099100)

Description of the change

As requested no .xml.in cleanup this time.
A second MP will follow soon.

Note:
These will not be the final fixes for thumbnail as
there are still a few issues unsolved...

1. This plugin (like several others, btw.) requires
the text plugin to be activated to fully work, but
the user is not informed about that fact, see:
https://code.launchpad.net/~mc-return/compiz/compiz.merge-fix1099100-thumbnail-title-text-issues/+merge/143042/comments/310279
Ideally bug 1101198 should be fixed first to perfectly
solve this issue, but if you think this feature is
not necessary, we should add text requirements to those
plugins.

2. While working smoothly with gallium-radeon, there
is still flickering of the thumbnail texture itself
when using fglrx. I have not tested other gfx/driver
combinations but expect there might be similar issues.

3. This plugin won't play together nicely with multiple
docks/taskbars/launchers as it will currently just display
one thumbnail live window preview per icon.

To post a comment you must log in.
3586. By MC Return

Fixed indentation

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

This looks fine code wise.

I'm a bit concerned as to how things will look once we start requiring that the text background be rendered in addition to the text. My understanding was that we were meant to render the thumbnail background (window) and then render the text on top of that. What was the reason that we couldn't do that? If it was that there was really a "hole" where the text was, then this sounds like a more fundamental problem with the rendering of the thumbnail background itself, and we shouldn't cover it up by rendering a text background on top of it.

Could you post a screenshot to see how it looks?

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

> This looks fine code wise.
>
> I'm a bit concerned as to how things will look once we start requiring that
> the text background be rendered in addition to the text. My understanding was
> that we were meant to render the thumbnail background (window) and then render
> the text on top of that. What was the reason that we couldn't do that? If it
> was that there was really a "hole" where the text was, then this sounds like a
> more fundamental problem with the rendering of the thumbnail background
> itself, and we shouldn't cover it up by rendering a text background on top of
> it.

Yes, it was a rendering problem initially. Most probably it could have been
solved differently also, by simply filling the hole for example.
I chose this solution, because it also fixes the problem and brings some
advancements and enhanced customization possibility, while hiding less of
the background and looking better at the same time.
This is kind of a solved problem combined with an upgrade and refined look.

>
> Could you post a screenshot to see how it looks?

This is how default looks now: http://imagebin.org/244365
Of course it can look very different as well, as you can configure everything
to your liking.

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

Okay, I think its a nice and new take. What do you think Daniel?
On 27/01/2013 10:30 AM, "MC Return" <email address hidden> wrote:

> Review: Resubmit
>
> > This looks fine code wise.
> >
> > I'm a bit concerned as to how things will look once we start requiring
> that
> > the text background be rendered in addition to the text. My
> understanding was
> > that we were meant to render the thumbnail background (window) and then
> render
> > the text on top of that. What was the reason that we couldn't do that?
> If it
> > was that there was really a "hole" where the text was, then this sounds
> like a
> > more fundamental problem with the rendering of the thumbnail background
> > itself, and we shouldn't cover it up by rendering a text background on
> top of
> > it.
>
> Yes, it was a rendering problem initially. Most probably it could have been
> solved differently also, by simply filling the hole for example.
> I chose this solution, because it also fixes the problem and brings some
> advancements and enhanced customization possibility, while hiding less of
> the background and looking better at the same time.
> This is kind of a solved problem combined with an upgrade and refined look.
>
> >
> > Could you post a screenshot to see how it looks?
>
> This is how default looks now: http://imagebin.org/244365
> Of course it can look very different as well, as you can configure
> everything
> to your liking.
> --
>
> https://code.launchpad.net/~mc-return/compiz/compiz.merge-fix1099100-thumbnail-title-text-issues.0/+merge/144954
> You are reviewing the proposed merge of
> lp:~mc-return/compiz/compiz.merge-fix1099100-thumbnail-title-text-issues.0
> into lp:compiz.
>

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

I'm fine with this as is - awaiting feedback from another reviewer.

review: Approve
3587. By MC Return

Merged latest lp:compiz

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

LGTM, works.

review: Approve

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-01-11 23:32:06 +0000
3+++ plugins/thumbnail/src/thumbnail.cpp 2013-01-31 19:13:21 +0000
4@@ -32,8 +32,6 @@
5
6 COMPIZ_PLUGIN_20090315 (thumbnail, ThumbPluginVTable);
7
8-const unsigned short TEXT_DISTANCE = 10;
9-
10 void
11 ThumbScreen::freeThumbText (Thumbnail *t)
12 {
13@@ -48,6 +46,9 @@
14 ThumbScreen::renderThumbText (Thumbnail *t,
15 bool freeThumb)
16 {
17+ if (!textPluginLoaded)
18+ return;
19+
20 CompText::Attrib tA;
21
22 if (freeThumb || !t->text)
23@@ -56,18 +57,23 @@
24 t->text = new CompText ();
25 }
26
27- if (!textPluginLoaded)
28- return;
29-
30 tA.maxWidth = t->width;
31 tA.maxHeight = 100;
32
33+ // text background
34+ tA.bgHMargin = 4;
35+ tA.bgVMargin = 4;
36+ tA.bgColor[0] = optionGetFontBackgroundColorRed ();
37+ tA.bgColor[1] = optionGetFontBackgroundColorGreen ();
38+ tA.bgColor[2] = optionGetFontBackgroundColorBlue ();
39+ tA.bgColor[3] = optionGetFontBackgroundColorAlpha ();
40+
41 tA.size = optionGetFontSize ();
42 tA.color[0] = optionGetFontColorRed ();
43 tA.color[1] = optionGetFontColorGreen ();
44 tA.color[2] = optionGetFontColorBlue ();
45 tA.color[3] = optionGetFontColorAlpha ();
46- tA.flags = CompText::Ellipsized;
47+ tA.flags = CompText::WithBackground | CompText::Ellipsized;
48 if (optionGetFontBold ())
49 tA.flags |= CompText::StyleBold;
50 tA.family = "Sans";
51@@ -85,7 +91,7 @@
52 CompRect rect (x, y, width, height);
53
54 if (t->text)
55- rect.setHeight (rect.height () + t->text->getHeight () + TEXT_DISTANCE);
56+ rect.setHeight (rect.height () + t->text->getHeight () + optionGetTextDistance ());
57
58 CompRegion region (rect);
59
60@@ -188,7 +194,7 @@
61
62 tHeight = thumb.height;
63 if (thumb.text)
64- tHeight += thumb.text->getHeight () + TEXT_DISTANCE;
65+ tHeight += thumb.text->getHeight () + optionGetTextDistance ();
66
67 /* Could someone please explain how this works */
68
69@@ -835,7 +841,7 @@
70 int wx = t->x;
71 int wy = t->y;
72 float width = t->width;
73- float height = t->height;
74+ float backheight = t->height; // background/glow height
75 GLWindowPaintAttrib sAttrib;
76 unsigned int mask = PAINT_WINDOW_TRANSFORMED_MASK |
77 PAINT_WINDOW_TRANSLUCENT_MASK;
78@@ -846,9 +852,6 @@
79
80 sAttrib = gWindow->paintAttrib ();
81
82- if (t->text)
83- height += t->text->getHeight () + TEXT_DISTANCE;
84-
85 /* Wrap drawWindowGeometry to make sure the general
86 drawWindowGeometry function is used */
87 addWindowGeometryIndex =
88@@ -873,7 +876,7 @@
89 foreach (GLTexture *tex, windowTexture)
90 {
91 tex->enable (GLTexture::Good);
92- paintTexture (*transform, color, wx, wy, width, height, off);
93+ paintTexture (*transform, color, wx, wy, width, backheight, off);
94 tex->disable ();
95 }
96 }
97@@ -887,7 +890,7 @@
98 foreach (GLTexture *tex, glowTexture)
99 {
100 tex->enable (GLTexture::Good);
101- paintTexture (*transform, color, wx, wy, width, height, off);
102+ paintTexture (*transform, color, wx, wy, width, backheight, off);
103 tex->disable ();
104 }
105 }
106@@ -897,7 +900,8 @@
107
108 if (t->text)
109 {
110- float ox = 0.0;
111+ float ox = 0.0f;
112+ float height = backheight + t->text->getHeight () + optionGetTextDistance ();
113
114 if (t->text->getWidth () < width)
115 ox = (width - t->text->getWidth ()) / 2.0;
116
117=== modified file 'plugins/thumbnail/thumbnail.xml.in'
118--- plugins/thumbnail/thumbnail.xml.in 2012-10-15 10:31:51 +0000
119+++ plugins/thumbnail/thumbnail.xml.in 2013-01-31 19:13:21 +0000
120@@ -93,6 +93,13 @@
121 <_long>Should be the window title Bold.</_long>
122 <default>true</default>
123 </option>
124+ <option name="text_distance" type="int">
125+ <_short>Text Distance</_short>
126+ <_long>The gap between the thumbnail and the window title text (in pixel).</_long>
127+ <default>10</default>
128+ <min>0</min>
129+ <max>32</max>
130+ </option>
131 <option name="font_size" type="int">
132 <_short>Font Size</_short>
133 <_long>Window title Font Size.</_long>
134@@ -104,10 +111,20 @@
135 <_short>Font Color</_short>
136 <_long>Window title Font Color.</_long>
137 <default>
138+ <red>0xffff</red>
139+ <green>0xffff</green>
140+ <blue>0xffff</blue>
141+ <alpha>0xffff</alpha>
142+ </default>
143+ </option>
144+ <option name="font_background_color" type="color">
145+ <_short>Font Background Color</_short>
146+ <_long>Color and opacity of the rounded rectangle title text background.</_long>
147+ <default>
148 <red>0x0000</red>
149 <green>0x0000</green>
150 <blue>0x0000</blue>
151- <alpha>0xffff</alpha>
152+ <alpha>0x7fff</alpha>
153 </default>
154 </option>
155 </subgroup>

Subscribers

People subscribed via source and target branches