diff options
Diffstat (limited to 'dash')
| -rw-r--r-- | dash/DashController.cpp | 68 | ||||
| -rw-r--r-- | dash/DashController.h | 4 | ||||
| -rw-r--r-- | dash/DashView.cpp | 68 | ||||
| -rw-r--r-- | dash/DashView.h | 4 | ||||
| -rw-r--r-- | dash/StandaloneDash.cpp | 2 |
5 files changed, 86 insertions, 60 deletions
diff --git a/dash/DashController.cpp b/dash/DashController.cpp index 4bbc58f0a..91d64c0d2 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() @@ -249,24 +248,44 @@ nux::Geometry Controller::GetIdealWindowGeometry() return ideal_geo; } -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(); +} - nux::Geometry geo = GetIdealWindowGeometry(); +void Controller::Relayout() +{ + EnsureDash(); view_->Relayout(); - window_->SetGeometry(geo); + window_->SetGeometry(GetIdealWindowGeometry()); + UpdateDashPosition(); +} - int horizontal_offset = 0; +void Controller::UpdateDashPosition() +{ + auto launcher_position = Settings::Instance().launcher_position(); + int left_offset = 0; + int top_offset = panel::Style::Instance().PanelHeight(monitor_); + int launcher_size = unity::Settings::Instance().LauncherSize(monitor_); - if (Settings::Instance().launcher_position() == LauncherPosition::LEFT) - horizontal_offset = unity::Settings::Instance().LauncherSize(monitor_); + if (launcher_position == LauncherPosition::LEFT) + { + left_offset = launcher_size; + } + else if (launcher_position == LauncherPosition::BOTTOM && + Settings::Instance().form_factor() == FormFactor::DESKTOP) + { + auto const& monitor_geo = UScreen::GetDefault()->GetMonitorGeometry(monitor_); + top_offset = monitor_geo.height - view_->GetContentGeometry().height - launcher_size; + } - view_->SetMonitorOffset(horizontal_offset, panel::Style::Instance().PanelHeight(monitor_)); + view_->SetMonitorOffset(left_offset, top_offset); } void Controller::OnMouseDownOutsideWindow(int x, int y, @@ -320,19 +339,14 @@ bool Controller::ShowDash() return false; } + screen_ungrabbed_slot_->disconnect(); wm.SaveInputFocus(); EnsureDash(); monitor_ = GetIdealMonitor(); - screen_ungrabbed_slot_->disconnect(); - - int horizontal_offset = 0; - - if (Settings::Instance().launcher_position() == LauncherPosition::LEFT) - horizontal_offset = unity::Settings::Instance().LauncherSize(monitor_); - - view_->SetMonitorOffset(horizontal_offset, panel::Style::Instance().PanelHeight(monitor_)); - view_->AboutToShow(monitor_); + view_->SetMonitor(monitor_); + view_->AboutToShow(); + UpdateDashPosition(); FocusWindow(); visible_ = true; @@ -487,8 +501,16 @@ nux::Geometry Controller::GetInputWindowGeometry() nux::Geometry const& view_content_geo(view_->GetContentGeometry()); nux::Geometry geo(window_geo.x, window_geo.y, view_content_geo.width, view_content_geo.height); - geo.width += style.GetDashRightTileWidth().CP(view_->scale()); - geo.height += style.GetDashBottomTileHeight().CP(view_->scale()); + + if (Settings::Instance().form_factor() == FormFactor::DESKTOP) + { + geo.width += style.GetDashVerticalBorderWidth().CP(view_->scale()); + geo.height += style.GetDashHorizontalBorderHeight().CP(view_->scale()); + + if (Settings::Instance().launcher_position() == LauncherPosition::BOTTOM) + geo.y += view_content_geo.y - style.GetDashHorizontalBorderHeight().CP(view_->scale()); + } + return geo; } 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..9b97bace4 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; @@ -649,7 +650,20 @@ void DashView::Relayout() ubus_manager_.SendMessage(UBUS_DASH_SIZE_CHANGED, g_variant_new("(ii)", content_geo_.width, content_geo_.height)); if (preview_displaying_) - preview_container_->SetGeometry(layout_->GetGeometry()); + { + if (Settings::Instance().launcher_position() == LauncherPosition::BOTTOM) + { + auto preview_geo = content_geo_; + int padding = style.GetDashHorizontalBorderHeight().CP(scale()); + preview_geo.y += padding; + preview_geo.height -= padding; + preview_container_->SetGeometry(preview_geo); + } + else + { + preview_container_->SetGeometry(layout_->GetGeometry()); + } + } renderer_.UpdateBlurBackgroundSize(content_geo_, GetRenderAbsoluteGeometry(), false); @@ -662,7 +676,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 +708,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 +1133,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 +1510,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()); |
