Merge lp:~azzar1/unity/fix-backward-keynav into lp:unity

Proposed by Andrea Azzarone
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: 1954
Proposed branch: lp:~azzar1/unity/fix-backward-keynav
Merge into: lp:unity
Diff against target: 133 lines (+39/-18)
5 files modified
plugins/unityshell/src/ResultViewGrid.cpp (+5/-6)
plugins/unityshell/src/ResultViewGrid.h (+7/-8)
plugins/unityshell/src/SearchBar.cpp (+5/-2)
tests/autopilot/autopilot/emulators/unity.py (+6/-0)
tests/autopilot/autopilot/tests/test_dash.py (+16/-2)
To merge this branch: bzr merge lp:~azzar1/unity/fix-backward-keynav
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve
Review via email: mp+92676@code.launchpad.net

Description of the change

Fix a bug in the backward key navigation (bug. 931025)

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 'plugins/unityshell/src/ResultViewGrid.cpp'
2--- plugins/unityshell/src/ResultViewGrid.cpp 2012-02-04 05:28:23 +0000
3+++ plugins/unityshell/src/ResultViewGrid.cpp 2012-02-12 16:31:19 +0000
4@@ -72,9 +72,9 @@
5 vertical_spacing.changed.connect(needredraw_lambda);
6 padding.changed.connect(needredraw_lambda);
7
8- key_nav_focus_change.connect (sigc::mem_fun (this, &ResultViewGrid::OnOnKeyNavFocusChange));
9- key_nav_focus_activate.connect ([&] (nux::Area *area) { UriActivated.emit (focused_uri_); });
10- key_down.connect (sigc::mem_fun (this, &ResultViewGrid::OnKeyDown));
11+ key_nav_focus_change.connect(sigc::mem_fun(this, &ResultViewGrid::OnKeyNavFocusChange));
12+ key_nav_focus_activate.connect([&] (nux::Area *area) { UriActivated.emit (focused_uri_); });
13+ key_down.connect(sigc::mem_fun(this, &ResultViewGrid::OnKeyDown));
14 mouse_move.connect(sigc::mem_fun(this, &ResultViewGrid::MouseMove));
15 mouse_click.connect(sigc::mem_fun(this, &ResultViewGrid::MouseClick));
16
17@@ -488,8 +488,7 @@
18 return this;
19 }
20
21-// crappy name.
22-void ResultViewGrid::OnOnKeyNavFocusChange(nux::Area *area, bool has_focus, nux::KeyNavDirection direction)
23+void ResultViewGrid::OnKeyNavFocusChange(nux::Area *area, bool has_focus, nux::KeyNavDirection direction)
24 {
25 if (HasKeyFocus())
26 {
27@@ -504,7 +503,7 @@
28
29 int items_per_row = GetItemsPerRow();
30
31- if (direction == nux::KEY_NAV_UP)
32+ if (direction == nux::KEY_NAV_UP && expanded)
33 {
34 // This View just got focused through keyboard navigation and the
35 // focus is comming from the bottom. We want to focus the
36
37=== modified file 'plugins/unityshell/src/ResultViewGrid.h'
38--- plugins/unityshell/src/ResultViewGrid.h 2012-02-04 05:28:23 +0000
39+++ plugins/unityshell/src/ResultViewGrid.h 2012-02-12 16:31:19 +0000
40@@ -20,10 +20,8 @@
41 *
42 */
43
44-
45-
46-#ifndef RESULTVIEWGRID_H
47-#define RESULTVIEWGRID_H
48+#ifndef UNITYSHELL_RESULTVIEWGRID_H
49+#define UNITYSHELL_RESULTVIEWGRID_H
50
51 #include <UnityCore/Categories.h>
52 #include "ResultView.h"
53@@ -69,7 +67,7 @@
54 virtual bool InspectKeyEvent(unsigned int eventType, unsigned int keysym, const char* character);
55 virtual bool AcceptKeyNavFocus();
56 virtual nux::Area* KeyNavIteration(nux::KeyNavDirection direction);
57- virtual void OnOnKeyNavFocusChange(nux::Area* area, bool has_focus, nux::KeyNavDirection direction);
58+ virtual void OnKeyNavFocusChange(nux::Area* area, bool has_focus, nux::KeyNavDirection direction);
59 void OnKeyDown(unsigned long event_type, unsigned long event_keysym, unsigned long event_state, const TCHAR* character, unsigned short key_repeat_count);
60
61 virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);;
62@@ -112,6 +110,7 @@
63
64 };
65
66-}
67-}
68-#endif // RESULTVIEWGRID_H
69+} // namespace dash
70+} // namespace unity
71+
72+#endif // UNITYSHELL_RESULTVIEWGRID_H
73
74=== modified file 'plugins/unityshell/src/SearchBar.cpp'
75--- plugins/unityshell/src/SearchBar.cpp 2012-02-08 23:21:20 +0000
76+++ plugins/unityshell/src/SearchBar.cpp 2012-02-12 16:31:19 +0000
77@@ -542,8 +542,11 @@
78
79 void SearchBar::AddProperties(GVariantBuilder* builder)
80 {
81- unity::variant::BuilderWrapper(builder).add(GetGeometry());
82- g_variant_builder_add (builder, "{sv}", "search_string", g_variant_new_string (pango_entry_->GetText().c_str()) );
83+ unity::variant::BuilderWrapper wrapper(builder);
84+
85+ wrapper.add(GetGeometry());
86+ wrapper.add("has_focus", pango_entry_->HasKeyFocus());
87+ wrapper.add("search_string", pango_entry_->GetText());
88 }
89
90 } // namespace unity
91
92=== modified file 'tests/autopilot/autopilot/emulators/unity.py'
93--- tests/autopilot/autopilot/emulators/unity.py 2012-02-08 00:32:46 +0000
94+++ tests/autopilot/autopilot/emulators/unity.py 2012-02-12 16:31:19 +0000
95@@ -542,6 +542,12 @@
96 """
97 return unicode(self.get_state("//SearchBar")[0]['search_string'])
98
99+ def searchbar_has_focus(self):
100+ """
101+ Returns True if the search bar has the key focus, False otherwise.
102+ """
103+ return self.get_state("//SearchBar")[0]['has_focus']
104+
105 def get_current_lens(self):
106 """Returns the id of the current lens.
107
108
109=== modified file 'tests/autopilot/autopilot/tests/test_dash.py'
110--- tests/autopilot/autopilot/tests/test_dash.py 2012-02-07 22:20:45 +0000
111+++ tests/autopilot/autopilot/tests/test_dash.py 2012-02-12 16:31:19 +0000
112@@ -134,8 +134,22 @@
113
114 category = self.dash.get_focused_category()
115 self.assertEqual(category, None)
116-
117-
118+
119+ def test_backward_keynav(self):
120+ """Test that the backward keyboard navigation works well."""
121+ self.dash.ensure_hidden()
122+ self.dash.reveal_application_lens()
123+ kb = Keyboard()
124+
125+ # Moves the key focus to the lensbar
126+ for i in range(self.dash.get_num_rows()):
127+ kb.press_and_release("Down")
128+ self.assertIsNot(self.dash.get_focused_lens_icon(), '')
129+
130+ # backward key navigation...
131+ for i in range(self.dash.get_num_rows()):
132+ kb.press_and_release("Up")
133+ self.assertTrue(self.dash.searchbar_has_focus())
134
135
136