Merge lp:~vanvugt/unity/fix-1045705 into lp:unity

Proposed by Daniel van Vugt
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
Merged at revision: 2698
Proposed branch: lp:~vanvugt/unity/fix-1045705
Merge into: lp:unity
Diff against target: 136 lines (+44/-30)
2 files modified
plugins/unityshell/src/unityshell.cpp (+43/-29)
plugins/unityshell/src/unityshell.h (+1/-1)
To merge this branch: bzr merge lp:~vanvugt/unity/fix-1045705
Reviewer Review Type Date Requested Status
Omer Akram (community) functional Approve
Andrea Azzarone (community) Abstain
Marco Trevisan (Treviño) Approve
Unity Team design Pending
Review via email: mp+124160@code.launchpad.net

This proposal supersedes a proposal from 2012-09-07.

Commit message

Restore the panel shadow, which has been missing since Unity 6.4.
(LP: #1045705)

Description of the change

Restore the panel shadow, which has been missing since Unity 6.4.
(LP: #1045705)

REQUIRES a compiz fix first:
https://code.launchpad.net/~vanvugt/compiz/decorate-after-draw/+merge/124157
Without that fix, the active window will always have the panel shadow on top of it.

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Wasn't the design supposed to be that it draws on top of all windows unless a maximized window is the active one? I've subscribed John to check.

review: Needs Information
Revision history for this message
John Lea (johnlea) wrote : Posted in a previous version of this proposal

@smspillaz; the shadow is supposed to be drawn on top of all *non-focused* windows, including non-focused maximised windows. The behaviour with LIM is slightly different, but this is not relevant atm.

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Okay, so is that to say that it shouldn't draw on top of unmaximized windows which are in focus ?

Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

I know the design. I'm saying it may not be feasible to re-introduce that feature. Hence the comment.

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

> @smspillaz; the shadow is supposed to be drawn on top of all *non-focused*
> windows, including non-focused maximised windows.

This would result in a popping shadow, which would not look good.

Imagine you have a maximized, focused window and select another non-fullscreen window. The shadow would suddenly pop-up and be drawn on top of the now non-focused maximized window - Once you select this maximized window again, the shadow would suddenly disappear - this behavior would not be good and would feel like a bug.

Revision history for this message
Omer Akram (om26er) wrote : Posted in a previous version of this proposal

> Imagine you have a maximized, focused window and select another non-fullscreen
> window. The shadow would suddenly pop-up and be drawn on top of the now non-
> focused maximized window - Once you select this maximized window again, the
> shadow would suddenly disappear - this behavior would not be good and would
> feel like a bug.

This behavior exists in 12.04 and does not feel like a bug to me :-)

Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

All,

The correct place to discuss the validity of design decision is in bug 967294. Not here.

The discussion here is about whether or not we want to accept this proposal which shadows just the desktop, or wait to see if someone can figure out how to restore shadows over unfocussed windows too.

Revision history for this message
Omer Akram (om26er) wrote : Posted in a previous version of this proposal

Yes, I am aware of that. I just wanted to make it clear that this feature already exists in 12.04 and have regressed in 12.10

Revision history for this message
John Lea (johnlea) : Posted in a previous version of this proposal
review: Approve (design)
Revision history for this message
John Lea (johnlea) wrote : Posted in a previous version of this proposal

yes, this is a regression that needs to be fixed before release

Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Just to clarify: You are choosing no shadow at all, over shadowing just the desktop :(

Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

But shadowing just the desktop is a good first step I think. Hence this proposal.

Revision history for this message
Andrea Cimitan (cimi) wrote : Posted in a previous version of this proposal

Yes, but it's not the fix to the regression. If there isn't a way to fix this, we revert the change that introduced the regression.

Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

The change that disabled shadowing, I don't know. It seems to have come from Linaro in their original GLES port a while ago. And we only just noticed now when switching to COMPIZ_MODERN_GL.

I never noticed it because the shadow has *never* worked for me when I built Unity locally. So it looked the same as usual to me in testing.

Revision history for this message
Andrea Cimitan (cimi) wrote : Posted in a previous version of this proposal

My vote goes for a partial fix, so all screenshots (documentation too) will benefit the fix.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Fully fixed now, pending a small compiz fix.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Nice, works ok and looks fine. Just one small thing:

49 + CompRect bounds(redraw.boundingRect());

Why not CompRect const& bounds = redraw.boundingRect() instead?
We don't need a copy here...

review: Approve
Revision history for this message
Andrea Azzarone (azzar1) wrote :

Code looks good but I got a crash. Seems like _shadow_texture[0] == 0x0 but I'm sure that the shadow_texture png file is correctly installed.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Updated per Marco and Andy's comments.

Revision history for this message
Andrea Azzarone (azzar1) wrote :

No crash here but I still don't get the shadow.

review: Abstain
Revision history for this message
Omer Akram (om26er) wrote :

Shadow was working for me with this branch on Saturday. didn't test with latest changes to this branch though.

Revision history for this message
Tim Penhey (thumper) wrote :

Does this also fix bug 1043260 ?

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

No, this is not related to bug 1043260. In fact, bug 1043260 has nothing to do with the panel shadow at all. That one is caused by the active blur.

Revision history for this message
Omer Akram (om26er) wrote :

Just tested this branch with latest revisions and the Shadow is there.

review: Approve (functional)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/unityshell.cpp'
2--- plugins/unityshell/src/unityshell.cpp 2012-09-15 00:07:22 +0000
3+++ plugins/unityshell/src/unityshell.cpp 2012-09-17 03:47:21 +0000
4@@ -526,34 +526,48 @@
5 panel_shadow_matrix_ = matrix;
6 }
7
8-/* Currently unimplemented */
9-void UnityScreen::paintPanelShadow(const GLMatrix& matrix)
10+void UnityScreen::paintPanelShadow(const CompRegion& clip)
11 {
12- return;
13-
14 if (sources_.GetSource(local::RELAYOUT_TIMEOUT))
15 return;
16
17 if (PluginAdapter::Default()->IsExpoActive())
18 return;
19
20- nuxPrologue();
21-
22 CompOutput* output = _last_output;
23- float vc[4];
24- float h = 20.0f;
25- float w = 1.0f;
26 float panel_h = static_cast<float>(panel_style_.panel_height);
27
28- float x1 = output->x();
29- float y1 = output->y() + panel_h;
30- float x2 = x1 + output->width();
31- float y2 = y1 + h;
32-
33- vc[0] = x1;
34- vc[1] = x2;
35- vc[2] = y1;
36- vc[3] = y2;
37+ // You have no shadow texture. But how?
38+ if (_shadow_texture.empty() || !_shadow_texture[0])
39+ return;
40+
41+ float shadowX = output->x();
42+ float shadowY = output->y() + panel_h;
43+ float shadowWidth = output->width();
44+ float shadowHeight = _shadow_texture[0]->height();
45+ CompRect shadowRect(shadowX, shadowY, shadowWidth, shadowHeight);
46+
47+ CompRegion redraw(clip);
48+ redraw &= shadowRect;
49+
50+ if (redraw.isEmpty())
51+ return;
52+
53+ const CompRect& bounds(redraw.boundingRect());
54+
55+ // Sub-rectangle of the shadow needing redrawing:
56+ float x1 = bounds.x1();
57+ float y1 = bounds.y1();
58+ float x2 = bounds.x2();
59+ float y2 = bounds.y2();
60+
61+ // Texture coordinates of the above rectangle:
62+ float tx1 = (x1 - shadowX) / shadowWidth;
63+ float ty1 = (y1 - shadowY) / shadowHeight;
64+ float tx2 = (x2 - shadowX) / shadowWidth;
65+ float ty2 = (y2 - shadowY) / shadowHeight;
66+
67+ nuxPrologue();
68
69 // compiz doesn't use the same method of tracking monitors as our toolkit
70 // we need to make sure we properly associate with the right monitor
71@@ -594,17 +608,17 @@
72 };
73
74 vertexData = {
75- vc[0], vc[2], 0,
76- vc[0], vc[3], 0,
77- vc[1], vc[2], 0,
78- vc[1], vc[3], 0,
79+ x1, y1, 0,
80+ x1, y2, 0,
81+ x2, y1, 0,
82+ x2, y2, 0,
83 };
84
85 textureData = {
86- COMP_TEX_COORD_X(tex->matrix(), 0), COMP_TEX_COORD_Y(tex->matrix(), 0),
87- COMP_TEX_COORD_X(tex->matrix(), 0), COMP_TEX_COORD_Y(tex->matrix(), h),
88- COMP_TEX_COORD_X(tex->matrix(), w), COMP_TEX_COORD_Y(tex->matrix(), 0),
89- COMP_TEX_COORD_X(tex->matrix(), w), COMP_TEX_COORD_Y(tex->matrix(), h),
90+ tx1, ty1,
91+ tx1, ty2,
92+ tx2, ty1,
93+ tx2, ty2,
94 };
95
96 streamingBuffer->begin(GL_TRIANGLE_STRIP);
97@@ -614,7 +628,7 @@
98 streamingBuffer->addTexCoords(0, 4, &textureData[0]);
99
100 streamingBuffer->end();
101- streamingBuffer->render(matrix);
102+ streamingBuffer->render(panel_shadow_matrix_);
103
104 tex->disable();
105 if (!wasBlend)
106@@ -2373,7 +2387,7 @@
107 Window active_window = screen->activeWindow();
108 if (window->id() == active_window && window->type() != CompWindowTypeDesktopMask)
109 {
110- uScreen->paintPanelShadow(matrix);
111+ uScreen->paintPanelShadow(region);
112 }
113
114 bool ret = gWindow->glDraw(matrix, attrib, region, mask);
115@@ -2381,7 +2395,7 @@
116 if ((active_window == 0 || active_window == window->id()) &&
117 (window->type() == CompWindowTypeDesktopMask))
118 {
119- uScreen->paintPanelShadow(matrix);
120+ uScreen->paintPanelShadow(region);
121 }
122
123
124
125=== modified file 'plugins/unityshell/src/unityshell.h'
126--- plugins/unityshell/src/unityshell.h 2012-09-12 18:00:22 +0000
127+++ plugins/unityshell/src/unityshell.h 2012-09-17 03:47:21 +0000
128@@ -95,7 +95,7 @@
129
130 /* nux draw wrapper */
131 void paintDisplay();
132- void paintPanelShadow(const GLMatrix& matrix);
133+ void paintPanelShadow(const CompRegion& clip);
134 void setPanelShadowMatrix(const GLMatrix& matrix);
135
136 void preparePaint (int ms);