Merge lp:~brandontschaefer/unity/hud-to-dash-fix into lp:unity

Proposed by Brandon Schaefer
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: 2215
Proposed branch: lp:~brandontschaefer/unity/hud-to-dash-fix
Merge into: lp:unity
Diff against target: 92 lines (+30/-3)
5 files modified
plugins/unityshell/src/HudController.cpp (+2/-0)
plugins/unityshell/src/LauncherController.cpp (+7/-0)
plugins/unityshell/src/LauncherController.h (+2/-0)
plugins/unityshell/src/unityshell.cpp (+3/-0)
tests/autopilot/autopilot/tests/test_hud.py (+16/-3)
To merge this branch: bzr merge lp:~brandontschaefer/unity/hud-to-dash-fix
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve
Review via email: mp+100064@code.launchpad.net

Commit message

Fixes the pinyin pop up box disappearing in the hud.

Description of the change

== Problem ==
When the Hud gets closed it doesn't emit end_key_nav, which resets the preedit box for ibus-pinyin engine. So when you reopened the Hud it wouldn't redraw the preedit window, because it didn't know it disappeared.

== Fix ==
The fix was to force Hud to lose key nav mode. This caused a problem with key focus when switching from the Hud to the Dash, this was fixed by making sure the Hud closes BEFORE the Dash opens.

== Test ==
Autopilot test

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

At the end of test_hud_to_dash_has_key_focus you shouldn't need to ensure_hidden on the dash.

If you do because it is a hud test, then change it so the test goes like this:

  self.dash.ensure_visible()
  self.addCleanup(self.dash.ensure_hidden)

That way if the assert fails, the dash is still hidden.

Also, PEP-8 says only one blank line between class methods.

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

Looks fine now.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/unityshell/src/HudController.cpp'
--- plugins/unityshell/src/HudController.cpp 2012-04-02 00:16:21 +0000
+++ plugins/unityshell/src/HudController.cpp 2012-04-03 03:16:20 +0000
@@ -322,6 +322,8 @@
322 window_->EnableInputWindow(false, "Hud", true, false);322 window_->EnableInputWindow(false, "Hud", true, false);
323 visible_ = false;323 visible_ = false;
324324
325 nux::GetWindowCompositor().SetKeyFocusArea(NULL,nux::KEY_NAV_NONE);
326
325 StartShowHideTimeline();327 StartShowHideTimeline();
326328
327 restore = true;329 restore = true;
328330
=== modified file 'plugins/unityshell/src/LauncherController.cpp'
--- plugins/unityshell/src/LauncherController.cpp 2012-04-02 03:10:50 +0000
+++ plugins/unityshell/src/LauncherController.cpp 2012-04-03 03:16:20 +0000
@@ -981,6 +981,13 @@
981 pimpl->launcher_label_show_handler_id_ = g_timeout_add(local::shortcuts_show_delay, show_shortcuts, pimpl);981 pimpl->launcher_label_show_handler_id_ = g_timeout_add(local::shortcuts_show_delay, show_shortcuts, pimpl);
982}982}
983983
984bool Controller::AboutToShowDash(int was_tap, int when) const
985{
986 if ((when - pimpl->launcher_key_press_time_) < local::super_tap_duration && was_tap)
987 return true;
988 return false;
989}
990
984void Controller::HandleLauncherKeyRelease(bool was_tap, int when)991void Controller::HandleLauncherKeyRelease(bool was_tap, int when)
985{992{
986 int tap_duration = when - pimpl->launcher_key_press_time_;993 int tap_duration = when - pimpl->launcher_key_press_time_;
987994
=== modified file 'plugins/unityshell/src/LauncherController.h'
--- plugins/unityshell/src/LauncherController.h 2012-03-27 04:35:01 +0000
+++ plugins/unityshell/src/LauncherController.h 2012-04-03 03:16:20 +0000
@@ -60,6 +60,8 @@
6060
61 void SetShowDesktopIcon(bool show_desktop_icon);61 void SetShowDesktopIcon(bool show_desktop_icon);
6262
63 bool AboutToShowDash(int was_tap, int when) const;
64
63 void HandleLauncherKeyPress(int when);65 void HandleLauncherKeyPress(int when);
64 void HandleLauncherKeyRelease(bool was_tap, int when);66 void HandleLauncherKeyRelease(bool was_tap, int when);
65 bool HandleLauncherKeyEvent(Display *display, 67 bool HandleLauncherKeyEvent(Display *display,
6668
=== modified file 'plugins/unityshell/src/unityshell.cpp'
--- plugins/unityshell/src/unityshell.cpp 2012-04-02 15:07:57 +0000
+++ plugins/unityshell/src/unityshell.cpp 2012-04-03 03:16:20 +0000
@@ -1597,6 +1597,9 @@
1597 LOG_DEBUG(logger) << "Super released: " << (was_tap ? "tapped" : "released");1597 LOG_DEBUG(logger) << "Super released: " << (was_tap ? "tapped" : "released");
1598 int when = options[7].value().i(); // XEvent time in millisec1598 int when = options[7].value().i(); // XEvent time in millisec
15991599
1600 if (hud_controller_->IsVisible() && launcher_controller_->AboutToShowDash(was_tap, when))
1601 hud_controller_->HideHud();
1602
1600 super_keypressed_ = false;1603 super_keypressed_ = false;
1601 launcher_controller_->KeyNavTerminate(true);1604 launcher_controller_->KeyNavTerminate(true);
1602 launcher_controller_->HandleLauncherKeyRelease(was_tap, when);1605 launcher_controller_->HandleLauncherKeyRelease(was_tap, when);
16031606
=== modified file 'tests/autopilot/autopilot/tests/test_hud.py'
--- tests/autopilot/autopilot/tests/test_hud.py 2012-04-02 20:18:58 +0000
+++ tests/autopilot/autopilot/tests/test_hud.py 2012-04-03 03:16:20 +0000
@@ -219,14 +219,27 @@
219 self.dash.ensure_hidden()219 self.dash.ensure_hidden()
220 self.assertThat(self.launcher.key_nav_is_active, Equals(False))220 self.assertThat(self.launcher.key_nav_is_active, Equals(False))
221221
222 def test_hud_to_dash_has_key_focus(self):
223 """When switching from the hud to the dash you don't lose key focus."""
224 self.hud.ensure_visible()
225 sleep(1)
226
227 self.dash.ensure_visible()
228 self.addCleanup(self.dash.ensure_hidden)
229
230 self.keyboard.type('focus1')
231
232 self.assertEqual(self.dash.search_string, 'focus1')
233
222 def test_dash_to_hud_has_key_focus(self):234 def test_dash_to_hud_has_key_focus(self):
223 """When switching from the dash to the hud you don't lose key focus."""235 """When switching from the dash to the hud you don't lose key focus."""
224 self.dash.ensure_visible()236 self.dash.ensure_visible()
225 self.hud.toggle_reveal()237 self.hud.ensure_visible()
226 sleep(1)238 sleep(1)
227239
228 self.keyboard.type('focus')240 self.keyboard.type('focus2')
229 self.assertEqual(self.hud.searchbar.search_string, 'focus')241
242 self.assertEqual(self.hud.search_string, 'focus2')
230243
231 def test_hud_closes_on_workspace_switch(self):244 def test_hud_closes_on_workspace_switch(self):
232 """This test shows that when you switch to another workspace the hud closes."""245 """This test shows that when you switch to another workspace the hud closes."""