Merge lp:~brandontschaefer/unity/hud-shrunk-click-close-SRU into lp:unity/5.0

Proposed by Brandon Schaefer
Status: Merged
Approved by: Brandon Schaefer
Approved revision: no longer in the source branch.
Merged at revision: 2373
Proposed branch: lp:~brandontschaefer/unity/hud-shrunk-click-close-SRU
Merge into: lp:unity/5.0
Diff against target: 96 lines (+34/-6)
2 files modified
plugins/unityshell/src/HudView.cpp (+7/-5)
tests/autopilot/autopilot/tests/test_hud.py (+27/-1)
To merge this branch: bzr merge lp:~brandontschaefer/unity/hud-shrunk-click-close-SRU
Reviewer Review Type Date Requested Status
Thomi Richards (community) quality Approve
Review via email: mp+111948@code.launchpad.net

Commit message

Fixes closing the shurnk Hud when clicking outside it's geometry.

Description of the change

=== Problem ===
When the hud is shrunk you cannot click to close it where it would normaly be.

=== Fix ===
Use the current_height_ in detecting if the mouse click is in or out of the area.

=== Test ===
Ap tests

To post a comment you must log in.
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) :
review: Approve (quality)

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-06-15 18:09:57 +0000
3+++ plugins/unityshell/src/HudView.cpp 2012-06-25 22:05:21 +0000
4@@ -357,7 +357,7 @@
5 {
6 dash::Style& style = dash::Style::Instance();
7
8- nux::VLayout* super_layout = new nux::VLayout();
9+ nux::VLayout* super_layout = new nux::VLayout();
10 layout_ = new nux::HLayout();
11 {
12 // fill layout with icon
13@@ -405,7 +405,7 @@
14 {
15 button->fake_focused = false;
16 }
17-
18+
19 if (!buttons_.empty())
20 buttons_.back()->fake_focused = true;
21 }
22@@ -424,7 +424,9 @@
23
24 void View::OnMouseButtonDown(int x, int y, unsigned long button, unsigned long key)
25 {
26- if (!content_geo_.IsPointInside(x, y))
27+ nux::Geometry current_geo(content_geo_);
28+ current_geo.height = current_height_;
29+ if (!current_geo.IsPointInside(x, y))
30 {
31 ubus.SendMessage(UBUS_HUD_CLOSE_REQUEST);
32 }
33@@ -464,7 +466,7 @@
34 x += content_width - 1;
35 nux::GetPainter().Draw2DLine(gfx_context, x, y, x, y + height, nux::color::White * 0.13);
36 }
37-
38+
39 GetLayout()->ProcessDraw(gfx_context, force_draw);
40 nux::GetPainter().PopBackgroundStack();
41 }
42@@ -504,7 +506,7 @@
43 {
44 unsigned num_buttons = buttons_.size();
45 variant::BuilderWrapper(builder)
46- .add(GetGeometry())
47+ .add(content_geo_)
48 .add("selected_button", selected_button_)
49 .add("num_buttons", num_buttons);
50 }
51
52=== modified file 'tests/autopilot/autopilot/tests/test_hud.py'
53--- tests/autopilot/autopilot/tests/test_hud.py 2012-06-19 16:59:06 +0000
54+++ tests/autopilot/autopilot/tests/test_hud.py 2012-06-25 22:05:21 +0000
55@@ -207,7 +207,7 @@
56 self.hud.ensure_visible()
57 self.dash.ensure_visible()
58 self.addCleanup(self.dash.ensure_hidden)
59-
60+
61 self.keybinding("launcher/keynav")
62 self.assertThat(self.launcher.key_nav_is_active, Equals(False))
63
64@@ -241,6 +241,32 @@
65 self.assertThat(self.window_manager.scale_active, Eventually(Equals(True)))
66 self.assertThat(self.hud.visible, Eventually(Equals(False)))
67
68+ def test_hud_closes_click_outside_geo_shrunk(self):
69+ """
70+ Clicking outside the hud when it is shurnk will make it close.
71+ Shurnk is when the hud has no results and is much smaller then normal.
72+ """
73+
74+ self.hud.ensure_visible()
75+ (x,y,w,h) = self.hud.view.geometry
76+ self.mouse.move(w/2, h-50)
77+ self.mouse.click()
78+
79+ self.assertThat(self.hud.visible, Eventually(Equals(False)))
80+
81+ def test_hud_closes_click_outside_geo(self):
82+ """Clicking outside of the hud will make it close."""
83+
84+ self.hud.ensure_visible()
85+ self.keyboard.type("Test")
86+
87+ (x,y,w,h) = self.hud.view.geometry
88+ self.mouse.move(w/2, h+50)
89+ self.mouse.click()
90+
91+ self.assertThat(self.hud.visible, Eventually(Equals(False)))
92+
93+
94 class HudLauncherInteractionsTests(HudTestsBase):
95
96 launcher_modes = [('Launcher autohide', {'launcher_autohide': False}),

Subscribers

People subscribed via source and target branches

to all changes: