Merge lp:~brandontschaefer/unity/lp.1109150-fix-dash-indicators into lp:unity

Proposed by Brandon Schaefer
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
Merged at revision: 3090
Proposed branch: lp:~brandontschaefer/unity/lp.1109150-fix-dash-indicators
Merge into: lp:unity
Diff against target: 157 lines (+59/-4)
8 files modified
dash/DashController.cpp (+7/-0)
dash/DashController.h (+1/-0)
panel/PanelController.cpp (+14/-0)
panel/PanelController.h (+2/-0)
panel/PanelView.cpp (+5/-0)
panel/PanelView.h (+2/-0)
plugins/unityshell/src/unityshell.cpp (+16/-4)
tests/autopilot/unity/tests/test_panel.py (+12/-0)
To merge this branch: bzr merge lp:~brandontschaefer/unity/lp.1109150-fix-dash-indicators
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Andrea Azzarone (community) Approve
MC Return (community) Approve
Review via email: mp+145531@code.launchpad.net

Commit message

Clicking on the indicators in the dash will now open them! (And close the dash).

Description of the change

=== Problem ===
The panel is below the Dash when opened. This means mouse events do not get to the indicator. (This has to be this way due to the dash previews)

=== Fix ===
Check when a mouse event happens in unityshell.cpp and check if the mouse event is over an indicator. Another problem was the dash animation takes to long to finish before the mouse event gets to the indicators. So I had to make a new function that would simply hide the dash right away, so the mouse event would get to the indicator.

=== Test ===
AP test.

To post a comment you must log in.
Revision history for this message
MC Return (mc-return) wrote :

LGTM. +1

review: Approve
Revision history for this message
Andrea Azzarone (azzar1) wrote :

+bool Controller::IsMouseInsideIndicator(nux::Point mouse_position) const

nux::Point const& mo.. ?

Btw looks good to me and works here.

