Merge lp:~gordallott/unity/fix-focus-issues-on-click into lp:unity

Proposed by Gord Allott
Status: Merged
Approved by: Neil J. Patel
Approved revision: no longer in the source branch.
Merged at revision: 1685
Proposed branch: lp:~gordallott/unity/fix-focus-issues-on-click
Merge into: lp:unity
Diff against target: 40 lines (+18/-3)
1 file modified
plugins/unityshell/src/ResultViewGrid.cpp (+18/-3)
To merge this branch: bzr merge lp:~gordallott/unity/fix-focus-issues-on-click
Reviewer Review Type Date Requested Status
Neil J. Patel (community) Approve
Review via email: mp+77907@code.launchpad.net

Description of the change

fixes the attached bug, essentially clicking caused the result-view to get focused, but nux sends the you are focused event before the click event. so the result-view focused the first element causing the dash to scroll, so when the click event is actually finally called, its in a completely different part of the dash than you expected

To post a comment you must log in.
Revision history for this message
Neil J. Patel (njpatel) :
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 2011-09-28 16:20:21 +0000
3+++ plugins/unityshell/src/ResultViewGrid.cpp 2011-10-03 11:16:33 +0000
4@@ -485,11 +485,24 @@
5 // crappy name.
6 void ResultViewGrid::OnOnKeyNavFocusChange(nux::Area *area)
7 {
8-
9 if (HasKeyFocus())
10 {
11- focused_uri_ = results_.front().uri;
12- selected_index_ = 0;
13+ if (selected_index_ < 0)
14+ {
15+ if (mouse_over_index_ >= 0)
16+ {
17+ // to hack around nux, nux sends the keynavfocuschange event before
18+ // mouse clicks, so when mouse click happens we have already scrolled away
19+ // because the keynav focus changed
20+ focused_uri_ = results_[mouse_over_index_].uri;
21+ selected_index_ = mouse_over_index_;
22+ }
23+ else
24+ {
25+ focused_uri_ = results_.front().uri;
26+ selected_index_ = 0;
27+ }
28+ }
29 NeedRedraw();
30
31 int items_per_row = GetItemsPerRow();
32@@ -668,6 +681,8 @@
33 {
34 // we got a click on a button so activate it
35 Result result = results_[index];
36+ selected_index_ = index;
37+ focused_uri_ = result.uri;
38 UriActivated.emit(result.uri);
39 }
40 }