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

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

Commit message

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
Marco Trevisan (Treviño) (3v1n0) wrote :

+1

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

Subscribers

People subscribed via source and target branches

to all changes: