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
=== added file 'manual-tests/Launcher.txt'
--- manual-tests/Launcher.txt 1970-01-01 00:00:00 +0000
+++ manual-tests/Launcher.txt 2011-12-30 23:50:29 +0000
@@ -0,0 +1,54 @@
1Test Dash Key Focus
2-------------------
3This test shows that the search bar in the dash gets key focus when using the super key to start the dash on start up.
4
5#. Start on a fresh login
6#. Press the <super> key
7#. Wait for dash to appear
8#. Type "hello"
9
10Outcome
11 The dash will appear, and "hello" will be in the search box.
12
13Test Alt+F1 KeyNavMode Mouse Works
14-------------------------------
15This test shows that the mouse still works normally while keynav mode is active.
16
17#. Press Alt+F1 to enter keynav mode
18#. Using the mouse perform a normal action (such as dragging a window)
19
20Outcome
21 The keynav mode exits, along with the mouse performing the normal action
22 the user expects. Such as highlighting text, moving a window, clicking out
23 of keynav mode, or clicking on a launcher icon. All these actions should
24 also exit the keynav mode.
25
26Test Alt+F1 KeyNavMode Shortcuts
27-----------------------------
28This test shows that all the shortcuts work and also exits from keynav mode.
29
30#. Press Alt+F1 to enter keynav mode
31#. Press Super + a
32#. Press Esc
33#. Press Alt+F1
34#. Press Alt + Tab
35#. Press Alt+F1
36#. Press Ctrl + Alt + t
37
38Outcome
39 The first shortcut opens the dash app lens, which it should open it and quit the
40 nav mode. The second shortcut switches between applications. The last one will open
41 a new terminal. This is to show all SUPER, ALT, and CTRL shortcuts work; while
42 closing the keynav mode.
43
44Test Alt+F1 NavMode Quicklist Click Exit
45----------------------------------------
46This Test shows that clicking on a quicklist option quits keynav mode.
47
48#. Press Alt+F1 to enter keynav mode
49#. Press Right arrow
50#. Click on any option
51
52Outcome
53 No matter what option you click will exit keynav mode.
54
055
=== removed file 'manual-tests/launcher.txt'
--- manual-tests/launcher.txt 2011-11-29 02:48:26 +0000
+++ manual-tests/launcher.txt 1970-01-01 00:00:00 +0000
@@ -1,11 +0,0 @@
1Test Dash Key Focus
2-------------------
3This test shows that the search bar in the dash gets key focus when using the super key to start the dash on start up.
4
5#. Start on a fresh login
6#. Press the <super> key
7#. Wait for dash to appear
8#. Type "hello"
9
10Outcome
11 The dash will appear, and "hello" will be in the search box.
120
=== modified file 'plugins/unityshell/src/Launcher.cpp'
--- plugins/unityshell/src/Launcher.cpp 2011-12-14 16:18:41 +0000
+++ plugins/unityshell/src/Launcher.cpp 2011-12-30 23:50:29 +0000
@@ -135,6 +135,7 @@
135 NUX_FILE_LINE_DECL)135 NUX_FILE_LINE_DECL)
136 : View(NUX_FILE_LINE_PARAM)136 : View(NUX_FILE_LINE_PARAM)
137 , m_ContentOffsetY(0)137 , m_ContentOffsetY(0)
138 , _keynav_next_focus_change(false)
138 , m_BackgroundLayer(0)139 , m_BackgroundLayer(0)
139 , _model(0)140 , _model(0)
140 , _collection_window(NULL)141 , _collection_window(NULL)
@@ -457,7 +458,8 @@
457 if (_focus_keynav_handle > 0)458 if (_focus_keynav_handle > 0)
458 g_source_remove(_focus_keynav_handle);459 g_source_remove(_focus_keynav_handle);
459 _focus_keynav_handle = g_timeout_add(ANIM_DURATION_SHORT, &Launcher::MoveFocusToKeyNavModeTimeout, this);460 _focus_keynav_handle = g_timeout_add(ANIM_DURATION_SHORT, &Launcher::MoveFocusToKeyNavModeTimeout, this);
460461
462 _keynav_next_focus_change = false;
461}463}
462464
463gboolean465gboolean
@@ -1687,6 +1689,17 @@
1687 */1689 */
1688 if (_hidemode != LAUNCHER_HIDE_NEVER)1690 if (_hidemode != LAUNCHER_HIDE_NEVER)
1689 g_idle_add((GSourceFunc)CheckWindowOverLauncherSync, this);1691 g_idle_add((GSourceFunc)CheckWindowOverLauncherSync, this);
1692
1693 // When keynav is activated wait for the next change in focus, then exit
1694 if (_keynav_next_focus_change)
1695 {
1696 _keynav_next_focus_change = false;
1697 exitKeyNavMode();
1698 }
1699 else if (_keynav_activated)
1700 {
1701 _keynav_next_focus_change = true;
1702 }
1690}1703}
16911704
1692gboolean1705gboolean
@@ -2667,7 +2680,9 @@
2667 }2680 }
2668 break;2681 break;
26692682
2670 // esc/left (close quicklist or exit laucher key-focus)2683 // alt/ctrl/esc/left (close quicklist or exit laucher key-focus)
2684 case NUX_VK_MENU:
2685 case NUX_VK_CONTROL:
2671 case NUX_VK_LEFT:2686 case NUX_VK_LEFT:
2672 case NUX_KP_LEFT:2687 case NUX_KP_LEFT:
2673 case NUX_VK_ESCAPE:2688 case NUX_VK_ESCAPE:
@@ -2714,6 +2729,15 @@
2714 exitKeyNavMode();2729 exitKeyNavMode();
2715 break;2730 break;
27162731
2732 // When super is pressed
2733 case NUX_VK_LWIN:
2734 case NUX_VK_RWIN:
2735 {
2736 StartKeyShowLauncher();
2737 }
2738 exitKeyNavMode();
2739 break;
2740
2717 default:2741 default:
2718 break;2742 break;
2719 }2743 }
@@ -2736,6 +2760,11 @@
2736 SetHover(false);2760 SetHover(false);
2737 SetStateMouseOverLauncher(false);2761 SetStateMouseOverLauncher(false);
2738 }2762 }
2763
2764 if (quicklist->MouseUsed())
2765 {
2766 exitKeyNavMode();
2767 }
2739 // Cancel any prior state that was set before the Quicklist appeared.2768 // Cancel any prior state that was set before the Quicklist appeared.
2740 SetActionState(ACTION_NONE);2769 SetActionState(ACTION_NONE);
27412770
@@ -2807,6 +2836,12 @@
28072836
2808 if (_icon_mouse_down && (_icon_mouse_down == launcher_icon))2837 if (_icon_mouse_down && (_icon_mouse_down == launcher_icon))
2809 {2838 {
2839 // If icon clicked, exit key nav
2840 if (_keynav_activated)
2841 {
2842 exitKeyNavMode();
2843 }
2844
2810 _icon_mouse_down->mouse_up.emit(nux::GetEventButton(button_flags));2845 _icon_mouse_down->mouse_up.emit(nux::GetEventButton(button_flags));
28112846
2812 if (GetActionState() == ACTION_NONE)2847 if (GetActionState() == ACTION_NONE)
28132848
=== modified file 'plugins/unityshell/src/Launcher.h'
--- plugins/unityshell/src/Launcher.h 2011-12-08 01:23:11 +0000
+++ plugins/unityshell/src/Launcher.h 2011-12-30 23:50:29 +0000
@@ -403,6 +403,7 @@
403403
404 bool _shortcuts_shown;404 bool _shortcuts_shown;
405 bool _keynav_activated;405 bool _keynav_activated;
406 bool _keynav_next_focus_change;
406 guint64 _latest_shortcut;407 guint64 _latest_shortcut;
407408
408 BacklightMode _backlight_mode;409 BacklightMode _backlight_mode;
409410
=== modified file 'plugins/unityshell/src/QuicklistView.cpp'
--- plugins/unityshell/src/QuicklistView.cpp 2011-12-15 08:52:31 +0000
+++ plugins/unityshell/src/QuicklistView.cpp 2011-12-30 23:50:29 +0000
@@ -59,7 +59,7 @@
59 , _anchorY(0)59 , _anchorY(0)
60 , _labelText(TEXT("QuicklistView 1234567890"))60 , _labelText(TEXT("QuicklistView 1234567890"))
61 , _top_size(4)61 , _top_size(4)
62 , _mouse_down(false)62 , _mouse_used(false)
63 , _enable_quicklist_for_testing(false)63 , _enable_quicklist_for_testing(false)
64 , _texture_bg(nullptr)64 , _texture_bg(nullptr)
65 , _texture_mask(nullptr)65 , _texture_mask(nullptr)
@@ -362,6 +362,7 @@
362 GrabKeyboard();362 GrabKeyboard();
363 QueueDraw();363 QueueDraw();
364 _compute_blur_bkg = true;364 _compute_blur_bkg = true;
365 _mouse_used = false;
365 }366 }
366}367}
367368
@@ -635,12 +636,11 @@
635636
636void QuicklistView::RecvItemMouseClick(QuicklistMenuItem* item, int x, int y)637void QuicklistView::RecvItemMouseClick(QuicklistMenuItem* item, int x, int y)
637{638{
638 _mouse_down = false;
639 if (IsVisible() && item->GetEnabled())639 if (IsVisible() && item->GetEnabled())
640 {640 {
641 // Check if the mouse was released over an item and emit the signal641 // Check if the mouse was released over an item and emit the signal
642 CheckAndEmitItemSignal(x + item->GetBaseX(), y + item->GetBaseY());642 CheckAndEmitItemSignal(x + item->GetBaseX(), y + item->GetBaseY());
643643 _mouse_used = true;
644 Hide();644 Hide();
645 }645 }
646}646}
@@ -688,14 +688,11 @@
688688
689void QuicklistView::RecvItemMouseRelease(QuicklistMenuItem* item, int x, int y)689void QuicklistView::RecvItemMouseRelease(QuicklistMenuItem* item, int x, int y)
690{690{
691 _mouse_down = false;
692
693
694 if (IsVisible() && item->GetEnabled())691 if (IsVisible() && item->GetEnabled())
695 {692 {
696 // Check if the mouse was released over an item and emit the signal693 // Check if the mouse was released over an item and emit the signal
697 CheckAndEmitItemSignal(x + item->GetBaseX(), y + item->GetBaseY());694 CheckAndEmitItemSignal(x + item->GetBaseX(), y + item->GetBaseY());
698695 _mouse_used = true;
699 Hide();696 Hide();
700 }697 }
701}698}
@@ -788,6 +785,7 @@
788{785{
789 if (IsVisible())786 if (IsVisible())
790 {787 {
788 _mouse_used = true;
791 Hide();789 Hide();
792 }790 }
793}791}
@@ -804,6 +802,7 @@
804802
805void QuicklistView::RecvMouseDownOutsideOfQuicklist(int x, int y, unsigned long button_flags, unsigned long key_flags)803void QuicklistView::RecvMouseDownOutsideOfQuicklist(int x, int y, unsigned long button_flags, unsigned long key_flags)
806{804{
805 _mouse_used = true;
807 Hide();806 Hide();
808}807}
809808
@@ -1529,6 +1528,12 @@
1529 return true;1528 return true;
1530}1529}
15311530
1531bool
1532QuicklistView::MouseUsed()
1533{
1534 return _mouse_used;
1535}
1536
1532QuicklistMenuItem*1537QuicklistMenuItem*
1533QuicklistView::GetSelectedMenuItem()1538QuicklistView::GetSelectedMenuItem()
1534{1539{
15351540
=== modified file 'plugins/unityshell/src/QuicklistView.h'
--- plugins/unityshell/src/QuicklistView.h 2011-12-15 08:52:31 +0000
+++ plugins/unityshell/src/QuicklistView.h 2011-12-30 23:50:29 +0000
@@ -97,6 +97,8 @@
97 unsigned int keysym,97 unsigned int keysym,
98 const char* character);98 const char* character);
9999
100 bool MouseUsed();
101
100 //Required for a11y102 //Required for a11y
101 QuicklistMenuItem* GetSelectedMenuItem();103 QuicklistMenuItem* GetSelectedMenuItem();
102 sigc::signal<void> selection_change;104 sigc::signal<void> selection_change;
@@ -152,7 +154,7 @@
152 nux::NString _labelText;154 nux::NString _labelText;
153 int _top_size; // size of the segment from point 13 to 14. See figure in ql_compute_full_mask_path.155 int _top_size; // size of the segment from point 13 to 14. See figure in ql_compute_full_mask_path.
154156
155 bool _mouse_down;157 bool _mouse_used;
156158
157 //iIf true, suppress the Quicklist behaviour that is expected in Unity.159 //iIf true, suppress the Quicklist behaviour that is expected in Unity.
158 // Keep the Quicklist on screen for testing and automation.160 // Keep the Quicklist on screen for testing and automation.