diff options
| author | Brandon Schaefer <brandon.schaefer@canonical.com> | 2013-03-19 21:25:49 +0000 |
|---|---|---|
| committer | Tarmac <> | 2013-03-19 21:25:49 +0000 |
| commit | 14973632a9b01cae21e5bdf9453729431beef766 (patch) | |
| tree | a57ccec74c8fe12df03b64493a8c21b45cec838a | |
| parent | 33dfe63997a35c5c60109ba763d65124f6e2ef68 (diff) | |
| parent | fe662485f38f16c8dc9eb0fd501bd966a4c01c2b (diff) | |
The HudButtons no longer receive mouse events until the mouse is being moved over the HudView. It resets when any typing happens, so the mouse can no longer steal button focus with out moving it (which in that case you want the button to focus :). Fixes: https://bugs.launchpad.net/bugs/1066442.
Approved by PS Jenkins bot, Marco Trevisan (TreviƱo). (bzr r3235)
| -rw-r--r-- | hud/HudView.cpp | 19 | ||||
| -rw-r--r-- | tests/autopilot/unity/tests/test_hud.py | 11 |
2 files changed, 22 insertions, 8 deletions
diff --git a/hud/HudView.cpp b/hud/HudView.cpp index 32d6e548e..09a6ad413 100644 --- a/hud/HudView.cpp +++ b/hud/HudView.cpp @@ -114,6 +114,11 @@ View::View() } }); + mouse_move.connect([this] (int x, int y, int dx, int dy, unsigned long mouse_button, unsigned long special_key) { + for (auto button : buttons_) + button->SetInputEventSensitivity(true); + }); + mouse_down.connect(sigc::mem_fun(this, &View::OnMouseButtonDown)); Relayout(); @@ -182,7 +187,6 @@ void View::ProcessGrowShrink() } } - void View::ResetToDefault() { SetQueries(Hud::Queries()); @@ -238,6 +242,7 @@ void View::SetQueries(Hud::Queries queries) HudButton::Ptr button(new HudButton()); buttons_.push_front(button); + button->SetInputEventSensitivity(false); button->SetMinimumWidth(content_width); button->SetMaximumWidth(content_width); button->SetQuery(query); @@ -248,7 +253,7 @@ void View::SetQueries(Hud::Queries queries) query_activated.emit(dynamic_cast<HudButton*>(view)->GetQuery()); }); - button->mouse_move.connect([&](int x, int y, int dx, int dy, unsigned long mouse_button, unsigned long special_key) { + button->mouse_move.connect([this](int x, int y, int dx, int dy, unsigned long mouse_button, unsigned long special_key) { if (keyboard_stole_focus_) { MouseStealsHudButtonFocus(); @@ -256,19 +261,19 @@ void View::SetQueries(Hud::Queries queries) } }); - button->mouse_enter.connect([&](int x, int y, unsigned long mouse_button, unsigned long special_key) { + button->mouse_enter.connect([this](int x, int y, unsigned long mouse_button, unsigned long special_key) { MouseStealsHudButtonFocus(); }); - button->mouse_leave.connect([&](int x, int y, unsigned long mouse_button, unsigned long special_key) { + button->mouse_leave.connect([this](int x, int y, unsigned long mouse_button, unsigned long special_key) { SelectLastFocusedButton(); }); - button->key_nav_focus_activate.connect([&](nux::Area* area) { + button->key_nav_focus_activate.connect([this](nux::Area* area) { query_activated.emit(dynamic_cast<HudButton*>(area)->GetQuery()); }); - button->key_nav_focus_change.connect([&](nux::Area* area, bool recieving, nux::KeyNavDirection direction){ + button->key_nav_focus_change.connect([this](nux::Area* area, bool recieving, nux::KeyNavDirection direction){ if (recieving) query_selected.emit(dynamic_cast<HudButton*>(area)->GetQuery()); }); @@ -418,9 +423,7 @@ void View::OnSearchChanged(std::string const& search_string) search_changed.emit(search_string); for(auto button : buttons_) - { button->fake_focused = false; - } if (!buttons_.empty()) buttons_.back()->fake_focused = true; diff --git a/tests/autopilot/unity/tests/test_hud.py b/tests/autopilot/unity/tests/test_hud.py index 97938b9d9..bc040a1ed 100644 --- a/tests/autopilot/unity/tests/test_hud.py +++ b/tests/autopilot/unity/tests/test_hud.py @@ -459,6 +459,17 @@ class HudBehaviorTests(HudTestsBase): self.assertProperty(char_win, is_active=True) + def test_mouse_does_not_steal_button_focus(self): + """When typing in the hud the mouse must not steal button focus.""" + + self.unity.hud.ensure_visible() + + (x,y,w,h) = self.unity.hud.view.geometry + self.mouse.move(w/4, h/4) + + self.keyboard.type("a") + self.assertThat(self.unity.hud.view.selected_button, Eventually(Equals(1))) + class HudLauncherInteractionsTests(HudTestsBase): |
