Merge lp:~3v1n0/unity/dash-positioning-improvements into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
Merged at revision: 4083
Proposed branch: lp:~3v1n0/unity/dash-positioning-improvements
Merge into: lp:unity
Diff against target: 328 lines (+65/-60)
8 files modified
dash/DashController.cpp (+32/-18)
dash/DashController.h (+3/-1)
dash/DashView.cpp (+21/-32)
dash/DashView.h (+2/-2)
dash/StandaloneDash.cpp (+1/-1)
tests/autopilot/unity/tests/test_dash.py (+2/-2)
unity-shared/DashStyle.cpp (+2/-2)
unity-shared/DashStyle.h (+2/-2)
To merge this branch: bzr merge lp:~3v1n0/unity/dash-positioning-improvements
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+286380@code.launchpad.net

Commit message

DashView: ensure that we update scaling when monitor changes

Plus don't increase the input area by border sizes when maximized.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Andrea Azzarone (azzar1) wrote :

LGTM.

review: Approve

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 2015-04-21 13:25:04 +0000
3+++ dash/DashController.cpp 2016-02-17 18:49:29 +0000
4@@ -89,7 +89,7 @@
5 }
6
7 SetupWindow();
8- UScreen::GetDefault()->changed.connect([this] (int, std::vector<nux::Geometry> const&) { Relayout(true); });
9+ UScreen::GetDefault()->changed.connect(sigc::mem_fun(this, &Controller::OnMonitorChanged));
10
11 form_factor_changed_ = Settings::Instance().form_factor.changed.connect([this] (FormFactor)
12 {
13@@ -177,7 +177,6 @@
14 HideDash();
15 }
16 });
17-
18 }
19
20 void Controller::EnsureDash()
21@@ -242,19 +241,30 @@
22 monitor_geo.height);
23 }
24
25-void Controller::Relayout(bool check_monitor)
26+void Controller::OnMonitorChanged(int primary, std::vector<nux::Geometry> const& monitors)
27+{
28+ if (!visible_ || !window_ || !view_)
29+ return;
30+
31+ monitor_ = std::min<int>(GetIdealMonitor(), monitors.size()-1);
32+ view_->SetMonitor(monitor_);
33+ Relayout();
34+}
35+
36+void Controller::Relayout()
37 {
38 EnsureDash();
39
40- if (check_monitor)
41- monitor_ = CLAMP(GetIdealMonitor(), 0, static_cast<int>(UScreen::GetDefault()->GetMonitors().size()-1));
42-
43- int launcher_width = unity::Settings::Instance().LauncherWidth(monitor_);
44- nux::Geometry geo = GetIdealWindowGeometry();
45-
46 view_->Relayout();
47- window_->SetGeometry(geo);
48- view_->SetMonitorOffset(launcher_width, panel::Style::Instance().PanelHeight(monitor_));
49+ window_->SetGeometry(GetIdealWindowGeometry());
50+ UpdateDashPosition();
51+}
52+
53+void Controller::UpdateDashPosition()
54+{
55+ int top_offset = panel::Style::Instance().PanelHeight(monitor_);
56+ int left_offset = unity::Settings::Instance().LauncherWidth(monitor_);
57+ view_->SetMonitorOffset(left_offset, top_offset);
58 }
59
60 void Controller::OnMouseDownOutsideWindow(int x, int y,
61@@ -308,18 +318,17 @@
62 return false;
63 }
64
65+ screen_ungrabbed_slot_->disconnect();
66 wm.SaveInputFocus();
67
68 EnsureDash();
69 monitor_ = GetIdealMonitor();
70- screen_ungrabbed_slot_->disconnect();
71- int launcher_width = unity::Settings::Instance().LauncherWidth(monitor_);
72- view_->SetMonitorOffset(launcher_width, panel::Style::Instance().PanelHeight(monitor_));
73- view_->AboutToShow(monitor_);
74+ view_->SetMonitor(monitor_);
75+ view_->AboutToShow();
76+ UpdateDashPosition();
77 FocusWindow();
78
79 visible_ = true;
80-
81 StartShowHideTimeline();
82
83 nux::Geometry const& view_content_geo = view_->GetContentGeometry();
84@@ -470,8 +479,13 @@
85 nux::Geometry const& view_content_geo(view_->GetContentGeometry());
86
87 nux::Geometry geo(window_geo.x, window_geo.y, view_content_geo.width, view_content_geo.height);
88- geo.width += style.GetDashRightTileWidth().CP(view_->scale());
89- geo.height += style.GetDashBottomTileHeight().CP(view_->scale());
90+
91+ if (Settings::Instance().form_factor() == FormFactor::DESKTOP)
92+ {
93+ geo.width += style.GetDashVerticalBorderWidth().CP(view_->scale());
94+ geo.height += style.GetDashHorizontalBorderHeight().CP(view_->scale());
95+ }
96+
97 return geo;
98 }
99
100
101=== modified file 'dash/DashController.h'
102--- dash/DashController.h 2015-04-22 23:54:26 +0000
103+++ dash/DashController.h 2016-02-17 18:49:29 +0000
104@@ -82,7 +82,9 @@
105
106 nux::Geometry GetIdealWindowGeometry();
107 int GetIdealMonitor();
108- void Relayout(bool check_monitor =false);
109+ void OnMonitorChanged(int primary, std::vector<nux::Geometry> const&);
110+ void UpdateDashPosition();
111+ void Relayout();
112
113 void OnMouseDownOutsideWindow(int x, int y, unsigned long bflags, unsigned long kflags);
114 void OnExternalShowDash(GVariant* variant);
115
116=== modified file 'dash/DashView.cpp'
117--- dash/DashView.cpp 2015-08-25 08:15:50 +0000
118+++ dash/DashView.cpp 2016-02-17 18:49:29 +0000
119@@ -139,10 +139,8 @@
120
121 SetupViews();
122 SetupUBusConnections();
123-
124 AddChild(overlay_window_buttons_.GetPointer());
125
126- mouse_down.connect(sigc::mem_fun(this, &DashView::OnMouseButtonDown));
127 preview_state_machine_.PreviewActivated.connect(sigc::mem_fun(this, &DashView::BuildPreview));
128
129 if (scopes_)
130@@ -169,6 +167,15 @@
131 RemoveLayout();
132 }
133
134+void DashView::SetMonitor(int monitor)
135+{
136+ if (monitor_== monitor)
137+ return;
138+
139+ monitor_ = monitor;
140+ scale = Settings::Instance().em(monitor_)->DPIScale();
141+}
142+
143 void DashView::SetMonitorOffset(int x, int y)
144 {
145 renderer_.x_offset = x;
146@@ -460,17 +467,11 @@
147 content_view_->SetPresentRedirectedView(true);
148 }
149
150-void DashView::AboutToShow(int monitor)
151+void DashView::AboutToShow()
152 {
153 visible_ = true;
154 search_bar_->text_entry()->SelectAll();
155
156- if (monitor_ != monitor)
157- {
158- monitor_ = monitor;
159- scale = Settings::Instance().em(monitor_)->DPIScale();
160- }
161-
162 /* Give the scopes a chance to prep data before we map them */
163 if (active_scope_view_)
164 {
165@@ -614,7 +615,7 @@
166 sigc::mem_fun(this, &DashView::OnActivateRequest));
167 }
168
169-long DashView::PostLayoutManagement (long LayoutResult)
170+long DashView::PostLayoutManagement(long LayoutResult)
171 {
172 Relayout();
173 return LayoutResult;
174@@ -662,7 +663,12 @@
175 nux::Geometry DashView::GetBestFitGeometry(nux::Geometry const& for_geo)
176 {
177 dash::Style& style = dash::Style::Instance();
178- int panel_height = renderer_.y_offset;
179+ int vertical_offset = renderer_.y_offset;
180+
181+ if (style.always_maximised)
182+ {
183+ return nux::Geometry(0, vertical_offset, for_geo.width, for_geo.height - vertical_offset);
184+ }
185
186 int width = 0, height = 0;
187 int tile_width = style.GetTileWidth().CP(scale);
188@@ -689,14 +695,9 @@
189
190 // width/height shouldn't be bigger than the geo available.
191 width = std::min(width, for_geo.width); // launcher width is taken into account in for_geo.
192- height = std::min(height, for_geo.height - panel_height); // panel height is not taken into account in for_geo.
193+ height = std::min(height, for_geo.height - vertical_offset); // panel height is not taken into account in for_geo.
194
195- if (style.always_maximised)
196- {
197- width = std::max(0, for_geo.width);
198- height = std::max(0, for_geo.height - panel_height);
199- }
200- return nux::Geometry(0, panel_height, width, height);
201+ return nux::Geometry(0, vertical_offset, width, height);
202 }
203
204 void DashView::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)
205@@ -1119,18 +1120,6 @@
206 }
207 }
208
209-void DashView::OnMouseButtonDown(int x, int y, unsigned long button, unsigned long key)
210-{
211- nux::Geometry geo(content_geo_);
212-
213- if (Settings::Instance().form_factor() == FormFactor::DESKTOP)
214- {
215- dash::Style& style = dash::Style::Instance();
216- geo.width += style.GetDashRightTileWidth().CP(scale);
217- geo.height += style.GetDashBottomTileHeight().CP(scale);
218- }
219-}
220-
221 void DashView::OnActivateRequest(GVariant* args)
222 {
223 glib::String uri;
224@@ -1508,8 +1497,8 @@
225 introspection.add(nux::Geometry(GetAbsoluteX(), GetAbsoluteY(), content_geo_.width, content_geo_.height))
226 .add("num_rows", num_rows)
227 .add("form_factor", form_factor)
228- .add("right-border-width", style.GetDashRightTileWidth().CP(scale))
229- .add("bottom-border-height", style.GetDashBottomTileHeight().CP(scale))
230+ .add("vertical-border-width", style.GetDashVerticalBorderWidth().CP(scale))
231+ .add("horizontal-border-height", style.GetDashHorizontalBorderHeight().CP(scale))
232 .add("preview_displaying", preview_displaying_)
233 .add("preview_animation", animate_split_value_ * animate_preview_container_value_ * animate_preview_value_)
234 .add("dash_maximized", style.always_maximised())
235
236=== modified file 'dash/DashView.h'
237--- dash/DashView.h 2015-08-25 08:15:50 +0000
238+++ dash/DashView.h 2016-02-17 18:49:29 +0000
239@@ -64,11 +64,12 @@
240
241 nux::Property<double> scale;
242
243- void AboutToShow(int monitor);
244+ void AboutToShow();
245 void AboutToHide();
246 void Relayout();
247 void DisableBlur();
248 void OnActivateRequest(GVariant* args);
249+ void SetMonitor(int monitor);
250 void SetMonitorOffset(int x, int y);
251
252 bool IsCommandLensOpen() const;
253@@ -108,7 +109,6 @@
254 void BuildPreview(Preview::Ptr model);
255 void ClosePreview();
256 void OnPreviewAnimationFinished();
257- void OnMouseButtonDown(int x, int y, unsigned long button, unsigned long key);
258 void OnBackgroundColorChanged(GVariant* args);
259 void OnSearchChanged(std::string const& search_string);
260 void OnLiveSearchReached(std::string const& search_string);
261
262=== modified file 'dash/StandaloneDash.cpp'
263--- dash/StandaloneDash.cpp 2015-11-06 18:13:34 +0000
264+++ dash/StandaloneDash.cpp 2016-02-17 18:49:29 +0000
265@@ -74,7 +74,7 @@
266 layout->AddView (view, 1, nux::MINOR_POSITION_CENTER);
267 layout->SetMinMaxSize(WIDTH.CP(scale_), HEIGHT.CP(scale_));
268
269- view->AboutToShow(0);
270+ view->AboutToShow();
271
272 nux::GetWindowThread()->SetLayout (layout);
273 nux::GetWindowCompositor().SetKeyFocusArea(view->default_focus());
274
275=== modified file 'tests/autopilot/unity/tests/test_dash.py'
276--- tests/autopilot/unity/tests/test_dash.py 2015-10-03 01:10:59 +0000
277+++ tests/autopilot/unity/tests/test_dash.py 2016-02-17 18:49:29 +0000
278@@ -740,7 +740,7 @@
279 if (self.unity.dash.view.form_factor != "desktop"):
280 self.skip("Not in desktop form-factor.")
281
282- x = self.unity.dash.view.x + self.unity.dash.view.width + self.unity.dash.view.right_border_width / 2
283+ x = self.unity.dash.view.x + self.unity.dash.view.width + self.unity.dash.view.vertical_border_width / 2
284 y = self.unity.dash.view.y + self.unity.dash.view.height / 2
285
286 self.mouse.move(x, y)
287@@ -756,7 +756,7 @@
288 self.skip("Not in desktop form-factor.")
289
290 x = self.unity.dash.view.x + self.unity.dash.view.width / 2
291- y = self.unity.dash.view.y + self.unity.dash.view.height + self.unity.dash.view.bottom_border_height / 2
292+ y = self.unity.dash.view.y + self.unity.dash.view.height + self.unity.dash.view.horizontal_border_height / 2
293
294 self.mouse.move(x, y)
295 self.mouse.click()
296
297=== modified file 'unity-shared/DashStyle.cpp'
298--- unity-shared/DashStyle.cpp 2016-02-09 01:26:22 +0000
299+++ unity-shared/DashStyle.cpp 2016-02-17 18:49:29 +0000
300@@ -2306,12 +2306,12 @@
301 return pimpl->dash_shine_.texture();
302 }
303
304-RawPixel Style::GetDashBottomTileHeight() const
305+RawPixel Style::GetDashHorizontalBorderHeight() const
306 {
307 return 30;
308 }
309
310-RawPixel Style::GetDashRightTileWidth() const
311+RawPixel Style::GetDashVerticalBorderWidth() const
312 {
313 return 30;
314 }
315
316=== modified file 'unity-shared/DashStyle.h'
317--- unity-shared/DashStyle.h 2014-07-10 19:30:17 +0000
318+++ unity-shared/DashStyle.h 2016-02-17 18:49:29 +0000
319@@ -184,8 +184,8 @@
320 BaseTexturePtr GetDashTopCorner(double scale) const;
321 BaseTexturePtr GetDashTopCornerMask(double scale) const;
322
323- RawPixel GetDashBottomTileHeight() const;
324- RawPixel GetDashRightTileWidth() const;
325+ RawPixel GetDashHorizontalBorderHeight() const;
326+ RawPixel GetDashVerticalBorderWidth() const;
327
328 BaseTexturePtr const& GetDashShine() const;
329