Merge lp:~thomir-deactivatedaccount/unity/fix-hud-closing into lp:unity

Proposed by Thomi Richards
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: 2481
Proposed branch: lp:~thomir-deactivatedaccount/unity/fix-hud-closing
Merge into: lp:unity
Diff against target: 86 lines (+28/-2)
4 files modified
dash/DashView.cpp (+6/-2)
hud/HudView.cpp (+4/-0)
tests/autopilot/unity/tests/test_dash.py (+9/-0)
tests/autopilot/unity/tests/test_hud.py (+9/-0)
To merge this branch: bzr merge lp:~thomir-deactivatedaccount/unity/fix-hud-closing
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve
Review via email: mp+114089@code.launchpad.net

Commit message

Dash and hud now close on Alt+F4 even when the caps lock or num lock keys are active.

Description of the change

Problem:

The dash and the hud are supposed to close on Alt+F4, but this doesn't work if the caps lock or num lock keys are active.

Solution:

This branch fixes that.

Tests:

There are two more autopilot tests that cover this code.

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

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dash/DashView.cpp'
2--- dash/DashView.cpp 2012-07-04 02:37:23 +0000
3+++ dash/DashView.cpp 2012-07-10 03:30:31 +0000
4@@ -227,7 +227,7 @@
5 nux::Geometry const& geo = GetGeometry();
6 content_geo_ = GetBestFitGeometry(geo);
7 dash::Style& style = dash::Style::Instance();
8-
9+
10 if (style.always_maximised)
11 {
12 if (geo.width >= content_geo_.width && geo.height > content_geo_.height)
13@@ -460,7 +460,7 @@
14 });
15
16 // global search done is handled by the home lens, no need to connect to it
17- // BUT, we will special case global search finished coming from
18+ // BUT, we will special case global search finished coming from
19 // the applications lens, because we want to be able to launch applications
20 // immediately without waiting for the search finished signal which will
21 // be delayed by all the lenses we're searching
22@@ -766,6 +766,10 @@
23 unsigned long x11_key_code,
24 unsigned long special_keys_state)
25 {
26+ // Only care about states of Alt, Ctrl, Super, Shift, not the lock keys
27+ special_keys_state &= (nux::NUX_STATE_ALT | nux::NUX_STATE_CTRL |
28+ nux::NUX_STATE_SUPER | nux::NUX_STATE_SHIFT);
29+
30 // Do what nux::View does, but if the event isn't a key navigation,
31 // designate the text entry to process it.
32
33
34=== modified file 'hud/HudView.cpp'
35--- hud/HudView.cpp 2012-07-04 02:37:23 +0000
36+++ hud/HudView.cpp 2012-07-10 03:30:31 +0000
37@@ -565,6 +565,10 @@
38 unsigned long x11_key_code,
39 unsigned long special_keys_state)
40 {
41+ // Only care about states of Alt, Ctrl, Super, Shift, not the lock keys
42+ special_keys_state &= (nux::NUX_STATE_ALT | nux::NUX_STATE_CTRL |
43+ nux::NUX_STATE_SUPER | nux::NUX_STATE_SHIFT);
44+
45 nux::KeyNavDirection direction = nux::KEY_NAV_NONE;
46 switch (x11_key_code)
47 {
48
49=== modified file 'tests/autopilot/unity/tests/test_dash.py'
50--- tests/autopilot/unity/tests/test_dash.py 2012-07-04 02:37:23 +0000
51+++ tests/autopilot/unity/tests/test_dash.py 2012-07-10 03:30:31 +0000
52@@ -62,6 +62,15 @@
53 self.keyboard.press_and_release("Alt+F4")
54 self.assertThat(self.dash.visible, Eventually(Equals(False)))
55
56+ def test_alt_f4_close_dash_with_capslock_on(self):
57+ """Dash must close on Alt+F4 even when the capslock is turned on."""
58+ self.keyboard.press_and_release("Caps_Lock")
59+ self.addCleanup(self.keyboard.press_and_release, "Caps_Lock")
60+
61+ self.dash.ensure_visible()
62+ self.keyboard.press_and_release("Alt+F4")
63+ self.assertThat(self.dash.visible, Eventually(Equals(False)))
64+
65 def test_dash_closes_on_spread(self):
66 """This test shows that when the spread is initiated, the dash closes."""
67 self.dash.ensure_visible()
68
69=== modified file 'tests/autopilot/unity/tests/test_hud.py'
70--- tests/autopilot/unity/tests/test_hud.py 2012-07-06 00:12:18 +0000
71+++ tests/autopilot/unity/tests/test_hud.py 2012-07-10 03:30:31 +0000
72@@ -254,6 +254,15 @@
73 self.keyboard.press_and_release("Alt+F4")
74 self.assertThat(self.hud.visible, Eventually(Equals(False)))
75
76+ def test_alt_f4_close_hud_with_capslock_on(self):
77+ """Hud must close on Alt+F4 even when the capslock is turned on."""
78+ self.keyboard.press_and_release("Caps_Lock")
79+ self.addCleanup(self.keyboard.press_and_release, "Caps_Lock")
80+
81+ self.hud.ensure_visible()
82+ self.keyboard.press_and_release("Alt+F4")
83+ self.assertThat(self.hud.visible, Eventually(Equals(False)))
84+
85
86 class HudLauncherInteractionsTests(HudTestsBase):
87