diff options
| author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2016-02-17 19:40:53 +0100 |
|---|---|---|
| committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2016-02-17 19:40:53 +0100 |
| commit | 7bfba75999adde6fcb6d4198d0b1c1a4954276a4 (patch) | |
| tree | 92f64d5d72d460f88d46939def75783bc8a60ca4 /dash | |
| parent | 0973cb0c1e889358e155f2ad4241264a50231606 (diff) | |
DashView: ensure that we update scaling when monitor changes
And also use better names for dash border sizes in DashStyle (bzr r4068.5.1)
Diffstat (limited to 'dash')
| -rw-r--r-- | dash/DashController.cpp | 39 | ||||
| -rw-r--r-- | dash/DashController.h | 4 | ||||
| -rw-r--r-- | dash/DashView.cpp | 53 | ||||
| -rw-r--r-- | dash/DashView.h | 4 | ||||
| -rw-r--r-- | dash/StandaloneDash.cpp | 2 |
5 files changed, 51 insertions, 51 deletions
diff --git a/dash/DashController.cpp b/dash/DashController.cpp index 55519d28b..26042fc97 100644 --- a/dash/DashController.cpp +++ b/dash/DashController.cpp @@ -89,7 +89,7 @@ Controller::Controller(Controller::WindowCreator const& create_window) } SetupWindow(); - UScreen::GetDefault()->changed.connect([this] (int, std::vector<nux::Geometry> const&) { Relayout(true); }); + UScreen::GetDefault()->changed.connect(sigc::mem_fun(this, &Controller::OnMonitorChanged)); form_factor_changed_ = Settings::Instance().form_factor.changed.connect([this] (FormFactor) { @@ -177,7 +177,6 @@ void Controller::RegisterUBusInterests() HideDash(); } }); - } void Controller::EnsureDash() @@ -242,19 +241,30 @@ nux::Geometry Controller::GetIdealWindowGeometry() monitor_geo.height); } -void Controller::Relayout(bool check_monitor) +void Controller::OnMonitorChanged(int primary, std::vector<nux::Geometry> const& monitors) { - EnsureDash(); + if (!visible_ || !window_ || !view_) + return; - if (check_monitor) - monitor_ = CLAMP(GetIdealMonitor(), 0, static_cast<int>(UScreen::GetDefault()->GetMonitors().size()-1)); + monitor_ = std::min<int>(GetIdealMonitor(), monitors.size()-1); + view_->SetMonitor(monitor_); + Relayout(); +} - int launcher_width = unity::Settings::Instance().LauncherWidth(monitor_); - nux::Geometry geo = GetIdealWindowGeometry(); +void Controller::Relayout() +{ + EnsureDash(); view_->Relayout(); - window_->SetGeometry(geo); - view_->SetMonitorOffset(launcher_width, panel::Style::Instance().PanelHeight(monitor_)); + window_->SetGeometry(GetIdealWindowGeometry()); + UpdateDashPosition(); +} + +void Controller::UpdateDashPosition() +{ + int top_offset = panel::Style::Instance().PanelHeight(monitor_); + int left_offset = unity::Settings::Instance().LauncherWidth(monitor_); + view_->SetMonitorOffset(left_offset, top_offset); } void Controller::OnMouseDownOutsideWindow(int x, int y, @@ -308,18 +318,17 @@ bool Controller::ShowDash() return false; } + screen_ungrabbed_slot_->disconnect(); wm.SaveInputFocus(); EnsureDash(); monitor_ = GetIdealMonitor(); - screen_ungrabbed_slot_->disconnect(); - int launcher_width = unity::Settings::Instance().LauncherWidth(monitor_); - view_->SetMonitorOffset(launcher_width, panel::Style::Instance().PanelHeight(monitor_)); - view_->AboutToShow(monitor_); + view_->SetMonitor(monitor_); + view_->AboutToShow(); + UpdateDashPosition(); FocusWindow(); visible_ = true; - StartShowHideTimeline(); nux::Geometry const& view_content_geo = view_->GetContentGeometry(); diff --git a/dash/DashController.h b/dash/DashController.h index 6228a458e..686871d50 100644 --- a/dash/DashController.h +++ b/dash/DashController.h @@ -82,7 +82,9 @@ private: nux::Geometry GetIdealWindowGeometry(); int GetIdealMonitor(); - void Relayout(bool check_monitor =false); + void OnMonitorChanged(int primary, std::vector<nux::Geometry> const&); + void UpdateDashPosition(); + void Relayout(); void OnMouseDownOutsideWindow(int x, int y, unsigned long bflags, unsigned long kflags); void OnExternalShowDash(GVariant* variant); diff --git a/dash/DashView.cpp b/dash/DashView.cpp index 391ffe625..848ca5fdf 100644 --- a/dash/DashView.cpp +++ b/dash/DashView.cpp @@ -139,10 +139,8 @@ DashView::DashView(Scopes::Ptr const& scopes, ApplicationStarter::Ptr const& app SetupViews(); SetupUBusConnections(); - AddChild(overlay_window_buttons_.GetPointer()); - mouse_down.connect(sigc::mem_fun(this, &DashView::OnMouseButtonDown)); preview_state_machine_.PreviewActivated.connect(sigc::mem_fun(this, &DashView::BuildPreview)); if (scopes_) @@ -169,6 +167,15 @@ DashView::~DashView() RemoveLayout(); } +void DashView::SetMonitor(int monitor) +{ + if (monitor_== monitor) + return; + + monitor_ = monitor; + scale = Settings::Instance().em(monitor_)->DPIScale(); +} + void DashView::SetMonitorOffset(int x, int y) { renderer_.x_offset = x; @@ -460,17 +467,11 @@ void DashView::OnPreviewAnimationFinished() content_view_->SetPresentRedirectedView(true); } -void DashView::AboutToShow(int monitor) +void DashView::AboutToShow() { visible_ = true; search_bar_->text_entry()->SelectAll(); - if (monitor_ != monitor) - { - monitor_ = monitor; - scale = Settings::Instance().em(monitor_)->DPIScale(); - } - /* Give the scopes a chance to prep data before we map them */ if (active_scope_view_) { @@ -614,7 +615,7 @@ void DashView::SetupUBusConnections() sigc::mem_fun(this, &DashView::OnActivateRequest)); } -long DashView::PostLayoutManagement (long LayoutResult) +long DashView::PostLayoutManagement(long LayoutResult) { Relayout(); return LayoutResult; @@ -662,7 +663,12 @@ void DashView::Relayout() nux::Geometry DashView::GetBestFitGeometry(nux::Geometry const& for_geo) { dash::Style& style = dash::Style::Instance(); - int panel_height = renderer_.y_offset; + int vertical_offset = renderer_.y_offset; + + if (style.always_maximised) + { + return nux::Geometry(0, vertical_offset, for_geo.width, for_geo.height - vertical_offset); + } int width = 0, height = 0; int tile_width = style.GetTileWidth().CP(scale); @@ -689,14 +695,9 @@ nux::Geometry DashView::GetBestFitGeometry(nux::Geometry const& for_geo) // width/height shouldn't be bigger than the geo available. width = std::min(width, for_geo.width); // launcher width is taken into account in for_geo. - height = std::min(height, for_geo.height - panel_height); // panel height is not taken into account in for_geo. + height = std::min(height, for_geo.height - vertical_offset); // panel height is not taken into account in for_geo. - if (style.always_maximised) - { - width = std::max(0, for_geo.width); - height = std::max(0, for_geo.height - panel_height); - } - return nux::Geometry(0, panel_height, width, height); + return nux::Geometry(0, vertical_offset, width, height); } void DashView::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw) @@ -1119,18 +1120,6 @@ void DashView::DrawPreview(nux::GraphicsEngine& graphics_engine, bool force_draw } } -void DashView::OnMouseButtonDown(int x, int y, unsigned long button, unsigned long key) -{ - nux::Geometry geo(content_geo_); - - if (Settings::Instance().form_factor() == FormFactor::DESKTOP) - { - dash::Style& style = dash::Style::Instance(); - geo.width += style.GetDashRightTileWidth().CP(scale); - geo.height += style.GetDashBottomTileHeight().CP(scale); - } -} - void DashView::OnActivateRequest(GVariant* args) { glib::String uri; @@ -1508,8 +1497,8 @@ void DashView::AddProperties(debug::IntrospectionData& introspection) introspection.add(nux::Geometry(GetAbsoluteX(), GetAbsoluteY(), content_geo_.width, content_geo_.height)) .add("num_rows", num_rows) .add("form_factor", form_factor) - .add("right-border-width", style.GetDashRightTileWidth().CP(scale)) - .add("bottom-border-height", style.GetDashBottomTileHeight().CP(scale)) + .add("vertical-border-width", style.GetDashVerticalBorderWidth().CP(scale)) + .add("horizontal-border-height", style.GetDashHorizontalBorderHeight().CP(scale)) .add("preview_displaying", preview_displaying_) .add("preview_animation", animate_split_value_ * animate_preview_container_value_ * animate_preview_value_) .add("dash_maximized", style.always_maximised()) diff --git a/dash/DashView.h b/dash/DashView.h index cdcf70767..95f485157 100644 --- a/dash/DashView.h +++ b/dash/DashView.h @@ -64,11 +64,12 @@ public: nux::Property<double> scale; - void AboutToShow(int monitor); + void AboutToShow(); void AboutToHide(); void Relayout(); void DisableBlur(); void OnActivateRequest(GVariant* args); + void SetMonitor(int monitor); void SetMonitorOffset(int x, int y); bool IsCommandLensOpen() const; @@ -108,7 +109,6 @@ private: void BuildPreview(Preview::Ptr model); void ClosePreview(); void OnPreviewAnimationFinished(); - void OnMouseButtonDown(int x, int y, unsigned long button, unsigned long key); void OnBackgroundColorChanged(GVariant* args); void OnSearchChanged(std::string const& search_string); void OnLiveSearchReached(std::string const& search_string); diff --git a/dash/StandaloneDash.cpp b/dash/StandaloneDash.cpp index 81b0a6aa1..4f0a03d76 100644 --- a/dash/StandaloneDash.cpp +++ b/dash/StandaloneDash.cpp @@ -74,7 +74,7 @@ void TestRunner::Init () layout->AddView (view, 1, nux::MINOR_POSITION_CENTER); layout->SetMinMaxSize(WIDTH.CP(scale_), HEIGHT.CP(scale_)); - view->AboutToShow(0); + view->AboutToShow(); nux::GetWindowThread()->SetLayout (layout); nux::GetWindowCompositor().SetKeyFocusArea(view->default_focus()); |
