Merge lp:~unity-team/unity/fixes.unityshell-overlay into lp:unity

Proposed by Brandon Schaefer on 2012-03-27
Status: Merged
Approved by: Brandon Schaefer on 2012-03-30
Approved revision: 2180
Merged at revision: 2194
Proposed branch: lp:~unity-team/unity/fixes.unityshell-overlay
Merge into: lp:unity
Diff against target: 290 lines (+85/-16)
9 files modified
plugins/unityshell/src/DashController.h (+2/-1)
plugins/unityshell/src/Launcher.h (+2/-1)
plugins/unityshell/src/LauncherController.cpp (+10/-0)
plugins/unityshell/src/LauncherController.h (+2/-0)
plugins/unityshell/src/LauncherIcon.cpp (+1/-0)
plugins/unityshell/src/unityshell.cpp (+19/-13)
plugins/unityshell/src/unityshell.h (+0/-1)
tests/autopilot/autopilot/emulators/unity/hud.py (+10/-0)
tests/autopilot/autopilot/tests/test_hud.py (+39/-0)
To merge this branch: bzr merge lp:~unity-team/unity/fixes.unityshell-overlay
Reviewer Review Type Date Requested Status
Thomi Richards (community) 2012-03-27 Approve on 2012-03-28
Review via email: mp+99462@code.launchpad.net

Commit Message

Fixes unityshell.cpp not taking into account of the hud overlay being active.

Description of the Change

== Problem ==
The hud being open in the unityshell wasn't taken into account. As it is an overlay there were somethings not happening for it. One big thing was input focus, now switching from the dash->hud works correctly!

The problem being is if you have the dash open then open the hud it opens the hud THEN closes the dash. This caused the dash to set key focus to NULL, which would remove key focus from the hud that had already been opened.

Also switching workspace didn't close the hud for me.

Along with make sure alt+f1 is disabled when the hud is opened.

== Fix ==
Exposed HideDash, so when the hud is about to show we can correctly close the dash BEFORE we open the hud.

Made an IsOverlayOpen function for LauncherController, which checks if any launchers have an overlay open. Using this in unityshell.cpp instead of keeping track of a boolean dash_is_open, which wasn't getting updated correctly.

== Test ==
Lots of autopilot!
-Make sure Alt+F1 is disabled
-Open Hud->Dash, make sure Alt+F1 is disabled
-Open Dash->Hud and make sure we have key focus
-Make sure the Hud closes when you switch workspaces

To post a comment you must log in.
Tim Penhey (thumper) wrote :

launcher_controller_->launcher() doesn't give the active launcher, but the launcher for window 0, so perhaps not best to use it that way :(

Tim Penhey (thumper) wrote :

Perhaps a better way is to add a method to LauncherController, for IsOverlayOpen, which traverses all its launchers, and returns true if any are true.

Brandon Schaefer (brandontschaefer) wrote :

Thanks, good catch. Plus it looks better when used. As opposed to launcher_controller->launcher().IsOverlayOpen()...

Tim Penhey (thumper) wrote :

Much better.

Thomi Richards (thomir) wrote :

Approved, thanks!

review: Approve
Unity Merger (unity-merger) wrote :

No commit message specified.

Unity Merger (unity-merger) wrote :

Attempt to merge into lp:unity failed due to conflicts:

text conflict in plugins/unityshell/src/unityshell.cpp
text conflict in tests/autopilot/autopilot/emulators/unity/hud.py
text conflict in tests/autopilot/autopilot/tests/test_hud.py

2180. By Brandon Schaefer on 2012-03-30

* merged trunk, conficts resolved

Brandon Schaefer (brandontschaefer) wrote :

Ran 42 tests in 158.498s
OK

All Hud ap test pass.

Brandon Schaefer (brandontschaefer) wrote :

