Merge lp:~brandontschaefer/unity/hud-to-dash-loses-win-focus into lp:unity

Proposed by Brandon Schaefer on 2012-04-18
Status: Merged
Approved by: Andrea Azzarone on 2012-04-18
Approved revision: 2308
Merged at revision: 2308
Proposed branch: lp:~brandontschaefer/unity/hud-to-dash-loses-win-focus
Merge into: lp:unity
Diff against target: 59 lines (+29/-5)
2 files modified
plugins/unityshell/src/DashController.cpp (+0/-2)
tests/autopilot/autopilot/tests/test_dash.py (+29/-3)
To merge this branch: bzr merge lp:~brandontschaefer/unity/hud-to-dash-loses-win-focus
Reviewer Review Type Date Requested Status
Andrea Azzarone Approve on 2012-04-18
Thomi Richards (community) 2012-04-18 Approve on 2012-04-18
Review via email: mp+102598@code.launchpad.net

Commit Message

Fixed going from the Hud to the Dash forgetting window focus when exiting from the Dash.

Description of the Change

=== Problem ===
Going from the Hud to the Dash and then quiting causes the window focus to be lost.

=== Fix ===
This line of code adapter->saveInputFoucs() was causing the problem, removed it. It makes AdapterPlugin::restoreInputFocus() use m_Screen->focusDefaultWindow() instead of using the _last_focused_window.

=== Test ===
AP test included, and all Dash AP test pass.

To post a comment you must log in.
Thomi Richards (thomir) wrote :

+1

review: Approve
Thomi Richards (thomir) :
review: Approve
Andrea Azzarone (azzar1) wrote :

How can this work if you remove the call to saveInputFocus?

review: Needs Information
Andrea Azzarone (azzar1) wrote :

> How can this work if you remove the call to saveInputFocus?
How can this work if you're removing the call to saveInputFocus?

review: Needs Information
Andrea Azzarone (azzar1) wrote :

Btw it works so +1

review: Approve
Brandon Schaefer (brandontschaefer) wrote :

> > How can this work if you remove the call to saveInputFocus?
> How can this work if you're removing the call to saveInputFocus?

It makes it use m_Screen->focusDefaultWindow() which gets the top window on the screen. I can't find a case where this wont work correctly...It is also how the Hud does it.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/DashController.cpp'
2--- plugins/unityshell/src/DashController.cpp 2012-04-18 14:06:50 +0000
3+++ plugins/unityshell/src/DashController.cpp 2012-04-18 22:02:20 +0000
4@@ -268,8 +268,6 @@
5 return;
6 }
7
8- adaptor->saveInputFocus ();
9-
10 view_->AboutToShow();
11
12 window_->ShowWindow(true);
13
14=== modified file 'tests/autopilot/autopilot/tests/test_dash.py'
15--- tests/autopilot/autopilot/tests/test_dash.py 2012-04-18 20:50:16 +0000
16+++ tests/autopilot/autopilot/tests/test_dash.py 2012-04-18 22:02:20 +0000
17@@ -262,9 +262,7 @@
18 """This test that Alt+F1 is disabled when the dash is opened."""
19 self.dash.ensure_visible()
20
21- launcher = self.launcher.get_launcher_for_monitor(0)
22- launcher.key_nav_start()
23-
24+ self.keybinding("launcher/keynav")
25 self.assertThat(self.launcher.key_nav_is_active, Equals(False))
26
27
28@@ -508,3 +506,31 @@
29
30 self.assertThat(self.dash.visible, Eventually(Equals(True)))
31
32+class DashRestoreFocus(DashTestCase):
33+ """Tests that the dash restores focus on exit."""
34+ def setUp(self):
35+ super(DashRestoreFocus,self).setUp()
36+
37+ def test_dash_restores_window_focus(self):
38+ """Make sure the dash restores the last focused window."""
39+ calc = self.start_app("Calculator")
40+ [calc_win] = calc.get_windows()
41+ self.assertTrue(calc_win.is_focused)
42+
43+ self.dash.ensure_visible()
44+ self.dash.ensure_hidden()
45+
46+ self.assertTrue(calc_win.is_focused)
47+
48+ def test_hud_to_dash_restores_window_focus(self):
49+ """Make sure the hud->dash restores the last focused window."""
50+ calc = self.start_app("Calculator")
51+ [calc_win] = calc.get_windows()
52+ self.assertTrue(calc_win.is_focused)
53+
54+ self.keybinding("hud/reveal")
55+ self.dash.ensure_visible()
56+ self.dash.ensure_hidden()
57+
58+ self.assertTrue(calc_win.is_focused)
59+