From 3ec142d3a2bc1cbe964f3e287b57d83a9481d287 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sun, 11 Apr 2021 18:26:56 +0300 Subject: [PATCH] drop deprecated screen edge relocation codepath --- app/view/positioner.cpp | 79 +++++++++++++++---- app/view/positioner.h | 10 +-- .../package/contents/ui/VisibilityManager.qml | 2 +- containment/package/contents/ui/main.qml | 18 +++-- .../configuration/pages/BehaviorConfig.qml | 8 +- 5 files changed, 85 insertions(+), 32 deletions(-) diff --git a/app/view/positioner.cpp b/app/view/positioner.cpp index 020e7236c..199cdb248 100644 --- a/app/view/positioner.cpp +++ b/app/view/positioner.cpp @@ -115,14 +115,15 @@ void Positioner::init() //! connections connect(this, &Positioner::screenGeometryChanged, this, &Positioner::syncGeometry); - connect(this, &Positioner::hideDockDuringLocationChangeStarted, this, &Positioner::updateInRelocationAnimation); + connect(this, &Positioner::hidingForRelocationStarted, this, &Positioner::updateInRelocationAnimation); + connect(this, &Positioner::showingAfterRelocationFinished, this, &Positioner::updateInRelocationAnimation); + connect(this, &Positioner::showingAfterRelocationFinished, this, &Positioner::syncLatteViews); + connect(this, &Positioner::hideDockDuringScreenChangeStarted, this, &Positioner::updateInRelocationAnimation); connect(this, &Positioner::hideDockDuringMovingToLayoutStarted, this, &Positioner::updateInRelocationAnimation); - connect(this, &Positioner::showDockAfterLocationChangeFinished, this, &Positioner::updateInRelocationAnimation); connect(this, &Positioner::showDockAfterScreenChangeFinished, this, &Positioner::updateInRelocationAnimation); connect(this, &Positioner::showDockAfterMovingToLayoutFinished, this, &Positioner::updateInRelocationAnimation); - connect(this, &Positioner::showDockAfterLocationChangeFinished, this, &Positioner::syncLatteViews); connect(this, &Positioner::showDockAfterScreenChangeFinished, this, &Positioner::syncLatteViews); connect(this, &Positioner::showDockAfterMovingToLayoutFinished, this, &Positioner::syncLatteViews); connect(m_view, &Latte::View::onPrimaryChanged, this, &Positioner::syncLatteViews); @@ -890,21 +891,29 @@ void Positioner::updateFormFactor() void Positioner::initSignalingForLocationChangeSliding() { + connect(this, &Positioner::hidingForRelocationStarted, this, &Positioner::onHideWindowsForSlidingOut); + //! signals to handle the sliding-in/out during location changes - connect(this, &Positioner::hideDockDuringLocationChangeStarted, this, &Positioner::onHideWindowsForSlidingOut); connect(m_view, &View::locationChanged, this, [&]() { if (m_nextScreenEdge != Plasma::Types::Floating) { - immediateSyncGeometry(); + bool isrelocationlastevent = isLastHidingRelocationEvent(); + immediateSyncGeometry(); m_nextScreenEdge = Plasma::Types::Floating; - QTimer::singleShot(100, [this]() { - m_view->effects()->setAnimationsBlocked(false); - emit showDockAfterLocationChangeFinished(); - m_view->showSettingsWindow(); - emit edgeChanged(); - }); + if (isrelocationlastevent) { + QTimer::singleShot(100, [this]() { + m_view->effects()->setAnimationsBlocked(false); + emit showingAfterRelocationFinished(); + emit edgeChanged(); + + if (m_repositionFromViewSettingsWindow) { + m_repositionFromViewSettingsWindow = false; + m_view->showSettingsWindow(); + } + }); + } } }); @@ -947,7 +956,7 @@ void Positioner::initSignalingForLocationChangeSliding() //! ---- both cases ---- !// //! this is used for both location and screen change cases, this signal //! is send when the sliding-out animation has finished - connect(this, &Positioner::hideDockDuringLocationChangeFinished, this, [&]() { + /* connect(this, &Positioner::hideDockDuringLocationChangeFinished, this, [&]() { m_view->effects()->setAnimationsBlocked(true); if (m_nextScreenEdge != Plasma::Types::Floating) { @@ -957,6 +966,14 @@ void Positioner::initSignalingForLocationChangeSliding() } else if (!m_nextLayout.isEmpty()) { m_view->moveToLayout(m_nextLayout); } + });*/ + + connect(this, &Positioner::hidingForRelocationFinished, this, [&]() { + m_view->effects()->setAnimationsBlocked(true); + + if (m_nextScreenEdge != Plasma::Types::Floating) { + m_view->setLocation(m_nextScreenEdge); + } }); } @@ -1022,7 +1039,7 @@ void Positioner::setIsStickedOnBottomEdge(bool sticked) void Positioner::updateInRelocationAnimation() { - bool inRelocationAnimation = ((m_nextScreenEdge != Plasma::Types::Floating) || (m_nextLayout != "") || m_nextScreen); + bool inRelocationAnimation = ((m_nextScreenEdge != Plasma::Types::Floating) || (!m_nextLayout.isEmpty()) || m_nextScreen); if (m_inRelocationAnimation == inRelocationAnimation) { return; @@ -1032,10 +1049,23 @@ void Positioner::updateInRelocationAnimation() emit inRelocationAnimationChanged(); } -void Positioner::hideDockDuringLocationChange(int goToLocation) +bool Positioner::isLastHidingRelocationEvent() const { - m_nextScreenEdge = static_cast(goToLocation); - emit hideDockDuringLocationChangeStarted(); + int events{0}; + + if (!m_nextLayout.isEmpty()) { + events++; + } + + if (m_nextScreen != nullptr){ + events++; + } + + if (m_nextScreenEdge != Plasma::Types::Floating) { + events++; + } + + return (events <= 1); } void Positioner::hideDockDuringMovingToLayout(QString layoutName) @@ -1064,5 +1094,22 @@ void Positioner::hideDockDuringMovingToLayout(QString layoutName) } } +void Positioner::setNextLocation(const QString layoutName, const QString screenId, int edge, int alignment) +{ + bool animated{false}; + + if (edge != m_view->location()) { + m_nextScreenEdge = static_cast(edge); + animated = true; + } + + m_repositionFromViewSettingsWindow = m_view->settingsWindowIsShown(); + + if (animated) { + emit hidingForRelocationStarted(); + } + +} + } } diff --git a/app/view/positioner.h b/app/view/positioner.h index ee4eaae32..5650e6c09 100644 --- a/app/view/positioner.h +++ b/app/view/positioner.h @@ -96,11 +96,10 @@ public: Latte::WindowSystem::WindowId trackedWindowId(); public slots: - Q_INVOKABLE void hideDockDuringLocationChange(int goToLocation); Q_INVOKABLE void hideDockDuringMovingToLayout(QString layoutName); Q_INVOKABLE bool setCurrentScreen(const QString id); - // Q_INVOKABLE void setNextLocation(const QString layoutName, const QString screenId, int edge, int alignment); + Q_INVOKABLE void setNextLocation(const QString layoutName, const QString screenId, int edge, int alignment); void syncGeometry(); @@ -127,13 +126,10 @@ signals: void showingAfterRelocationFinished(); //! Deprecated - void hideDockDuringLocationChangeStarted(); - void hideDockDuringLocationChangeFinished(); void hideDockDuringScreenChangeStarted(); void hideDockDuringScreenChangeFinished(); void hideDockDuringMovingToLayoutStarted(); void hideDockDuringMovingToLayoutFinished(); - void showDockAfterLocationChangeFinished(); void showDockAfterScreenChangeFinished(); void showDockAfterMovingToLayoutFinished(); @@ -165,6 +161,8 @@ private: void setCanvasGeometry(const QRect &geometry); + bool isLastHidingRelocationEvent() const; + QRect maximumNormalGeometry(); private: @@ -195,6 +193,8 @@ private: QTimer m_validateGeometryTimer; //!used for relocation properties group + bool m_repositionFromViewSettingsWindow{false}; + QString m_nextLayout; Plasma::Types::Location m_nextScreenEdge{Plasma::Types::Floating}; QScreen *m_nextScreen{nullptr}; diff --git a/containment/package/contents/ui/VisibilityManager.qml b/containment/package/contents/ui/VisibilityManager.qml index ea94c7981..fde2d67fd 100644 --- a/containment/package/contents/ui/VisibilityManager.qml +++ b/containment/package/contents/ui/VisibilityManager.qml @@ -540,7 +540,7 @@ Item{ } function sendHideDockDuringLocationChangeFinished(){ - latteView.positioner.hideDockDuringLocationChangeFinished(); + latteView.positioner.hidingForRelocationFinished(); } function sendSlidingOutAnimationEnded() { diff --git a/containment/package/contents/ui/main.qml b/containment/package/contents/ui/main.qml index b8f01a27d..f6c2e4e69 100644 --- a/containment/package/contents/ui/main.qml +++ b/containment/package/contents/ui/main.qml @@ -482,8 +482,10 @@ Item { onLatteViewChanged: { if (latteView) { if (latteView.positioner) { - latteView.positioner.hideDockDuringLocationChangeStarted.connect(visibilityManager.slotHideDockDuringLocationChange); - latteView.positioner.showDockAfterLocationChangeFinished.connect(visibilityManager.slotShowDockAfterLocationChange); + latteView.positioner.hidingForRelocationStarted.connect(visibilityManager.slotHideDockDuringLocationChange); + latteView.positioner.showingAfterRelocationFinished.connect(visibilityManager.slotShowDockAfterLocationChange); + + //! Deprecated latteView.positioner.hideDockDuringScreenChangeStarted.connect(visibilityManager.slotHideDockDuringLocationChange); latteView.positioner.showDockAfterScreenChangeFinished.connect(visibilityManager.slotShowDockAfterLocationChange); latteView.positioner.hideDockDuringMovingToLayoutStarted.connect(visibilityManager.slotHideDockDuringLocationChange); @@ -502,8 +504,10 @@ Item { target: latteView onPositionerChanged: { if (latteView.positioner) { - latteView.positioner.hideDockDuringLocationChangeStarted.connect(visibilityManager.slotHideDockDuringLocationChange); - latteView.positioner.showDockAfterLocationChangeFinished.connect(visibilityManager.slotShowDockAfterLocationChange); + latteView.positioner.hidingForRelocationStarted.connect(visibilityManager.slotHideDockDuringLocationChange); + latteView.positioner.showingAfterRelocationFinished.connect(visibilityManager.slotShowDockAfterLocationChange); + + //! Deprecated latteView.positioner.hideDockDuringScreenChangeStarted.connect(visibilityManager.slotHideDockDuringLocationChange); latteView.positioner.showDockAfterScreenChangeFinished.connect(visibilityManager.slotShowDockAfterLocationChange); latteView.positioner.hideDockDuringMovingToLayoutStarted.connect(visibilityManager.slotHideDockDuringLocationChange); @@ -563,8 +567,10 @@ Item { if (latteView) { if (latteView.positioner) { - latteView.positioner.hideDockDuringLocationChangeStarted.disconnect(visibilityManager.slotHideDockDuringLocationChange); - latteView.positioner.showDockAfterLocationChangeFinished.disconnect(visibilityManager.slotShowDockAfterLocationChange); + latteView.positioner.hidingForRelocationStarted.disconnect(visibilityManager.slotHideDockDuringLocationChange); + latteView.positioner.showingAfterRelocationFinished.disconnect(visibilityManager.slotShowDockAfterLocationChange); + + // Deprecated latteView.positioner.hideDockDuringScreenChangeStarted.disconnect(visibilityManager.slotHideDockDuringLocationChange); latteView.positioner.showDockAfterScreenChangeFinished.disconnect(visibilityManager.slotShowDockAfterLocationChange); latteView.positioner.hideDockDuringMovingToLayoutStarted.disconnect(visibilityManager.slotHideDockDuringLocationChange); diff --git a/shell/package/contents/configuration/pages/BehaviorConfig.qml b/shell/package/contents/configuration/pages/BehaviorConfig.qml index a58333b4d..194291270 100644 --- a/shell/package/contents/configuration/pages/BehaviorConfig.qml +++ b/shell/package/contents/configuration/pages/BehaviorConfig.qml @@ -217,7 +217,7 @@ PlasmaComponents.Page { onClicked: { //! clicked event is more wayland friendly because it release focus from the button before hiding the window if (viewConfig.isReady && plasmoid.location !== edge) { - latteView.positioner.hideDockDuringLocationChange(edge); + latteView.positioner.setNextLocation("", "", edge, LatteCore.Types.NoneAlignment); } } } @@ -236,7 +236,7 @@ PlasmaComponents.Page { onClicked: { //! clicked event is more wayland friendly because it release focus from the button before hiding the window if (viewConfig.isReady && plasmoid.location !== edge) { - latteView.positioner.hideDockDuringLocationChange(edge); + latteView.positioner.setNextLocation("", "", edge, LatteCore.Types.NoneAlignment); } } } @@ -255,7 +255,7 @@ PlasmaComponents.Page { onClicked: { //! clicked event is more wayland friendly because it release focus from the button before hiding the window if (viewConfig.isReady && plasmoid.location !== edge) { - latteView.positioner.hideDockDuringLocationChange(edge); + latteView.positioner.setNextLocation("", "", edge, LatteCore.Types.NoneAlignment); } } } @@ -274,7 +274,7 @@ PlasmaComponents.Page { onClicked: { //! clicked event is more wayland friendly because it release focus from the button before hiding the window if (viewConfig.isReady && plasmoid.location !== edge) { - latteView.positioner.hideDockDuringLocationChange(edge); + latteView.positioner.setNextLocation("", "", edge, LatteCore.Types.NoneAlignment); } } }