Merge lp:~azzar1/unity/fix-934062 into lp:unity

Proposed by Andrea Azzarone
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 2468
Proposed branch: lp:~azzar1/unity/fix-934062
Merge into: lp:unity
Diff against target: 148 lines (+20/-93)
2 files modified
plugins/unityshell/src/unityshell.cpp (+13/-15)
tests/autopilot/unity/tests/test_shortcut_hint.py (+7/-78)
To merge this branch: bzr merge lp:~azzar1/unity/fix-934062
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
jenkins (community) continuous-integration Approve
Review via email: mp+113066@code.launchpad.net

Commit message

Close the overlay is a modifier key is pressed. Don't treat super+tab as a special case.

Description of the change

== Problem ==
"Keyboard Shortcuts" overlay can cause annoyance

== Fix ==
Close the overlay if a modifier key is pressed. Super + TAB must not be treated as a special case! [1]

== Test ==
AP test added.

[1] https://bugs.launchpad.net/unity/+bug/934062/comments/27

To post a comment you must log in.
Revision history for this message
jenkins (martin-mrazik+qa) wrote :

PASSED: Continuous integration, rev:2457
http://s-jenkins:8080/job/unity-ci/53/

review: Approve (continuous-integration)
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

It's sad to remove so much tests, but... I have to approve this... :/

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/unityshell.cpp'
2--- plugins/unityshell/src/unityshell.cpp 2012-06-29 20:35:23 +0000
3+++ plugins/unityshell/src/unityshell.cpp 2012-07-02 15:44:22 +0000
4@@ -1407,6 +1407,19 @@
5 break;
6 case KeyPress:
7 {
8+ if (super_keypressed_)
9+ {
10+ /* We need an idle to postpone this action, after the current event
11+ * has been processed */
12+ sources_.Add(std::make_shared<glib::Idle>([&]() {
13+ shortcut_controller_->SetEnabled(false);
14+ shortcut_controller_->Hide();
15+ EnableCancelAction(CancelActionTarget::SHORTCUT_HINT, false);
16+
17+ return false;
18+ }));
19+ }
20+
21 KeySym key_sym;
22 char key_string[2];
23 int result = XLookupString(&(event->xkey), key_string, 2, &key_sym, 0);
24@@ -1434,21 +1447,6 @@
25
26 if (super_keypressed_)
27 {
28- if (key_sym != XK_Escape || (key_sym == XK_Escape && !launcher_controller_->KeyNavIsActive()))
29- {
30- /* We need an idle to postpone this action, after the current event
31- * has been processed */
32- sources_.Add(std::make_shared<glib::Idle>([&]() {
33- if (!launcher_controller_->KeyNavIsActive())
34- {
35- shortcut_controller_->SetEnabled(false);
36- shortcut_controller_->Hide();
37- EnableCancelAction(CancelActionTarget::SHORTCUT_HINT, false);
38- }
39- return false;
40- }));
41- }
42-
43 skip_other_plugins = launcher_controller_->HandleLauncherKeyEvent(screen->dpy(), key_sym, event->xkey.keycode, event->xkey.state, key_string);
44 if (!skip_other_plugins)
45 skip_other_plugins = dash_controller_->CheckShortcutActivation(key_string);
46
47=== modified file 'tests/autopilot/unity/tests/test_shortcut_hint.py'
48--- tests/autopilot/unity/tests/test_shortcut_hint.py 2012-05-17 11:52:32 +0000
49+++ tests/autopilot/unity/tests/test_shortcut_hint.py 2012-07-02 15:44:22 +0000
50@@ -104,6 +104,13 @@
51 self.keybinding_tap("expo/start")
52 self.addCleanup(self.keybinding, "expo/cancel")
53
54+ def test_shortcut_hint_hide_pressing_modifiers(self):
55+ """Pressing a modifer key must hide the shortcut hint."""
56+ self.shortcut_hint.ensure_visible()
57+ self.addCleanup(self.shortcut_hint.ensure_hidden)
58+
59+ self.keyboard.press('Control')
60+
61 self.assertThat(self.shortcut_hint.visible, Eventually(Equals(False)))
62
63 def test_launcher_switcher_next_doesnt_show_shortcut_hint(self):
64@@ -133,84 +140,6 @@
65
66 self.assertThat(self.shortcut_hint.visible, Equals(False))
67
68- def test_launcher_switcher_next_keeps_shortcut_hint(self):
69- """Super+Tab switcher cycling forwards must not dispel an already-showing
70- shortcut hint.
71-
72- """
73- show_timeout = self.shortcut_hint.get_show_timeout()
74- self.shortcut_hint.ensure_visible()
75- self.addCleanup(self.shortcut_hint.ensure_hidden)
76-
77- self.keybinding("launcher/switcher/next")
78- self.addCleanup(self.keyboard.press_and_release, "Escape")
79-
80- self.assertThat(self.launcher.key_nav_is_active, Equals(True))
81-
82- self.keybinding("launcher/switcher/next")
83- sleep(show_timeout * 2)
84- self.assertThat(self.shortcut_hint.visible, Equals(True))
85-
86- def test_launcher_switcher_prev_keeps_shortcut_hint(self):
87- """Super+Tab switcher cycling backwards must not dispel an already-showing
88- shortcut hint.
89-
90- """
91- show_timeout = self.shortcut_hint.get_show_timeout()
92- self.shortcut_hint.ensure_visible()
93- self.addCleanup(self.shortcut_hint.ensure_visible)
94-
95- self.keybinding("launcher/switcher/next")
96- self.addCleanup(self.keyboard.press_and_release, "Escape")
97- self.assertThat(self.launcher.key_nav_is_active, Equals(True))
98-
99- self.keybinding("launcher/switcher/prev")
100- self.keybinding("launcher/switcher/prev")
101- sleep(show_timeout * 2)
102- self.assertThat(self.shortcut_hint.visible, Equals(True))
103-
104- def test_launcher_switcher_cancel_doesnt_hide_shortcut_hint(self):
105- """Cancelling the launcher switcher (by Escape) must not hide the
106- shortcut hint view.
107-
108- """
109- self.shortcut_hint.ensure_visible()
110- self.addCleanup(self.shortcut_hint.ensure_hidden)
111-
112- self.keybinding("launcher/switcher/next")
113- # NOTE: This will generate an extra Escape keypress if the test passes,
114- # but that's better than the alternative...
115- self.addCleanup(self.keybinding, "launcher/switcher/exit")
116-
117- self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(True)))
118- self.assertThat(self.shortcut_hint.visible, Equals(True))
119-
120- self.keyboard.press_and_release("Escape")
121-
122- self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(False)))
123- self.assertThat(self.shortcut_hint.visible, Equals(True))
124-
125- def test_launcher_switcher_and_shortcut_hint_escaping(self):
126- """Cancelling the launcher switcher (by Escape) should not hide the
127- shortcut hint view, an extra keypress is needed.
128-
129- """
130- self.shortcut_hint.ensure_visible()
131- self.addCleanup(self.shortcut_hint.ensure_hidden)
132-
133- self.keybinding("launcher/switcher/next")
134-
135- self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(True)))
136- self.assertThat(self.shortcut_hint.visible, Equals(True))
137-
138- self.keyboard.press_and_release("Escape")
139-
140- self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(False)))
141- self.assertThat(self.shortcut_hint.visible, Equals(True))
142-
143- self.keyboard.press_and_release("Escape")
144- self.assertThat(self.shortcut_hint.visible, Eventually(Equals(False)))
145-
146 def test_launcher_icons_hints_show_with_shortcut_hint(self):
147 """When the shortcut hint is shown also the launcer's icons hints should
148 be shown.