Merge lp:~gordallott/unity/fix-hud-refresh-move-selection into lp:unity

Proposed by Gord Allott
Status: Merged
Approved by: Michal Hruby
Approved revision: no longer in the source branch.
Merged at revision: 2274
Proposed branch: lp:~gordallott/unity/fix-hud-refresh-move-selection
Merge into: lp:unity
Diff against target: 52 lines (+24/-0)
2 files modified
plugins/unityshell/src/HudView.cpp (+14/-0)
tests/autopilot/autopilot/tests/test_hud.py (+10/-0)
To merge this branch: bzr merge lp:~gordallott/unity/fix-hud-refresh-move-selection
Reviewer Review Type Date Requested Status
Michal Hruby (community) Approve
Review via email: mp+101579@code.launchpad.net

Commit message

HUD: Ignores service updates if user is key navigating

Description of the change

Problem:
Hud resets its focus when it gets an updated query, the service likes to send these all the time, causing your selection to be reset when you are keynavigating

Solution:
ignore service updates when you are key navigating, which is better than the alternative of changing the buttons underneath the user

Testing:
yup

UNBLOCK

To post a comment you must log in.
Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

(UNBLOCKing as it's something a lot of people reported in the community test. We definitively want it for the release)

Revision history for this message
Michal Hruby (mhr3) wrote :

Looks reasonable. +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/HudView.cpp'
2--- plugins/unityshell/src/HudView.cpp 2012-04-05 15:14:16 +0000
3+++ plugins/unityshell/src/HudView.cpp 2012-04-11 15:22:24 +0000
4@@ -213,6 +213,11 @@
5
6 void View::SetQueries(Hud::Queries queries)
7 {
8+ // early exit, if the user is key navigating on the hud, we don't want to set new
9+ // queries under them, that is just rude
10+ if (!buttons_.empty() && buttons_.back()->fake_focused == false)
11+ return;
12+
13 // remove the previous children
14 for (auto button : buttons_)
15 {
16@@ -385,6 +390,15 @@
17 {
18 search_bar_->search_hint = "";
19 }
20+
21+ std::list<HudButton::Ptr>::iterator it;
22+ for(it = buttons_.begin(); it != buttons_.end(); ++it)
23+ {
24+ (*it)->fake_focused = false;
25+ }
26+
27+ if (!buttons_.empty())
28+ buttons_.back()->fake_focused = true;
29 }
30
31
32
33=== modified file 'tests/autopilot/autopilot/tests/test_hud.py'
34--- tests/autopilot/autopilot/tests/test_hud.py 2012-04-05 03:29:40 +0000
35+++ tests/autopilot/autopilot/tests/test_hud.py 2012-04-11 15:22:24 +0000
36@@ -103,6 +103,16 @@
37 self.keyboard.press_and_release('Up')
38 self.assertThat(self.hud.selected_button, Equals(1))
39
40+ def test_no_reset_selected_button(self):
41+ self.reveal_hud()
42+ self.keyboard.type('is')
43+ sleep(1)
44+ self.keyboard.press_and_release('Down')
45+ self.assertThat(self.hud.selected_button, Equals(2))
46+ # long sleep to let the service send updated results
47+ sleep(10)
48+ self.assertThat(self.hud.selected_button, Equals(2))
49+
50 def test_slow_tap_not_reveal_hud(self):
51 self.hud.toggle_reveal(tap_delay=0.3)
52 sleep(1)