Merge lp:~3v1n0/unity/panel-opacity-toggle into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: 1770
Proposed branch: lp:~3v1n0/unity/panel-opacity-toggle
Merge into: lp:unity
Diff against target: 288 lines (+115/-16)
7 files modified
manual-tests/Panel.txt (+18/-0)
plugins/unityshell/src/PanelController.cpp (+20/-0)
plugins/unityshell/src/PanelController.h (+1/-0)
plugins/unityshell/src/PanelView.cpp (+51/-3)
plugins/unityshell/src/PanelView.h (+3/-0)
plugins/unityshell/src/unityshell.cpp (+4/-0)
plugins/unityshell/unityshell.xml.in (+18/-13)
To merge this branch: bzr merge lp:~3v1n0/unity/panel-opacity-toggle
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve
Neil J. Patel (community) Abstain
Review via email: mp+77219@code.launchpad.net

Description of the change

As requested on bug #807891 I've added an option to toggle the panel opacity if a window is currently maximized (and visible) in the current workspace.

Test is missing, it will be added once the autopilot will be available.

To post a comment you must log in.
Revision history for this message
Neil J. Patel (njpatel) wrote :

Hey Marco, I'm going to abstain on this until tomorrow when we branch for P, as it adds options etc which we won't get away with for O. Good work, though :)

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

No problem, I figured that... Who really cares about this option will use the PPA I guess ;)

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

Neil and Marco, is there a simple way we could test this in a unittest?

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

Mh, I think we can easily test the Panel::Controller::Impl but I'm not sure how we could automatize the check of the result. I'll look for a solution.

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

We should be able to easily add an autopilot test when it is ready I think.

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

Yes. I'll wait for that.

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

OK. Can we add a manual-test for this to be made into an autopilot test later.

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

Manual test added.

