From 16b83772e3f1fca6466185943bbdb2cdd188f7ef Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Mon, 3 May 2021 23:24:23 +0300 Subject: [PATCH] fixes for Sidebars hiding/showing behavior --- app/view/visibilitymanager.cpp | 134 ++++++++++-------- app/view/visibilitymanager.h | 3 + .../package/contents/ui/VisibilityManager.qml | 2 +- .../controls/CustomVisibilityModeButton.qml | 19 ++- 4 files changed, 92 insertions(+), 66 deletions(-) diff --git a/app/view/visibilitymanager.cpp b/app/view/visibilitymanager.cpp index 98cc32bfb..38e3bfe82 100644 --- a/app/view/visibilitymanager.cpp +++ b/app/view/visibilitymanager.cpp @@ -345,11 +345,13 @@ void VisibilityManager::setMode(Latte::Types::Visibility mode) case Types::SidebarOnDemand: m_connections[base] = connect(m_latteView, &Latte::View::inEditModeChanged, this, [&]() { if (!m_latteView->inEditMode()) { - toggleHiddenState(); + m_isRequestedShownSidebarOnDemand = false; + updateHiddenState(); } }); - toggleHiddenState(); + m_isRequestedShownSidebarOnDemand = false; + updateHiddenState(); break; case Types::SidebarAutoHide: @@ -677,10 +679,79 @@ void VisibilityManager::show() } } +void VisibilityManager::toggleHiddenState() +{ + if (!m_latteView->inEditMode()) { + if (isSidebar()) { + // if (m_blockHidingEvents.contains(Q_FUNC_INFO)) { + // removeBlockHidingEvent(Q_FUNC_INFO); + // } + + if (m_mode == Latte::Types::SidebarOnDemand) { + m_isRequestedShownSidebarOnDemand = !m_isRequestedShownSidebarOnDemand; + updateHiddenState(); + } else if (m_mode == Latte::Types::SidebarAutoHide) { + if (m_isHidden) { + emit mustBeShown(); + startTimerHide(SIDEBARAUTOHIDEMINIMUMSHOW + m_timerHideInterval); + } else { + emit mustBeHide(); + } + } + } else { + /* if (!m_isHidden && !m_blockHidingEvents.contains(Q_FUNC_INFO)) { + addBlockHidingEvent(Q_FUNC_INFO); + } else if (m_isHidden) { + removeBlockHidingEvent(Q_FUNC_INFO); + }*/ + } + } +} + +void VisibilityManager::updateHiddenState() +{ + if (m_dragEnter) + return; + + switch (m_mode) { + case Types::AutoHide: + case Types::WindowsCanCover: + raiseView(m_containsMouse); + break; + + case Types::DodgeActive: + dodgeActive(); + break; + + case Types::DodgeMaximized: + dodgeMaximized(); + break; + + case Types::DodgeAllWindows: + dodgeAllWindows(); + break; + + case Types::SidebarOnDemand: + raiseView(m_isRequestedShownSidebarOnDemand); + break; + + case Types::SidebarAutoHide: + raiseView(m_latteView->inEditMode() || (m_containsMouse && !m_isHidden)); + break; + + default: + break; + } +} void VisibilityManager::raiseView(bool raise) { if (m_mode == Latte::Types::SidebarOnDemand) { + if (raise && m_isHidden) { + emit mustBeShown(); + } else if (!raise && !m_isHidden && !m_dragEnter && !hidingIsBlocked()) { + emit mustBeHide(); + } return; } @@ -726,65 +797,6 @@ bool VisibilityManager::isValidMode() const return (m_mode != Types::None && m_mode != Types::NormalWindow); } -void VisibilityManager::toggleHiddenState() -{ - if (!m_latteView->inEditMode()) { - if (isSidebar()) { - if (m_blockHidingEvents.contains(Q_FUNC_INFO)) { - removeBlockHidingEvent(Q_FUNC_INFO); - } - - if (m_isHidden) { - emit mustBeShown(); - - if(m_mode == Latte::Types::SidebarAutoHide) { - startTimerHide(SIDEBARAUTOHIDEMINIMUMSHOW + m_timerHideInterval); - } - } else { - emit mustBeHide(); - } - } else { - /* if (!m_isHidden && !m_blockHidingEvents.contains(Q_FUNC_INFO)) { - addBlockHidingEvent(Q_FUNC_INFO); - } else if (m_isHidden) { - removeBlockHidingEvent(Q_FUNC_INFO); - }*/ - } - } -} - -void VisibilityManager::updateHiddenState() -{ - if (m_dragEnter) - return; - - switch (m_mode) { - case Types::AutoHide: - case Types::WindowsCanCover: - raiseView(m_containsMouse); - break; - - case Types::DodgeActive: - dodgeActive(); - break; - - case Types::DodgeMaximized: - dodgeMaximized(); - break; - - case Types::DodgeAllWindows: - dodgeAllWindows(); - break; - - case Types::SidebarAutoHide: - raiseView(m_latteView->inEditMode() || (m_containsMouse && !m_isHidden)); - break; - - default: - break; - } -} - void VisibilityManager::applyActivitiesToHiddenWindows(const QStringList &activities) { if (m_edgeGhostWindow) { diff --git a/app/view/visibilitymanager.h b/app/view/visibilitymanager.h index 6364e826f..f435e34ef 100644 --- a/app/view/visibilitymanager.h +++ b/app/view/visibilitymanager.h @@ -233,6 +233,9 @@ private: bool m_raiseOnActivityChange{false}; bool m_hideNow{false}; + //! valid on demand sidebar hidden state in order to be checked after slide-ins/outs + bool m_isRequestedShownSidebarOnDemand{false}; + int m_frameExtentsHeadThicknessGap{0}; int m_timerHideInterval{700}; Plasma::Types::Location m_frameExtentsLocation{Plasma::Types::BottomEdge}; diff --git a/containment/package/contents/ui/VisibilityManager.qml b/containment/package/contents/ui/VisibilityManager.qml index b07051521..3448d4bd5 100644 --- a/containment/package/contents/ui/VisibilityManager.qml +++ b/containment/package/contents/ui/VisibilityManager.qml @@ -578,7 +578,7 @@ Item{ //! Normal Dodge/AutoHide case if (!slidingAnimationAutoHiddenOut.running && !latteView.visibility.blockHiding - && (!latteView.visibility.containsMouse)) { + && !latteView.visibility.containsMouse) { slidingAnimationAutoHiddenOut.init(); } } diff --git a/shell/package/contents/controls/CustomVisibilityModeButton.qml b/shell/package/contents/controls/CustomVisibilityModeButton.qml index 3162780cd..dfe8413a7 100644 --- a/shell/package/contents/controls/CustomVisibilityModeButton.qml +++ b/shell/package/contents/controls/CustomVisibilityModeButton.qml @@ -40,10 +40,18 @@ LatteComponents.ComboBoxButton{ comboBoxPopupTextHorizontalAlignment: Text.AlignHCenter property int mode: LatteCore.Types.WindowsGoBelow - readonly property int currentModeIndex: Math.min(Math.max(0, mode-firstVisibilityMode), lastVisibilityMode-firstVisibilityMode) + readonly property int currentModeIndex: { + for (var i=0; i= custom.firstVisibilityMode && latteView.visibility.mode<=custom.lastVisibilityMode) { - custom.viewRelevantVisibilityModeChanged(); + for (var i=0; i