Merge lp:~brandontschaefer/unity/fix-896122 into lp:unity

Proposed by Brandon Schaefer
Status: Rejected
Rejected by: Tim Penhey
Proposed branch: lp:~brandontschaefer/unity/fix-896122
Merge into: lp:unity
Diff against target: 280 lines (+107/-21)
6 files modified
manual-tests/Launcher.txt (+54/-0)
manual-tests/launcher.txt (+0/-11)
plugins/unityshell/src/Launcher.cpp (+37/-2)
plugins/unityshell/src/Launcher.h (+1/-0)
plugins/unityshell/src/QuicklistView.cpp (+12/-7)
plugins/unityshell/src/QuicklistView.h (+3/-1)
To merge this branch: bzr merge lp:~brandontschaefer/unity/fix-896122
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) Approve
Sam Spilsbury (community) Approve
Review via email: mp+86848@code.launchpad.net

Description of the change

Uses the window_focus_change signal to close the keynav when the focus is changed from the launcher; while still allowing the user to preform normal actions; such as moving a window or highlighting text etc.

Handles the quicklist problem by using a bool in the QuicklistView that gets set if the mouse is responsible for the call to QuicklistView::Hide(). If it is then in Launcher::RecvQuickliseClose() we call exitKeyNavMode().

The shortcuts get handled in Launcher::RecvKeyPressed. If the user presses alt or ctrl then exitKeyNavMode(), allowing those shortcuts to work. When super is pressed call StartKeyShowLauncher() then then exitKeyNavMode(); which makes the super and super + shortcut work correctly.

To post a comment you must log in.
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Needs test cases.

Revision history for this message
Sam Spilsbury (smspillaz) :
review: Approve
Revision history for this message
Andrea Azzarone (azzar1) wrote :

+1 for me.

review: Approve
Revision history for this message
Tim Penhey (thumper) wrote :

