Merge lp:~brandontschaefer/unity/keynav-alt+f1-expo-fix into lp:unity

Proposed by Brandon Schaefer
Status: Merged
Approved by: Thomi Richards
Approved revision: no longer in the source branch.
Merged at revision: 2430
Proposed branch: lp:~brandontschaefer/unity/keynav-alt+f1-expo-fix
Merge into: lp:unity
Diff against target: 59 lines (+30/-2)
2 files modified
launcher/LauncherController.cpp (+7/-2)
tests/autopilot/unity/tests/test_launcher.py (+23/-0)
To merge this branch: bzr merge lp:~brandontschaefer/unity/keynav-alt+f1-expo-fix
Reviewer Review Type Date Requested Status
Thomi Richards (community) quality Approve
Jason Smith (community) Approve
Review via email: mp+111262@code.launchpad.net

Commit message

Fixes focus problem when entering expo mode from KeyNav(Alt+F1).

Description of the change

=== Problem ===

When KeyNav would terminate it would activate the launcher icon before restoring input focus. This means in Alt+F1 mode the screen was still grabbed causing the focus in expo mode to fail. This was caused by a ubus message race condition.

=== Fix ===

Added a GLib::Idle fucntion for the activation, so the ubus call has time to finish before activating the icon.

=== Test ===

AP test included

To post a comment you must log in.
Revision history for this message
Jason Smith (jassmith) wrote :

Coolio :)

Like the use of the lambda

review: Approve
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

Looks good to me.

review: Approve (quality)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/LauncherController.cpp'
2--- launcher/LauncherController.cpp 2012-06-15 02:03:31 +0000
3+++ launcher/LauncherController.cpp 2012-06-20 20:55:18 +0000
4@@ -196,6 +196,7 @@
5
6 LauncherList launchers;
7
8+ glib::Source::UniquePtr activate_idle_;
9 glib::Object<BamfMatcher> matcher_;
10 glib::Signal<void, BamfMatcher*, BamfView*> view_opened_signal_;
11 glib::SourceManager sources_;
12@@ -1196,8 +1197,12 @@
13 g_variant_new_boolean(pimpl->keynav_restore_window_));
14 }
15
16- if (activate)
17- pimpl->model_->Selection()->Activate(ActionArg(ActionArg::LAUNCHER, 0));
18+ pimpl->activate_idle_.reset(new glib::Idle([&] () {
19+ if (activate)
20+ pimpl->model_->Selection()->Activate(ActionArg(ActionArg::LAUNCHER, 0));
21+
22+ return false;
23+ }));
24
25 pimpl->launcher_keynav = false;
26 if (!pimpl->launcher_open)
27
28=== modified file 'tests/autopilot/unity/tests/test_launcher.py'
29--- tests/autopilot/unity/tests/test_launcher.py 2012-06-18 05:20:12 +0000
30+++ tests/autopilot/unity/tests/test_launcher.py 2012-06-20 20:55:18 +0000
31@@ -378,6 +378,29 @@
32 self.assertTrue(calc.is_active)
33 self.assertFalse(mahjongg.is_active)
34
35+ def test_launcher_keynav_expo_focus(self):
36+ """When entering expo mode from KeyNav the Desktop must get focus."""
37+
38+ for icon in self.launcher.model.get_launcher_icons_for_monitor(self.launcher_monitor):
39+ if (icon.tooltip_text == "Workspace Switcher"):
40+ self.launcher_instance.key_nav_activate()
41+ break
42+ self.launcher_instance.key_nav_next()
43+
44+ self.assertThat(self.panels.get_active_panel().title, Eventually(Equals("Ubuntu Desktop")))
45+
46+ def test_launcher_keynav_expo_exit_on_esc(self):
47+ """Esc should quit expo when entering it from KeyNav."""
48+
49+ for icon in self.launcher.model.get_launcher_icons_for_monitor(self.launcher_monitor):
50+ if (icon.tooltip_text == "Workspace Switcher"):
51+ self.launcher_instance.key_nav_activate()
52+ break
53+ self.launcher_instance.key_nav_next()
54+
55+ self.keyboard.press_and_release("Escape")
56+ self.assertThat(self.window_manager.expo_active, Eventually(Equals(False)))
57+
58 def test_launcher_keynav_alt_tab_quits(self):
59 """Tests that alt+tab exits keynav mode."""
60