review: Approve
Revision history for this message
Andrea Azzarone (azzar1) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dash/DashController.cpp'
2--- dash/DashController.cpp 2012-12-13 14:26:56 +0000
3+++ dash/DashController.cpp 2013-01-30 19:02:24 +0000
4@@ -334,6 +334,13 @@
5 nux::GetWindowCompositor().SetKeyFocusArea(view_->default_focus());
6 }
7
8+void Controller::QuicklyHideDash(bool restore)
9+{
10+ HideDash(restore);
11+ timeline_animator_.Stop();
12+ window_->ShowWindow(false);
13+}
14+
15 void Controller::HideDash(bool restore)
16 {
17 if (!visible_)
18
19=== modified file 'dash/DashController.h'
20--- dash/DashController.h 2012-12-13 03:17:19 +0000
21+++ dash/DashController.h 2013-01-30 19:02:24 +0000
22@@ -59,6 +59,7 @@
23 sigc::signal<void> on_realize;
24
25 void HideDash(bool restore_focus = true);
26+ void QuicklyHideDash(bool restore_focus = true);
27 void ShowDash();
28
29 void ReFocusKeyInput();
30
31=== modified file 'panel/PanelController.cpp'
32--- panel/PanelController.cpp 2012-11-08 09:12:24 +0000
33+++ panel/PanelController.cpp 2013-01-30 19:02:24 +0000
34@@ -59,6 +59,7 @@
35 int discovery_fadein, int discovery_fadeout);
36
37 void OnScreenChanged(unsigned int primary_monitor, std::vector<nux::Geometry>& monitors, Introspectable *iobj);
38+
39 private:
40 typedef nux::ObjectPtr<nux::BaseWindow> BaseWindowPtr;
41
42@@ -291,6 +292,19 @@
43 geo = window->GetGeometry();
44 }
45
46+bool Controller::IsMouseInsideIndicator(nux::Point const& mouse_position) const
47+{
48+ for (auto view : pimpl->GetPanelViews())
49+ {
50+ PanelView* panel_view = static_cast<PanelView*>(view);
51+
52+ if (panel_view->IsMouseInsideIndicator(mouse_position))
53+ return true;
54+ }
55+
56+ return false;
57+}
58+
59 float Controller::Impl::opacity() const
60 {
61 return opacity_;
62
63=== modified file 'panel/PanelController.h'
64--- panel/PanelController.h 2012-09-11 13:57:19 +0000
65+++ panel/PanelController.h 2013-01-30 19:02:24 +0000
66@@ -53,6 +53,8 @@
67
68 float opacity() const;
69
70+ bool IsMouseInsideIndicator(nux::Point const& mouse_position) const;
71+
72 std::string GetName() const;
73 void AddProperties(GVariantBuilder* builder);
74 private:
75
76=== modified file 'panel/PanelView.cpp'
77--- panel/PanelView.cpp 2013-01-29 00:32:06 +0000
78+++ panel/PanelView.cpp 2013-01-30 19:02:24 +0000
79@@ -174,6 +174,11 @@
80 QueueDraw();
81 }
82
83+bool PanelView::IsMouseInsideIndicator(nux::Point const& mouse_position) const
84+{
85+ return indicators_->GetGeometry().IsInside(mouse_position);
86+}
87+
88 void PanelView::OnBackgroundUpdate(GVariant *data)
89 {
90 gdouble red, green, blue, alpha;
91
92=== modified file 'panel/PanelView.h'
93--- panel/PanelView.h 2012-12-18 19:25:50 +0000
94+++ panel/PanelView.h 2013-01-30 19:02:24 +0000
95@@ -66,6 +66,8 @@
96
97 void SetLauncherWidth(int width);
98
99+ bool IsMouseInsideIndicator(nux::Point const& mouse_position) const;
100+
101 protected:
102 void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
103 void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
104
105=== modified file 'plugins/unityshell/src/unityshell.cpp'
106--- plugins/unityshell/src/unityshell.cpp 2013-01-24 18:56:11 +0000
107+++ plugins/unityshell/src/unityshell.cpp 2013-01-30 19:02:24 +0000
108@@ -1530,11 +1530,23 @@
109
110 Window dash_xid = dash_controller_->window()->GetInputWindowId();
111 Window top_xid = wm.GetTopWindowAbove(dash_xid);
112- nux::Geometry const& on_top_geo = wm.GetWindowGeometry(top_xid);
113-
114- if (!dash_geo.IsInside(pt) && !DoesPointIntersectUnityGeos(pt) && !on_top_geo.IsInside(pt))
115+ nux::Geometry const& always_on_top_geo = wm.GetWindowGeometry(top_xid);
116+
117+ bool indicator_clicked = panel_controller_->IsMouseInsideIndicator(pt);
118+ bool outside_dash = !dash_geo.IsInside(pt) && !DoesPointIntersectUnityGeos(pt);
119+
120+ if ((outside_dash || indicator_clicked) && !always_on_top_geo.IsInside(pt))
121 {
122- dash_controller_->HideDash(false);
123+ if (indicator_clicked)
124+ {
125+ // We must skip the Dash hide animation, otherwise the indicators
126+ // wont recive the mouse click event
127+ dash_controller_->QuicklyHideDash();
128+ }
129+ else
130+ {
131+ dash_controller_->HideDash(false);
132+ }
133 }
134 }
135
136
137=== modified file 'tests/autopilot/unity/tests/test_panel.py'
138--- tests/autopilot/unity/tests/test_panel.py 2013-01-29 01:25:46 +0000
139+++ tests/autopilot/unity/tests/test_panel.py 2013-01-30 19:02:24 +0000
140@@ -981,6 +981,18 @@
141 self.assertThat(menu_entry.menu_x, Eventually(Equals(0)))
142 self.assertThat(menu_entry.menu_y, Eventually(Equals(0)))
143
144+ def test_indicator_opens_when_dash_is_open(self):
145+ """When the dash is open and a click is on an indicator the dash
146+ must close and the indicator must open.
147+ """
148+ self.dash.ensure_visible()
149+
150+ indicator = self.panel.indicators.get_indicator_by_name_hint("indicator-session")
151+ self.mouse_open_indicator(indicator)
152+
153+ self.assertThat(indicator.active, Eventually(Equals(True)))
154+ self.assertThat(self.dash.visible, Eventually(Equals(False)))
155+
156
157 class PanelKeyNavigationTests(PanelTestsBase):
158