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
1=== modified file 'plugins/unityshell/src/HudController.cpp'
2--- plugins/unityshell/src/HudController.cpp 2012-04-02 00:16:21 +0000
3+++ plugins/unityshell/src/HudController.cpp 2012-04-03 03:16:20 +0000
4@@ -322,6 +322,8 @@
5 window_->EnableInputWindow(false, "Hud", true, false);
6 visible_ = false;
7
8+ nux::GetWindowCompositor().SetKeyFocusArea(NULL,nux::KEY_NAV_NONE);
9+
10 StartShowHideTimeline();
11
12 restore = true;
13
14=== modified file 'plugins/unityshell/src/LauncherController.cpp'
15--- plugins/unityshell/src/LauncherController.cpp 2012-04-02 03:10:50 +0000
16+++ plugins/unityshell/src/LauncherController.cpp 2012-04-03 03:16:20 +0000
17@@ -981,6 +981,13 @@
18 pimpl->launcher_label_show_handler_id_ = g_timeout_add(local::shortcuts_show_delay, show_shortcuts, pimpl);
19 }
20
21+bool Controller::AboutToShowDash(int was_tap, int when) const
22+{
23+ if ((when - pimpl->launcher_key_press_time_) < local::super_tap_duration && was_tap)
24+ return true;
25+ return false;
26+}
27+
28 void Controller::HandleLauncherKeyRelease(bool was_tap, int when)
29 {
30 int tap_duration = when - pimpl->launcher_key_press_time_;
31
32=== modified file 'plugins/unityshell/src/LauncherController.h'
33--- plugins/unityshell/src/LauncherController.h 2012-03-27 04:35:01 +0000
34+++ plugins/unityshell/src/LauncherController.h 2012-04-03 03:16:20 +0000
35@@ -60,6 +60,8 @@
36
37 void SetShowDesktopIcon(bool show_desktop_icon);
38
39+ bool AboutToShowDash(int was_tap, int when) const;
40+
41 void HandleLauncherKeyPress(int when);
42 void HandleLauncherKeyRelease(bool was_tap, int when);
43 bool HandleLauncherKeyEvent(Display *display,
44
45=== modified file 'plugins/unityshell/src/unityshell.cpp'
46--- plugins/unityshell/src/unityshell.cpp 2012-04-02 15:07:57 +0000
47+++ plugins/unityshell/src/unityshell.cpp 2012-04-03 03:16:20 +0000
48@@ -1597,6 +1597,9 @@
49 LOG_DEBUG(logger) << "Super released: " << (was_tap ? "tapped" : "released");
50 int when = options[7].value().i(); // XEvent time in millisec
51
52+ if (hud_controller_->IsVisible() && launcher_controller_->AboutToShowDash(was_tap, when))
53+ hud_controller_->HideHud();
54+
55 super_keypressed_ = false;
56 launcher_controller_->KeyNavTerminate(true);
57 launcher_controller_->HandleLauncherKeyRelease(was_tap, when);
58
59=== modified file 'tests/autopilot/autopilot/tests/test_hud.py'
60--- tests/autopilot/autopilot/tests/test_hud.py 2012-04-02 20:18:58 +0000
61+++ tests/autopilot/autopilot/tests/test_hud.py 2012-04-03 03:16:20 +0000
62@@ -219,14 +219,27 @@
63 self.dash.ensure_hidden()
64 self.assertThat(self.launcher.key_nav_is_active, Equals(False))
65
66+ def test_hud_to_dash_has_key_focus(self):
67+ """When switching from the hud to the dash you don't lose key focus."""
68+ self.hud.ensure_visible()
69+ sleep(1)
70+
71+ self.dash.ensure_visible()
72+ self.addCleanup(self.dash.ensure_hidden)
73+
74+ self.keyboard.type('focus1')
75+
76+ self.assertEqual(self.dash.search_string, 'focus1')
77+
78 def test_dash_to_hud_has_key_focus(self):
79 """When switching from the dash to the hud you don't lose key focus."""
80 self.dash.ensure_visible()
81- self.hud.toggle_reveal()
82+ self.hud.ensure_visible()
83 sleep(1)
84
85- self.keyboard.type('focus')
86- self.assertEqual(self.hud.searchbar.search_string, 'focus')
87+ self.keyboard.type('focus2')
88+
89+ self.assertEqual(self.hud.search_string, 'focus2')
90
91 def test_hud_closes_on_workspace_switch(self):
92 """This test shows that when you switch to another workspace the hud closes."""