Opps, wrong mp...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/DashController.h'
2--- plugins/unityshell/src/DashController.h 2012-03-21 12:31:11 +0000
3+++ plugins/unityshell/src/DashController.h 2012-03-30 04:03:19 +0000
4@@ -56,6 +56,8 @@
5
6 sigc::signal<void> on_realize;
7
8+ void HideDash(bool restore_focus = true);
9+
10 protected:
11 std::string GetName() const;
12 void AddProperties(GVariantBuilder* builder);
13@@ -78,7 +80,6 @@
14 void OnActivateRequest(GVariant* variant);
15
16 void ShowDash();
17- void HideDash(bool restore_focus = true);
18
19 void StartShowHideTimeline();
20 static gboolean OnViewShowHideFrame(Controller* self);
21
22=== modified file 'plugins/unityshell/src/Launcher.h'
23--- plugins/unityshell/src/Launcher.h 2012-03-28 02:42:13 +0000
24+++ plugins/unityshell/src/Launcher.h 2012-03-30 04:03:19 +0000
25@@ -130,6 +130,8 @@
26 void ExitKeyNavMode();
27 bool IsInKeyNavMode() const;
28
29+ bool IsOverlayOpen() const;
30+
31 static const int ANIM_DURATION_SHORT;
32
33 void RenderIconToTexture(nux::GraphicsEngine& GfxContext, AbstractLauncherIcon::Ptr icon, nux::ObjectPtr<nux::IOpenGLBaseTexture> texture);
34@@ -274,7 +276,6 @@
35
36 void OnOverlayHidden(GVariant* data);
37 void OnOverlayShown(GVariant* data);
38- bool IsOverlayOpen() const;
39
40 void DesaturateIcons();
41 void SaturateIcons();
42
43=== modified file 'plugins/unityshell/src/LauncherController.cpp'
44--- plugins/unityshell/src/LauncherController.cpp 2012-03-28 02:42:13 +0000
45+++ plugins/unityshell/src/LauncherController.cpp 2012-03-30 04:03:19 +0000
46@@ -1142,6 +1142,16 @@
47 return pimpl->launcher_keynav;
48 }
49
50+bool Controller::IsOverlayOpen() const
51+{
52+ for (auto launcher_ptr : pimpl->launchers)
53+ {
54+ if (launcher_ptr->IsOverlayOpen())
55+ return true;
56+ }
57+ return false;
58+}
59+
60 std::string
61 Controller::GetName() const
62 {
63
64=== modified file 'plugins/unityshell/src/LauncherController.h'
65--- plugins/unityshell/src/LauncherController.h 2012-03-21 12:31:11 +0000
66+++ plugins/unityshell/src/LauncherController.h 2012-03-30 04:03:19 +0000
67@@ -75,6 +75,8 @@
68 void KeyNavPrevious();
69 bool KeyNavIsActive() const;
70
71+ bool IsOverlayOpen() const;
72+
73 protected:
74 // Introspectable methods
75 std::string GetName() const;
76
77=== modified file 'plugins/unityshell/src/LauncherIcon.cpp'
78--- plugins/unityshell/src/LauncherIcon.cpp 2012-03-27 15:00:59 +0000
79+++ plugins/unityshell/src/LauncherIcon.cpp 2012-03-30 04:03:19 +0000
80@@ -77,6 +77,7 @@
81 , _present_time_handle(0)
82 , _time_delay_handle(0)
83 , _sort_priority(0)
84+ , _last_monitor(0)
85 , _background_color(nux::color::White)
86 , _glow_color(nux::color::White)
87 , _shortcut(0)
88
89=== modified file 'plugins/unityshell/src/unityshell.cpp'
90--- plugins/unityshell/src/unityshell.cpp 2012-03-29 14:31:40 +0000
91+++ plugins/unityshell/src/unityshell.cpp 2012-03-30 04:03:19 +0000
92@@ -124,7 +124,6 @@
93 #ifndef USE_GLES
94 , _active_fbo (0)
95 #endif
96- , dash_is_open_ (false)
97 , grab_index_ (0)
98 , painting_tray_ (false)
99 , last_scroll_event_(0)
100@@ -360,12 +359,10 @@
101
102 BackgroundEffectHelper::updates_enabled = true;
103
104- ubus_manager_.RegisterInterest(UBUS_OVERLAY_SHOWN, [&](GVariant * args) {
105- dash_is_open_ = true;
106+ ubus_manager_.RegisterInterest(UBUS_OVERLAY_SHOWN, [&](GVariant * args) {
107 dash_monitor_ = g_variant_get_int32(args);
108 RaiseInputWindows();
109 });
110- ubus_manager_.RegisterInterest(UBUS_OVERLAY_HIDDEN, [&](GVariant * args) { dash_is_open_ = false; });
111 LOG_INFO(logger) << "UnityScreen constructed: " << timer.ElapsedSeconds() << "s";
112 }
113 }
114@@ -572,7 +569,8 @@
115 i++;
116 }
117
118- if (!(dash_is_open_ && current_monitor == dash_monitor_) && panel_controller_->opacity() > 0.0f)
119+ if (!(launcher_controller_->IsOverlayOpen() && current_monitor == dash_monitor_)
120+ && panel_controller_->opacity() > 0.0f)
121 {
122 foreach(GLTexture * tex, _shadow_texture)
123 {
124@@ -650,7 +648,8 @@
125 i++;
126 }
127
128- if (!(dash_is_open_ && current_monitor == dash_monitor_) && panel_controller_->opacity() > 0.0f)
129+ if (!(launcher_controller_->IsOverlayOpen() && current_monitor == dash_monitor_)
130+ && panel_controller_->opacity() > 0.0f)
131 {
132 foreach(GLTexture * tex, _shadow_texture)
133 {
134@@ -853,8 +852,8 @@
135 bool UnityScreen::forcePaintOnTop ()
136 {
137 return !allowWindowPaint ||
138- ((switcher_controller_->Visible() ||
139- dash_is_open_) && !fullscreen_windows_.empty () && (!(screen->grabbed () && !screen->otherGrabExist (NULL))));
140+ ((switcher_controller_->Visible() || launcher_controller_->IsOverlayOpen())
141+ && !fullscreen_windows_.empty () && (!(screen->grabbed () && !screen->otherGrabExist (NULL))));
142 }
143
144 void UnityWindow::paintThumbnail (nux::Geometry const& bounding, float alpha)
145@@ -1341,7 +1340,7 @@
146 #ifndef USE_GLES
147 cScreen->damageScreen(); // evil hack
148 #endif
149- if (_key_nav_mode_requested && !dash_is_open_)
150+ if (_key_nav_mode_requested && !launcher_controller_->IsOverlayOpen())
151 launcher_controller_->KeyNavGrab();
152 _key_nav_mode_requested = false;
153 break;
154@@ -1521,7 +1520,7 @@
155 PluginAdapter::Default()->NotifyCompizEvent(plugin, event, option);
156 compiz::CompizMinimizedWindowHandler<UnityScreen, UnityWindow>::handleCompizEvent (plugin, event, option);
157
158- if (dash_is_open_ && g_strcmp0(event, "start_viewport_switch") == 0)
159+ if (launcher_controller_->IsOverlayOpen() && g_strcmp0(event, "start_viewport_switch") == 0)
160 {
161 ubus_manager_.SendMessage(UBUS_PLACE_VIEW_CLOSE_REQUEST);
162 }
163@@ -1638,6 +1637,10 @@
164
165 void UnityScreen::SendExecuteCommand()
166 {
167+ if (hud_controller_->IsVisible())
168+ {
169+ hud_controller_->HideHud();
170+ }
171 ubus_manager_.SendMessage(UBUS_PLACE_ENTRY_ACTIVATE_REQUEST,
172 g_variant_new("(sus)", "commands.lens", 0, ""));
173 }
174@@ -1978,9 +1981,12 @@
175 {
176 // Handles closing KeyNav (Alt+F1) if the hud is about to show
177 if (launcher_controller_->KeyNavIsActive())
178- {
179 launcher_controller_->KeyNavTerminate(false);
180- }
181+
182+ // If an overlay is open, it must be the dash! Close it!
183+ if (launcher_controller_->IsOverlayOpen())
184+ dash_controller_->HideDash();
185+
186 hud_controller_->ShowHud();
187 }
188
189@@ -2357,7 +2363,7 @@
190 UnityScreen* us = UnityScreen::get(screen);
191 CompWindow *lw;
192
193- if (us->dash_is_open_)
194+ if (us->launcher_controller_->IsOverlayOpen())
195 {
196 lw = screen->findWindow(us->launcher_controller_->LauncherWindowId(0));
197 lw->moveInputFocusTo();
198
199=== modified file 'plugins/unityshell/src/unityshell.h'
200--- plugins/unityshell/src/unityshell.h 2012-03-29 05:14:03 +0000
201+++ plugins/unityshell/src/unityshell.h 2012-03-30 04:03:19 +0000
202@@ -330,7 +330,6 @@
203 bool queryForShader ();
204
205 UBusManager ubus_manager_;
206- bool dash_is_open_;
207 int dash_monitor_;
208 CompScreen::GrabHandle grab_index_;
209 CompWindowList fullscreen_windows_;
210
211=== modified file 'tests/autopilot/autopilot/emulators/unity/hud.py'
212--- tests/autopilot/autopilot/emulators/unity/hud.py 2012-03-27 22:48:34 +0000
213+++ tests/autopilot/autopilot/emulators/unity/hud.py 2012-03-30 04:03:19 +0000
214@@ -9,10 +9,16 @@
215
216 from autopilot.keybindings import KeybindingsHelper
217 from autopilot.emulators.unity import UnityIntrospectionObject
218+from autopilot.emulators.unity.dash import SearchBar
219
220
221 class HudView(UnityIntrospectionObject):
222 """Proxy object for the hud view child of the controller."""
223+
224+ @property
225+ def searchbar(self):
226+ """Get the search bar attached to this hud view."""
227+ return self.get_children_by_type(SearchBar)[0]
228
229 @property
230 def geometry(self):
231@@ -59,6 +65,10 @@
232 return views[0] if views else None
233
234 @property
235+ def searchbar(self):
236+ """Returns the searchbar attached to the hud."""
237+ return self._get_view().searchbar;
238+
239 def geometry(self):
240 return (self.x, self.y, self.width, self.height)
241
242
243=== modified file 'tests/autopilot/autopilot/tests/test_hud.py'
244--- tests/autopilot/autopilot/tests/test_hud.py 2012-03-29 20:25:35 +0000
245+++ tests/autopilot/autopilot/tests/test_hud.py 2012-03-30 04:03:19 +0000
246@@ -205,6 +205,45 @@
247 contents = open("/tmp/autopilot_gedit_undo_test_temp_file.txt").read().strip('\n')
248 self.assertEqual("0 ", contents)
249
250+ def test_disabled_alt_f1(self):
251+ """This test shows that Alt+F1 mode is disabled for the hud."""
252+ self.hud.toggle_reveal()
253+
254+ launcher = self.launcher.get_launcher_for_monitor(0)
255+ launcher.key_nav_start()
256+
257+ self.assertThat(self.launcher.key_nav_is_active, Equals(False))
258+
259+ def test_hud_to_dash_disabled_alt_f1(self):
260+ """When switching from the hud to the dash alt+f1 is disabled."""
261+ self.hud.toggle_reveal()
262+ sleep(1)
263+
264+ self.dash.ensure_visible()
265+
266+ launcher = self.launcher.get_launcher_for_monitor(0)
267+ launcher.key_nav_start()
268+
269+ self.dash.ensure_hidden()
270+ self.assertThat(self.launcher.key_nav_is_active, Equals(False))
271+
272+ def test_dash_to_hud_has_key_focus(self):
273+ """When switching from the dash to the hud you don't lose key focus."""
274+ self.dash.ensure_visible()
275+ self.hud.toggle_reveal()
276+ sleep(1)
277+
278+ self.keyboard.type('focus')
279+
280+ self.assertEqual(self.hud.searchbar.search_string, 'focus')
281+
282+ def test_hud_closes_on_workspace_switch(self):
283+ """This test shows that when you switch to another workspace the hud closes."""
284+ self.hud.toggle_reveal()
285+ sleep(1)
286+
287+ self.workspace.switch_to(1)
288+ self.workspace.switch_to(2)
289
290 class HudLauncherInteractionsTests(HudTestsBase):
291