Launcher code rewritten and new patch landed. This isn't needed.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'manual-tests/Launcher.txt'
2--- manual-tests/Launcher.txt 1970-01-01 00:00:00 +0000
3+++ manual-tests/Launcher.txt 2011-12-30 23:50:29 +0000
4@@ -0,0 +1,54 @@
5+Test Dash Key Focus
6+-------------------
7+This test shows that the search bar in the dash gets key focus when using the super key to start the dash on start up.
8+
9+#. Start on a fresh login
10+#. Press the <super> key
11+#. Wait for dash to appear
12+#. Type "hello"
13+
14+Outcome
15+ The dash will appear, and "hello" will be in the search box.
16+
17+Test Alt+F1 KeyNavMode Mouse Works
18+-------------------------------
19+This test shows that the mouse still works normally while keynav mode is active.
20+
21+#. Press Alt+F1 to enter keynav mode
22+#. Using the mouse perform a normal action (such as dragging a window)
23+
24+Outcome
25+ The keynav mode exits, along with the mouse performing the normal action
26+ the user expects. Such as highlighting text, moving a window, clicking out
27+ of keynav mode, or clicking on a launcher icon. All these actions should
28+ also exit the keynav mode.
29+
30+Test Alt+F1 KeyNavMode Shortcuts
31+-----------------------------
32+This test shows that all the shortcuts work and also exits from keynav mode.
33+
34+#. Press Alt+F1 to enter keynav mode
35+#. Press Super + a
36+#. Press Esc
37+#. Press Alt+F1
38+#. Press Alt + Tab
39+#. Press Alt+F1
40+#. Press Ctrl + Alt + t
41+
42+Outcome
43+ The first shortcut opens the dash app lens, which it should open it and quit the
44+ nav mode. The second shortcut switches between applications. The last one will open
45+ a new terminal. This is to show all SUPER, ALT, and CTRL shortcuts work; while
46+ closing the keynav mode.
47+
48+Test Alt+F1 NavMode Quicklist Click Exit
49+----------------------------------------
50+This Test shows that clicking on a quicklist option quits keynav mode.
51+
52+#. Press Alt+F1 to enter keynav mode
53+#. Press Right arrow
54+#. Click on any option
55+
56+Outcome
57+ No matter what option you click will exit keynav mode.
58+
59
60=== removed file 'manual-tests/launcher.txt'
61--- manual-tests/launcher.txt 2011-11-29 02:48:26 +0000
62+++ manual-tests/launcher.txt 1970-01-01 00:00:00 +0000
63@@ -1,11 +0,0 @@
64-Test Dash Key Focus
65--------------------
66-This test shows that the search bar in the dash gets key focus when using the super key to start the dash on start up.
67-
68-#. Start on a fresh login
69-#. Press the <super> key
70-#. Wait for dash to appear
71-#. Type "hello"
72-
73-Outcome
74- The dash will appear, and "hello" will be in the search box.
75
76=== modified file 'plugins/unityshell/src/Launcher.cpp'
77--- plugins/unityshell/src/Launcher.cpp 2011-12-14 16:18:41 +0000
78+++ plugins/unityshell/src/Launcher.cpp 2011-12-30 23:50:29 +0000
79@@ -135,6 +135,7 @@
80 NUX_FILE_LINE_DECL)
81 : View(NUX_FILE_LINE_PARAM)
82 , m_ContentOffsetY(0)
83+ , _keynav_next_focus_change(false)
84 , m_BackgroundLayer(0)
85 , _model(0)
86 , _collection_window(NULL)
87@@ -457,7 +458,8 @@
88 if (_focus_keynav_handle > 0)
89 g_source_remove(_focus_keynav_handle);
90 _focus_keynav_handle = g_timeout_add(ANIM_DURATION_SHORT, &Launcher::MoveFocusToKeyNavModeTimeout, this);
91-
92+
93+ _keynav_next_focus_change = false;
94 }
95
96 gboolean
97@@ -1687,6 +1689,17 @@
98 */
99 if (_hidemode != LAUNCHER_HIDE_NEVER)
100 g_idle_add((GSourceFunc)CheckWindowOverLauncherSync, this);
101+
102+ // When keynav is activated wait for the next change in focus, then exit
103+ if (_keynav_next_focus_change)
104+ {
105+ _keynav_next_focus_change = false;
106+ exitKeyNavMode();
107+ }
108+ else if (_keynav_activated)
109+ {
110+ _keynav_next_focus_change = true;
111+ }
112 }
113
114 gboolean
115@@ -2667,7 +2680,9 @@
116 }
117 break;
118
119- // esc/left (close quicklist or exit laucher key-focus)
120+ // alt/ctrl/esc/left (close quicklist or exit laucher key-focus)
121+ case NUX_VK_MENU:
122+ case NUX_VK_CONTROL:
123 case NUX_VK_LEFT:
124 case NUX_KP_LEFT:
125 case NUX_VK_ESCAPE:
126@@ -2714,6 +2729,15 @@
127 exitKeyNavMode();
128 break;
129
130+ // When super is pressed
131+ case NUX_VK_LWIN:
132+ case NUX_VK_RWIN:
133+ {
134+ StartKeyShowLauncher();
135+ }
136+ exitKeyNavMode();
137+ break;
138+
139 default:
140 break;
141 }
142@@ -2736,6 +2760,11 @@
143 SetHover(false);
144 SetStateMouseOverLauncher(false);
145 }
146+
147+ if (quicklist->MouseUsed())
148+ {
149+ exitKeyNavMode();
150+ }
151 // Cancel any prior state that was set before the Quicklist appeared.
152 SetActionState(ACTION_NONE);
153
154@@ -2807,6 +2836,12 @@
155
156 if (_icon_mouse_down && (_icon_mouse_down == launcher_icon))
157 {
158+ // If icon clicked, exit key nav
159+ if (_keynav_activated)
160+ {
161+ exitKeyNavMode();
162+ }
163+
164 _icon_mouse_down->mouse_up.emit(nux::GetEventButton(button_flags));
165
166 if (GetActionState() == ACTION_NONE)
167
168=== modified file 'plugins/unityshell/src/Launcher.h'
169--- plugins/unityshell/src/Launcher.h 2011-12-08 01:23:11 +0000
170+++ plugins/unityshell/src/Launcher.h 2011-12-30 23:50:29 +0000
171@@ -403,6 +403,7 @@
172
173 bool _shortcuts_shown;
174 bool _keynav_activated;
175+ bool _keynav_next_focus_change;
176 guint64 _latest_shortcut;
177
178 BacklightMode _backlight_mode;
179
180=== modified file 'plugins/unityshell/src/QuicklistView.cpp'
181--- plugins/unityshell/src/QuicklistView.cpp 2011-12-15 08:52:31 +0000
182+++ plugins/unityshell/src/QuicklistView.cpp 2011-12-30 23:50:29 +0000
183@@ -59,7 +59,7 @@
184 , _anchorY(0)
185 , _labelText(TEXT("QuicklistView 1234567890"))
186 , _top_size(4)
187- , _mouse_down(false)
188+ , _mouse_used(false)
189 , _enable_quicklist_for_testing(false)
190 , _texture_bg(nullptr)
191 , _texture_mask(nullptr)
192@@ -362,6 +362,7 @@
193 GrabKeyboard();
194 QueueDraw();
195 _compute_blur_bkg = true;
196+ _mouse_used = false;
197 }
198 }
199
200@@ -635,12 +636,11 @@
201
202 void QuicklistView::RecvItemMouseClick(QuicklistMenuItem* item, int x, int y)
203 {
204- _mouse_down = false;
205 if (IsVisible() && item->GetEnabled())
206 {
207 // Check if the mouse was released over an item and emit the signal
208 CheckAndEmitItemSignal(x + item->GetBaseX(), y + item->GetBaseY());
209-
210+ _mouse_used = true;
211 Hide();
212 }
213 }
214@@ -688,14 +688,11 @@
215
216 void QuicklistView::RecvItemMouseRelease(QuicklistMenuItem* item, int x, int y)
217 {
218- _mouse_down = false;
219-
220-
221 if (IsVisible() && item->GetEnabled())
222 {
223 // Check if the mouse was released over an item and emit the signal
224 CheckAndEmitItemSignal(x + item->GetBaseX(), y + item->GetBaseY());
225-
226+ _mouse_used = true;
227 Hide();
228 }
229 }
230@@ -788,6 +785,7 @@
231 {
232 if (IsVisible())
233 {
234+ _mouse_used = true;
235 Hide();
236 }
237 }
238@@ -804,6 +802,7 @@
239
240 void QuicklistView::RecvMouseDownOutsideOfQuicklist(int x, int y, unsigned long button_flags, unsigned long key_flags)
241 {
242+ _mouse_used = true;
243 Hide();
244 }
245
246@@ -1529,6 +1528,12 @@
247 return true;
248 }
249
250+bool
251+QuicklistView::MouseUsed()
252+{
253+ return _mouse_used;
254+}
255+
256 QuicklistMenuItem*
257 QuicklistView::GetSelectedMenuItem()
258 {
259
260=== modified file 'plugins/unityshell/src/QuicklistView.h'
261--- plugins/unityshell/src/QuicklistView.h 2011-12-15 08:52:31 +0000
262+++ plugins/unityshell/src/QuicklistView.h 2011-12-30 23:50:29 +0000
263@@ -97,6 +97,8 @@
264 unsigned int keysym,
265 const char* character);
266
267+ bool MouseUsed();
268+
269 //Required for a11y
270 QuicklistMenuItem* GetSelectedMenuItem();
271 sigc::signal<void> selection_change;
272@@ -152,7 +154,7 @@
273 nux::NString _labelText;
274 int _top_size; // size of the segment from point 13 to 14. See figure in ql_compute_full_mask_path.
275
276- bool _mouse_down;
277+ bool _mouse_used;
278
279 //iIf true, suppress the Quicklist behaviour that is expected in Unity.
280 // Keep the Quicklist on screen for testing and automation.