Revision history for this message
Tim Penhey (thumper) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'manual-tests/Panel.txt'
2--- manual-tests/Panel.txt 1970-01-01 00:00:00 +0000
3+++ manual-tests/Panel.txt 2011-12-08 04:17:34 +0000
4@@ -0,0 +1,18 @@
5+Panel Opacity Toggle
6+--------------------
7+This test shows how works the panel_opacity_maximized_toggle unity option
8+
9+#. Open CCSM
10+#. Go in the "Experimental" tab
11+#. Set the "Panel Opacity" setting to a value less than 1.0 (best is 0.0 for testing)
12+#. Enable the "Panel Opacity for Maximized Windows Toggle"
13+#. Close all your opened windows
14+#. The panel should be transparent according to the opacity setting
15+#. Now open a window and make sure it is restored
16+#. Open another Window and make it maximized
17+
18+Outcome
19+ When there's at least one maximized window on the current screen, the panel
20+ should become opaque, also if the opacity setting is set to 0.0.
21+ Once all the maximized windows are closed, restored or not visible,
22+ the panel should go back to its defined opacity.
23
24=== modified file 'plugins/unityshell/src/PanelController.cpp'
25--- plugins/unityshell/src/PanelController.cpp 2011-11-07 19:05:57 +0000
26+++ plugins/unityshell/src/PanelController.cpp 2011-12-08 04:17:34 +0000
27@@ -51,6 +51,8 @@
28
29 // NOTE: nux::Property maybe?
30 void SetOpacity(float opacity);
31+ void SetOpacityMaximizedToggle(bool enabled);
32+
33 float opacity() const;
34
35 private:
36@@ -64,12 +66,14 @@
37 private:
38 std::vector<nux::BaseWindow*> windows_;
39 float opacity_;
40+ bool opacity_maximized_toggle_;
41 bool open_menu_start_received_;
42 };
43
44
45 Controller::Impl::Impl()
46 : opacity_(1.0f)
47+ , opacity_maximized_toggle_(false)
48 , open_menu_start_received_(false)
49 {
50 UScreen* screen = UScreen::GetDefault();
51@@ -139,6 +143,16 @@
52 }
53 }
54
55+void Controller::Impl::SetOpacityMaximizedToggle(bool enabled)
56+{
57+ opacity_maximized_toggle_ = enabled;
58+
59+ for (auto window : windows_)
60+ {
61+ ViewForWindow(window)->SetOpacityMaximizedToggle(opacity_maximized_toggle_);
62+ }
63+}
64+
65 void Controller::Impl::QueueRedraw()
66 {
67 for (auto window: windows_)
68@@ -201,6 +215,7 @@
69 PanelView* view = new PanelView();
70 view->SetMaximumHeight(24);
71 view->SetOpacity(opacity_);
72+ view->SetOpacityMaximizedToggle(opacity_maximized_toggle_);
73 view->SetPrimary(i == primary_monitor);
74 view->SetMonitor(i);
75
76@@ -281,6 +296,11 @@
77 pimpl->SetOpacity(opacity);
78 }
79
80+void Controller::SetOpacityMaximizedToggle(bool enabled)
81+{
82+ pimpl->SetOpacityMaximizedToggle(enabled);
83+}
84+
85 void Controller::QueueRedraw()
86 {
87 pimpl->QueueRedraw();
88
89=== modified file 'plugins/unityshell/src/PanelController.h'
90--- plugins/unityshell/src/PanelController.h 2011-09-29 04:26:23 +0000
91+++ plugins/unityshell/src/PanelController.h 2011-12-08 04:17:34 +0000
92@@ -47,6 +47,7 @@
93
94 // NOTE: nux::Property maybe?
95 void SetOpacity(float opacity);
96+ void SetOpacityMaximizedToggle(bool enabled);
97 float opacity() const;
98
99 private:
100
101=== modified file 'plugins/unityshell/src/PanelView.cpp'
102--- plugins/unityshell/src/PanelView.cpp 2011-10-25 16:08:30 +0000
103+++ plugins/unityshell/src/PanelView.cpp 2011-12-08 04:17:34 +0000
104@@ -56,6 +56,7 @@
105 : View(NUX_FILE_LINE_PARAM),
106 _is_dirty(true),
107 _opacity(1.0f),
108+ _opacity_maximized_toggle(false),
109 _is_primary(false),
110 _monitor(0),
111 _dash_is_open(false)
112@@ -139,7 +140,12 @@
113 ubus_server_unregister_interest(ubus, _handle_bg_color_update);
114 ubus_server_unregister_interest(ubus, _handle_dash_hidden);
115 ubus_server_unregister_interest(ubus, _handle_dash_shown);
116- _on_indicator_updated_connections.clear();
117+
118+ for (auto conn : _on_indicator_updated_connections)
119+ conn.disconnect();
120+
121+ for (auto conn : _maximized_opacity_toggle_connections)
122+ conn.disconnect();
123
124 indicator::EntryLocationMap locations;
125 _remote->SyncGeometries(GetName() + boost::lexical_cast<std::string>(_monitor), locations);
126@@ -362,8 +368,10 @@
127 _last_width = geo.width;
128 _last_height = geo.height;
129 _is_dirty = false;
130+
131+ guint32 maximized_win = _menu_view->GetMaximizedWindow();
132
133- if (_dash_is_open && (_menu_view->GetMaximizedWindow() == 0))
134+ if (_dash_is_open && maximized_win == 0)
135 {
136 if (_bg_layer)
137 delete _bg_layer;
138@@ -375,7 +383,14 @@
139 }
140 else
141 {
142- nux::NBitmapData* bitmap = panel::Style::Instance().GetBackground(geo.width, geo.height, _opacity);
143+ double opacity = _opacity;
144+ if (_opacity_maximized_toggle && maximized_win != 0 &&
145+ !WindowManager::Default()->IsWindowObscured(maximized_win))
146+ {
147+ opacity = 1.0f;
148+ }
149+
150+ nux::NBitmapData* bitmap = panel::Style::Instance().GetBackground(geo.width, geo.height, opacity);
151 nux::BaseTexture* texture2D = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableTexture();
152 texture2D->Update(bitmap);
153 delete bitmap;
154@@ -599,6 +614,39 @@
155 ForceUpdateBackground();
156 }
157
158+void
159+PanelView::SetOpacityMaximizedToggle(bool enabled)
160+{
161+ if (_opacity_maximized_toggle != enabled)
162+ {
163+ if (enabled)
164+ {
165+ auto win_manager = WindowManager::Default();
166+ auto update_bg_lambda = [&](guint32) { ForceUpdateBackground(); };
167+ auto conn = &_maximized_opacity_toggle_connections;
168+
169+ conn->push_back(win_manager->window_minimized.connect(update_bg_lambda));
170+ conn->push_back(win_manager->window_unminimized.connect(update_bg_lambda));
171+ conn->push_back(win_manager->window_maximized.connect(update_bg_lambda));
172+ conn->push_back(win_manager->window_restored.connect(update_bg_lambda));
173+ conn->push_back(win_manager->window_mapped.connect(update_bg_lambda));
174+ conn->push_back(win_manager->window_unmapped.connect(update_bg_lambda));
175+ conn->push_back(win_manager->compiz_screen_viewport_switch_ended.connect(
176+ sigc::mem_fun(this, &PanelView::ForceUpdateBackground)));
177+ }
178+ else
179+ {
180+ for (auto conn : _maximized_opacity_toggle_connections)
181+ conn.disconnect();
182+
183+ _maximized_opacity_toggle_connections.clear();
184+ }
185+
186+ _opacity_maximized_toggle = enabled;
187+ ForceUpdateBackground();
188+ }
189+}
190+
191 bool
192 PanelView::GetPrimary()
193 {
194
195=== modified file 'plugins/unityshell/src/PanelView.h'
196--- plugins/unityshell/src/PanelView.h 2011-11-28 21:27:17 +0000
197+++ plugins/unityshell/src/PanelView.h 2011-12-08 04:17:34 +0000
198@@ -70,6 +70,7 @@
199 void EndFirstMenuShow();
200
201 void SetOpacity(float opacity);
202+ void SetOpacityMaximizedToggle(bool enabled);
203
204 void TrackMenuPointer();
205
206@@ -110,6 +111,7 @@
207 nux::Color _bg_color;
208 bool _is_dirty;
209 float _opacity;
210+ bool _opacity_maximized_toggle;
211 bool _needs_geo_sync;
212 bool _is_primary;
213 int _monitor;
214@@ -122,6 +124,7 @@
215 nux::Point _tracked_pointer_pos;
216
217 std::vector<sigc::connection> _on_indicator_updated_connections;
218+ std::vector<sigc::connection> _maximized_opacity_toggle_connections;
219 BackgroundEffectHelper bg_effect_helper_;
220 nux::ObjectPtr <nux::IOpenGLBaseTexture> bg_blur_texture_;
221 };
222
223=== modified file 'plugins/unityshell/src/unityshell.cpp'
224--- plugins/unityshell/src/unityshell.cpp 2011-12-06 21:35:59 +0000
225+++ plugins/unityshell/src/unityshell.cpp 2011-12-08 04:17:34 +0000
226@@ -239,6 +239,7 @@
227 optionSetLaunchAnimationNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
228 optionSetUrgentAnimationNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
229 optionSetPanelOpacityNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
230+ optionSetPanelOpacityMaximizedToggleNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
231 optionSetLauncherOpacityNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
232 optionSetIconSizeNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
233 optionSetAutohideAnimationNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
234@@ -2021,6 +2022,9 @@
235 case UnityshellOptions::PanelOpacity:
236 panel_controller_->SetOpacity(optionGetPanelOpacity());
237 break;
238+ case UnityshellOptions::PanelOpacityMaximizedToggle:
239+ panel_controller_->SetOpacityMaximizedToggle(optionGetPanelOpacityMaximizedToggle());
240+ break;
241 case UnityshellOptions::LauncherOpacity:
242 launcher.SetBackgroundAlpha(optionGetLauncherOpacity());
243 break;
244
245=== modified file 'plugins/unityshell/unityshell.xml.in'
246--- plugins/unityshell/unityshell.xml.in 2011-11-30 03:06:44 +0000
247+++ plugins/unityshell/unityshell.xml.in 2011-12-08 04:17:34 +0000
248@@ -242,22 +242,27 @@
249 </desc>
250 </option>
251 <option type="float" name="panel_opacity">
252- <_short>Panel Opacity</_short>
253- <_long>The opacity of the Panel background.</_long>
254- <default>1.0</default>
255- <min>0.0</min>
256- <max>1.0</max>
257- <precision>0.01</precision>
258+ <_short>Panel Opacity</_short>
259+ <_long>The opacity of the Panel background.</_long>
260+ <default>1.0</default>
261+ <min>0.0</min>
262+ <max>1.0</max>
263+ <precision>0.01</precision>
264+ </option>
265+ <option type="bool" name="panel_opacity_maximized_toggle">
266+ <_short>Panel Opacity for Maximized Windows Toggle.</_short>
267+ <_long>When a window is maximized and visible in the current viewport, the panel opacity is disabled</_long>
268+ <default>false</default>
269 </option>
270 <option type="float" name="launcher_opacity">
271- <_short>Launcher Opacity</_short>
272- <_long>The opacity of the Launcher background.</_long>
273- <default>0.6667</default>
274- <min>0.0</min>
275- <max>1.0</max>
276- <precision>0.0001</precision>
277+ <_short>Launcher Opacity</_short>
278+ <_long>The opacity of the Launcher background.</_long>
279+ <default>0.6667</default>
280+ <min>0.0</min>
281+ <max>1.0</max>
282+ <precision>0.0001</precision>
283 </option>
284- <option name="icon_size" type="int">
285+ <option name="icon_size" type="int">
286 <_short>Launcher icon size</_short>
287 <_long>The size of the launcher icons</_long>
288 <default>48</default>