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
=== modified file 'dash/DashController.cpp'
--- dash/DashController.cpp 2015-04-21 13:25:04 +0000
+++ dash/DashController.cpp 2016-02-17 18:49:29 +0000
@@ -89,7 +89,7 @@
89 }89 }
9090
91 SetupWindow();91 SetupWindow();
92 UScreen::GetDefault()->changed.connect([this] (int, std::vector<nux::Geometry> const&) { Relayout(true); });92 UScreen::GetDefault()->changed.connect(sigc::mem_fun(this, &Controller::OnMonitorChanged));
9393
94 form_factor_changed_ = Settings::Instance().form_factor.changed.connect([this] (FormFactor)94 form_factor_changed_ = Settings::Instance().form_factor.changed.connect([this] (FormFactor)
95 {95 {
@@ -177,7 +177,6 @@
177 HideDash();177 HideDash();
178 }178 }
179 });179 });
180
181}180}
182181
183void Controller::EnsureDash()182void Controller::EnsureDash()
@@ -242,19 +241,30 @@
242 monitor_geo.height);241 monitor_geo.height);
243}242}
244243
245void Controller::Relayout(bool check_monitor)244void Controller::OnMonitorChanged(int primary, std::vector<nux::Geometry> const& monitors)
245{
246 if (!visible_ || !window_ || !view_)
247 return;
248
249 monitor_ = std::min<int>(GetIdealMonitor(), monitors.size()-1);
250 view_->SetMonitor(monitor_);
251 Relayout();
252}
253
254void Controller::Relayout()
246{255{
247 EnsureDash();256 EnsureDash();
248257
249 if (check_monitor)
250 monitor_ = CLAMP(GetIdealMonitor(), 0, static_cast<int>(UScreen::GetDefault()->GetMonitors().size()-1));
251
252 int launcher_width = unity::Settings::Instance().LauncherWidth(monitor_);
253 nux::Geometry geo = GetIdealWindowGeometry();
254
255 view_->Relayout();258 view_->Relayout();
256 window_->SetGeometry(geo);259 window_->SetGeometry(GetIdealWindowGeometry());
257 view_->SetMonitorOffset(launcher_width, panel::Style::Instance().PanelHeight(monitor_));260 UpdateDashPosition();
261}
262
263void Controller::UpdateDashPosition()
264{
265 int top_offset = panel::Style::Instance().PanelHeight(monitor_);
266 int left_offset = unity::Settings::Instance().LauncherWidth(monitor_);
267 view_->SetMonitorOffset(left_offset, top_offset);
258}268}
259269
260void Controller::OnMouseDownOutsideWindow(int x, int y,270void Controller::OnMouseDownOutsideWindow(int x, int y,
@@ -308,18 +318,17 @@
308 return false;318 return false;
309 }319 }
310320
321 screen_ungrabbed_slot_->disconnect();
311 wm.SaveInputFocus();322 wm.SaveInputFocus();
312323
313 EnsureDash();324 EnsureDash();
314 monitor_ = GetIdealMonitor();325 monitor_ = GetIdealMonitor();
315 screen_ungrabbed_slot_->disconnect();326 view_->SetMonitor(monitor_);
316 int launcher_width = unity::Settings::Instance().LauncherWidth(monitor_);327 view_->AboutToShow();
317 view_->SetMonitorOffset(launcher_width, panel::Style::Instance().PanelHeight(monitor_));328 UpdateDashPosition();
318 view_->AboutToShow(monitor_);
319 FocusWindow();329 FocusWindow();
320330
321 visible_ = true;331 visible_ = true;
322
323 StartShowHideTimeline();332 StartShowHideTimeline();
324333
325 nux::Geometry const& view_content_geo = view_->GetContentGeometry();334 nux::Geometry const& view_content_geo = view_->GetContentGeometry();
@@ -470,8 +479,13 @@
470 nux::Geometry const& view_content_geo(view_->GetContentGeometry());479 nux::Geometry const& view_content_geo(view_->GetContentGeometry());
471480
472 nux::Geometry geo(window_geo.x, window_geo.y, view_content_geo.width, view_content_geo.height);481 nux::Geometry geo(window_geo.x, window_geo.y, view_content_geo.width, view_content_geo.height);
473 geo.width += style.GetDashRightTileWidth().CP(view_->scale());482
474 geo.height += style.GetDashBottomTileHeight().CP(view_->scale());483 if (Settings::Instance().form_factor() == FormFactor::DESKTOP)
484 {
485 geo.width += style.GetDashVerticalBorderWidth().CP(view_->scale());
486 geo.height += style.GetDashHorizontalBorderHeight().CP(view_->scale());
487 }
488
475 return geo;489 return geo;
476}490}
477491
478492
=== modified file 'dash/DashController.h'
--- dash/DashController.h 2015-04-22 23:54:26 +0000
+++ dash/DashController.h 2016-02-17 18:49:29 +0000
@@ -82,7 +82,9 @@
8282
83 nux::Geometry GetIdealWindowGeometry();83 nux::Geometry GetIdealWindowGeometry();
84 int GetIdealMonitor();84 int GetIdealMonitor();
85 void Relayout(bool check_monitor =false);85 void OnMonitorChanged(int primary, std::vector<nux::Geometry> const&);
86 void UpdateDashPosition();
87 void Relayout();
8688
87 void OnMouseDownOutsideWindow(int x, int y, unsigned long bflags, unsigned long kflags);89 void OnMouseDownOutsideWindow(int x, int y, unsigned long bflags, unsigned long kflags);
88 void OnExternalShowDash(GVariant* variant);90 void OnExternalShowDash(GVariant* variant);
8991
=== modified file 'dash/DashView.cpp'
--- dash/DashView.cpp 2015-08-25 08:15:50 +0000
+++ dash/DashView.cpp 2016-02-17 18:49:29 +0000
@@ -139,10 +139,8 @@
139139
140 SetupViews();140 SetupViews();
141 SetupUBusConnections();141 SetupUBusConnections();
142
143 AddChild(overlay_window_buttons_.GetPointer());142 AddChild(overlay_window_buttons_.GetPointer());
144143
145 mouse_down.connect(sigc::mem_fun(this, &DashView::OnMouseButtonDown));
146 preview_state_machine_.PreviewActivated.connect(sigc::mem_fun(this, &DashView::BuildPreview));144 preview_state_machine_.PreviewActivated.connect(sigc::mem_fun(this, &DashView::BuildPreview));
147145
148 if (scopes_)146 if (scopes_)
@@ -169,6 +167,15 @@
169 RemoveLayout();167 RemoveLayout();
170}168}
171169
170void DashView::SetMonitor(int monitor)
171{
172 if (monitor_== monitor)
173 return;
174
175 monitor_ = monitor;
176 scale = Settings::Instance().em(monitor_)->DPIScale();
177}
178
172void DashView::SetMonitorOffset(int x, int y)179void DashView::SetMonitorOffset(int x, int y)
173{180{
174 renderer_.x_offset = x;181 renderer_.x_offset = x;
@@ -460,17 +467,11 @@
460 content_view_->SetPresentRedirectedView(true);467 content_view_->SetPresentRedirectedView(true);
461}468}
462469
463void DashView::AboutToShow(int monitor)470void DashView::AboutToShow()
464{471{
465 visible_ = true;472 visible_ = true;
466 search_bar_->text_entry()->SelectAll();473 search_bar_->text_entry()->SelectAll();
467474
468 if (monitor_ != monitor)
469 {
470 monitor_ = monitor;
471 scale = Settings::Instance().em(monitor_)->DPIScale();
472 }
473
474 /* Give the scopes a chance to prep data before we map them */475 /* Give the scopes a chance to prep data before we map them */
475 if (active_scope_view_)476 if (active_scope_view_)
476 {477 {
@@ -614,7 +615,7 @@
614 sigc::mem_fun(this, &DashView::OnActivateRequest));615 sigc::mem_fun(this, &DashView::OnActivateRequest));
615}616}
616617
617long DashView::PostLayoutManagement (long LayoutResult)618long DashView::PostLayoutManagement(long LayoutResult)
618{619{
619 Relayout();620 Relayout();
620 return LayoutResult;621 return LayoutResult;
@@ -662,7 +663,12 @@
662nux::Geometry DashView::GetBestFitGeometry(nux::Geometry const& for_geo)663nux::Geometry DashView::GetBestFitGeometry(nux::Geometry const& for_geo)
663{664{
664 dash::Style& style = dash::Style::Instance();665 dash::Style& style = dash::Style::Instance();
665 int panel_height = renderer_.y_offset;666 int vertical_offset = renderer_.y_offset;
667
668 if (style.always_maximised)
669 {
670 return nux::Geometry(0, vertical_offset, for_geo.width, for_geo.height - vertical_offset);
671 }
666672
667 int width = 0, height = 0;673 int width = 0, height = 0;
668 int tile_width = style.GetTileWidth().CP(scale);674 int tile_width = style.GetTileWidth().CP(scale);
@@ -689,14 +695,9 @@
689695
690 // width/height shouldn't be bigger than the geo available.696 // width/height shouldn't be bigger than the geo available.
691 width = std::min(width, for_geo.width); // launcher width is taken into account in for_geo.697 width = std::min(width, for_geo.width); // launcher width is taken into account in for_geo.
692 height = std::min(height, for_geo.height - panel_height); // panel height is not taken into account in for_geo.698 height = std::min(height, for_geo.height - vertical_offset); // panel height is not taken into account in for_geo.
693699
694 if (style.always_maximised)700 return nux::Geometry(0, vertical_offset, width, height);
695 {
696 width = std::max(0, for_geo.width);
697 height = std::max(0, for_geo.height - panel_height);
698 }
699 return nux::Geometry(0, panel_height, width, height);
700}701}
701702
702void DashView::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)703void DashView::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)
@@ -1119,18 +1120,6 @@
1119 }1120 }
1120}1121}
11211122
1122void DashView::OnMouseButtonDown(int x, int y, unsigned long button, unsigned long key)
1123{
1124 nux::Geometry geo(content_geo_);
1125
1126 if (Settings::Instance().form_factor() == FormFactor::DESKTOP)
1127 {
1128 dash::Style& style = dash::Style::Instance();
1129 geo.width += style.GetDashRightTileWidth().CP(scale);
1130 geo.height += style.GetDashBottomTileHeight().CP(scale);
1131 }
1132}
1133
1134void DashView::OnActivateRequest(GVariant* args)1123void DashView::OnActivateRequest(GVariant* args)
1135{1124{
1136 glib::String uri;1125 glib::String uri;
@@ -1508,8 +1497,8 @@
1508 introspection.add(nux::Geometry(GetAbsoluteX(), GetAbsoluteY(), content_geo_.width, content_geo_.height))1497 introspection.add(nux::Geometry(GetAbsoluteX(), GetAbsoluteY(), content_geo_.width, content_geo_.height))
1509 .add("num_rows", num_rows)1498 .add("num_rows", num_rows)
1510 .add("form_factor", form_factor)1499 .add("form_factor", form_factor)
1511 .add("right-border-width", style.GetDashRightTileWidth().CP(scale))1500 .add("vertical-border-width", style.GetDashVerticalBorderWidth().CP(scale))
1512 .add("bottom-border-height", style.GetDashBottomTileHeight().CP(scale))1501 .add("horizontal-border-height", style.GetDashHorizontalBorderHeight().CP(scale))
1513 .add("preview_displaying", preview_displaying_)1502 .add("preview_displaying", preview_displaying_)
1514 .add("preview_animation", animate_split_value_ * animate_preview_container_value_ * animate_preview_value_)1503 .add("preview_animation", animate_split_value_ * animate_preview_container_value_ * animate_preview_value_)
1515 .add("dash_maximized", style.always_maximised())1504 .add("dash_maximized", style.always_maximised())
15161505
=== modified file 'dash/DashView.h'
--- dash/DashView.h 2015-08-25 08:15:50 +0000
+++ dash/DashView.h 2016-02-17 18:49:29 +0000
@@ -64,11 +64,12 @@
6464
65 nux::Property<double> scale;65 nux::Property<double> scale;
6666
67 void AboutToShow(int monitor);67 void AboutToShow();
68 void AboutToHide();68 void AboutToHide();
69 void Relayout();69 void Relayout();
70 void DisableBlur();70 void DisableBlur();
71 void OnActivateRequest(GVariant* args);71 void OnActivateRequest(GVariant* args);
72 void SetMonitor(int monitor);
72 void SetMonitorOffset(int x, int y);73 void SetMonitorOffset(int x, int y);
7374
74 bool IsCommandLensOpen() const;75 bool IsCommandLensOpen() const;
@@ -108,7 +109,6 @@
108 void BuildPreview(Preview::Ptr model);109 void BuildPreview(Preview::Ptr model);
109 void ClosePreview();110 void ClosePreview();
110 void OnPreviewAnimationFinished();111 void OnPreviewAnimationFinished();
111 void OnMouseButtonDown(int x, int y, unsigned long button, unsigned long key);
112 void OnBackgroundColorChanged(GVariant* args);112 void OnBackgroundColorChanged(GVariant* args);
113 void OnSearchChanged(std::string const& search_string);113 void OnSearchChanged(std::string const& search_string);
114 void OnLiveSearchReached(std::string const& search_string);114 void OnLiveSearchReached(std::string const& search_string);
115115
=== modified file 'dash/StandaloneDash.cpp'
--- dash/StandaloneDash.cpp 2015-11-06 18:13:34 +0000
+++ dash/StandaloneDash.cpp 2016-02-17 18:49:29 +0000
@@ -74,7 +74,7 @@
74 layout->AddView (view, 1, nux::MINOR_POSITION_CENTER);74 layout->AddView (view, 1, nux::MINOR_POSITION_CENTER);
75 layout->SetMinMaxSize(WIDTH.CP(scale_), HEIGHT.CP(scale_));75 layout->SetMinMaxSize(WIDTH.CP(scale_), HEIGHT.CP(scale_));
7676
77 view->AboutToShow(0);77 view->AboutToShow();
7878
79 nux::GetWindowThread()->SetLayout (layout);79 nux::GetWindowThread()->SetLayout (layout);
80 nux::GetWindowCompositor().SetKeyFocusArea(view->default_focus());80 nux::GetWindowCompositor().SetKeyFocusArea(view->default_focus());
8181
=== modified file 'tests/autopilot/unity/tests/test_dash.py'
--- tests/autopilot/unity/tests/test_dash.py 2015-10-03 01:10:59 +0000
+++ tests/autopilot/unity/tests/test_dash.py 2016-02-17 18:49:29 +0000
@@ -740,7 +740,7 @@
740 if (self.unity.dash.view.form_factor != "desktop"):740 if (self.unity.dash.view.form_factor != "desktop"):
741 self.skip("Not in desktop form-factor.")741 self.skip("Not in desktop form-factor.")
742742
743 x = self.unity.dash.view.x + self.unity.dash.view.width + self.unity.dash.view.right_border_width / 2743 x = self.unity.dash.view.x + self.unity.dash.view.width + self.unity.dash.view.vertical_border_width / 2
744 y = self.unity.dash.view.y + self.unity.dash.view.height / 2744 y = self.unity.dash.view.y + self.unity.dash.view.height / 2
745745
746 self.mouse.move(x, y)746 self.mouse.move(x, y)
@@ -756,7 +756,7 @@
756 self.skip("Not in desktop form-factor.")756 self.skip("Not in desktop form-factor.")
757757
758 x = self.unity.dash.view.x + self.unity.dash.view.width / 2758 x = self.unity.dash.view.x + self.unity.dash.view.width / 2
759 y = self.unity.dash.view.y + self.unity.dash.view.height + self.unity.dash.view.bottom_border_height / 2759 y = self.unity.dash.view.y + self.unity.dash.view.height + self.unity.dash.view.horizontal_border_height / 2
760760
761 self.mouse.move(x, y)761 self.mouse.move(x, y)
762 self.mouse.click()762 self.mouse.click()
763763
=== modified file 'unity-shared/DashStyle.cpp'
--- unity-shared/DashStyle.cpp 2016-02-09 01:26:22 +0000
+++ unity-shared/DashStyle.cpp 2016-02-17 18:49:29 +0000
@@ -2306,12 +2306,12 @@
2306 return pimpl->dash_shine_.texture();2306 return pimpl->dash_shine_.texture();
2307}2307}
23082308
2309RawPixel Style::GetDashBottomTileHeight() const2309RawPixel Style::GetDashHorizontalBorderHeight() const
2310{2310{
2311 return 30;2311 return 30;
2312}2312}
23132313
2314RawPixel Style::GetDashRightTileWidth() const2314RawPixel Style::GetDashVerticalBorderWidth() const
2315{2315{
2316 return 30;2316 return 30;
2317}2317}
23182318
=== modified file 'unity-shared/DashStyle.h'
--- unity-shared/DashStyle.h 2014-07-10 19:30:17 +0000
+++ unity-shared/DashStyle.h 2016-02-17 18:49:29 +0000
@@ -184,8 +184,8 @@
184 BaseTexturePtr GetDashTopCorner(double scale) const;184 BaseTexturePtr GetDashTopCorner(double scale) const;
185 BaseTexturePtr GetDashTopCornerMask(double scale) const;185 BaseTexturePtr GetDashTopCornerMask(double scale) const;
186186
187 RawPixel GetDashBottomTileHeight() const;187 RawPixel GetDashHorizontalBorderHeight() const;
188 RawPixel GetDashRightTileWidth() const;188 RawPixel GetDashVerticalBorderWidth() const;
189189
190 BaseTexturePtr const& GetDashShine() const;190 BaseTexturePtr const& GetDashShine() const;
191191