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

Proposed by Brandon Schaefer
Status: Rejected
Rejected by: Brandon Schaefer
Proposed branch: lp:~brandontschaefer/unity/fix-1066442
Merge into: lp:unity
Diff against target: 82 lines (+21/-2)
3 files modified
hud/HudView.cpp (+10/-2)
hud/HudView.h (+1/-0)
tests/autopilot/unity/tests/test_hud.py (+10/-0)
To merge this branch: bzr merge lp:~brandontschaefer/unity/fix-1066442
Reviewer Review Type Date Requested Status
Nick Dedekind (community) Needs Fixing
Review via email: mp+130453@code.launchpad.net

Commit message

Mouse no longer steals HUD button focus when typing.

Description of the change

=== Problem ===
The mouse would steal focus of the buttons in the hud while typing. If the mouse was over one of the buttons.

=== Fix ===
The mouse can only steal button focus now until after both last_height == current height ie. it is done animating.

=== Test ===
AP test

To post a comment you must log in.
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

37 + if (restore_button_input_ && current_height_ == last_known_height_)

You shouldn't need the current_height_ == last_known_height_ as this code should only be called once every time the query changes.
There seems to be something broken in the relyout where the view keeps doing ProcessGrowShrink.
This seems to be because a layout update causes the Min/Max to be set during a call to Relayout(), but there is no checks in those methods to check for an actual change, so it forces a parent relayout.

I think the animation needs some refactoring to get this working cleanly.

review: Needs Fixing
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

Also, I think you should keep the input sensitivity logic inside the HudView and remove it from the button.

review: Needs Fixing
2864. By Brandon Schaefer

* Move setting input focus to false to the HudView

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Yes, I thought was much. Any simple fix resulted in a regression of choppy animations, though I think it should stop trying to animate the ShrinkGrow process when it is done with either. I can take a look at it.

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

I need to redo this, as I had a working branch somewhere...but theres are some interesting problems with this bug.

Unmerged revisions

2864. By Brandon Schaefer

* Move setting input focus to false to the HudView

2863. By Brandon Schaefer

* The mouse no longer steals button focus in the hud while typing.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hud/HudView.cpp'
2--- hud/HudView.cpp 2012-09-19 09:50:37 +0000
3+++ hud/HudView.cpp 2012-10-23 15:52:21 +0000
4@@ -68,6 +68,7 @@
5 , selected_button_(0)
6 , show_embedded_icon_(true)
7 , keyboard_stole_focus_(false)
8+ , restore_button_input_(false)
9 {
10 renderer_.SetOwner(this);
11 renderer_.need_redraw.connect([this] () {
12@@ -149,8 +150,6 @@
13 //shrink
14 new_height = last_height - ((last_height - target_height) * progress);
15 }
16-
17-
18 LOG_DEBUG(logger) << "resizing to " << target_height << " (" << new_height << ")"
19 << "View height: " << GetGeometry().height;
20 current_height_ = new_height;
21@@ -163,6 +162,13 @@
22
23 if (diff > grow_anim_length + pause_before_grow_length)
24 {
25+ if (restore_button_input_ && current_height_ == last_known_height_)
26+ {
27+ restore_button_input_ = false;
28+ for (auto button : buttons_)
29+ button->SetInputEventSensitivity(true);
30+ }
31+
32 // ensure we are at our final location and update last known height
33 current_height_ = target_height;
34 last_known_height_ = target_height;
35@@ -226,6 +232,7 @@
36 RemoveChild(button.GetPointer());
37 }
38
39+ restore_button_input_ = true;
40 selected_button_ = 0;
41 queries_ = queries_;
42 buttons_.clear();
43@@ -241,6 +248,7 @@
44 button->SetMinimumWidth(content_width);
45 button->SetMaximumWidth(content_width);
46 button->SetQuery(query);
47+ button->SetInputEventSensitivity(false);
48
49 button_views_->AddView(button.GetPointer(), 0, nux::MINOR_POSITION_LEFT);
50
51
52=== modified file 'hud/HudView.h'
53--- hud/HudView.h 2012-09-13 16:56:38 +0000
54+++ hud/HudView.h 2012-10-23 15:52:21 +0000
55@@ -121,6 +121,7 @@
56 bool show_embedded_icon_;
57 bool activated_signal_sent_;
58 bool keyboard_stole_focus_;
59+ bool restore_button_input_;
60 };
61
62
63
64=== modified file 'tests/autopilot/unity/tests/test_hud.py'
65--- tests/autopilot/unity/tests/test_hud.py 2012-10-11 01:44:15 +0000
66+++ tests/autopilot/unity/tests/test_hud.py 2012-10-23 15:52:21 +0000
67@@ -397,6 +397,16 @@
68
69 self.assertThat(self.hud.view.selected_button, Eventually(Equals(1)))
70
71+ def test_mouse_does_not_steal_button_focus(self):
72+ """When typing in the hud the mouse must not steal button focus."""
73+
74+ self.hud.ensure_visible()
75+ (x,y,w,h) = self.hud.view.geometry
76+ self.mouse.move(w/4, h/4)
77+
78+ self.keyboard.type("a")
79+ self.assertThat(self.hud.view.selected_button, Eventually(Equals(1)))
80+
81 def test_keep_focus_on_application_opens(self):
82 """The Hud must keep key focus as well as stay open if an app gets opened from an external source. """
83