From 706a80cae3f760fdc5a978e99ac67b2a2a374652 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Tue, 7 Jan 2020 17:52:52 +0200 Subject: [PATCH] hide timer for floating views --for floating views the hide timer can do the trick about when to make the checks that the view must become hidden. In floating views should support different default and current value because it should be greater that the normal use cases. --- app/view/visibilitymanager.cpp | 55 +++++++++++++------ app/view/visibilitymanager.h | 7 +++ .../configuration/pages/BehaviorConfig.qml | 2 + 3 files changed, 47 insertions(+), 17 deletions(-) diff --git a/app/view/visibilitymanager.cpp b/app/view/visibilitymanager.cpp index 792be324e..f69b2ea01 100644 --- a/app/view/visibilitymanager.cpp +++ b/app/view/visibilitymanager.cpp @@ -58,15 +58,7 @@ VisibilityManager::VisibilityManager(PlasmaQuick::ContainmentView *view) m_wm = m_corona->wm(); connect(this, &VisibilityManager::slideOutFinished, this, &VisibilityManager::updateHiddenState); - connect(this, &VisibilityManager::slideInFinished, this, [&]() { - if (m_latteView && !m_latteView->screenEdgeMarginEnabled()) { - //! after slide-out the real floating windows should ignore their criteria - //! until containsMouse from view has been set to true and false to afterwards - updateHiddenState(); - } else { - m_timerHide.stop(); - } - }); + connect(this, &VisibilityManager::slideInFinished, this, &VisibilityManager::updateHiddenState); connect(this, &VisibilityManager::enableKWinEdgesChanged, this, &VisibilityManager::updateKWinEdgesSupport); connect(this, &VisibilityManager::modeChanged, this, &VisibilityManager::updateKWinEdgesSupport); @@ -74,6 +66,7 @@ VisibilityManager::VisibilityManager(PlasmaQuick::ContainmentView *view) if (m_latteView) { connect(m_latteView, &Latte::View::eventTriggered, this, &VisibilityManager::viewEventManager); connect(m_latteView, &Latte::View::byPassWMChanged, this, &VisibilityManager::updateKWinEdgesSupport); + connect(m_latteView, &Latte::View::screenEdgeMarginEnabledChanged, this, &VisibilityManager::updateHideTimer); connect(m_latteView, &Latte::View::absoluteGeometryChanged, this, [&]() { if (m_mode == Types::AlwaysVisible && m_latteView->screen()) { @@ -341,6 +334,11 @@ QRect VisibilityManager::acceptableStruts() return calcs; } +bool VisibilityManager::floatHideInterval() const +{ + return (m_latteView && m_latteView->screenEdgeMarginEnabled()); +} + bool VisibilityManager::raiseOnDesktop() const { return m_raiseOnDesktopChange; @@ -453,19 +451,39 @@ void VisibilityManager::setTimerShow(int msec) int VisibilityManager::timerHide() const { - return m_timerHide.interval(); + if (floatHideInterval()) { + return m_floatHideInterval; + } else { + return m_normalHideInterval; + } } void VisibilityManager::setTimerHide(int msec) { - int interval = qMax(HIDEMINIMUMINTERVAL, msec); + int newInterval = qMax(HIDEMINIMUMINTERVAL, msec); + int curInterval = !floatHideInterval() ? m_normalHideInterval : m_floatHideInterval; - if (m_timerHide.interval() == interval) { + if (curInterval == newInterval && m_timerHide.interval() == newInterval) { return; } - m_timerHide.setInterval(interval); - emit timerHideChanged(); + if (floatHideInterval()) { + m_floatHideInterval = newInterval; + } else { + m_normalHideInterval = newInterval; + } + + updateHideTimer(); +} + +void VisibilityManager::updateHideTimer() +{ + int curInterval = !floatHideInterval() ? m_normalHideInterval : m_floatHideInterval; + + if (m_timerHide.interval() != curInterval) { + m_timerHide.setInterval(curInterval); + emit timerHideChanged(); + } } bool VisibilityManager::supportsKWinEdges() const @@ -644,7 +662,8 @@ void VisibilityManager::saveConfig() config.writeEntry("enableKWinEdges", m_enableKWinEdgesFromUser); config.writeEntry("timerShow", m_timerShow.interval()); - config.writeEntry("timerHide", m_timerHide.interval()); + config.writeEntry("timerHide", m_normalHideInterval); + config.writeEntry("timerFloatHide", m_floatHideInterval); config.writeEntry("raiseOnDesktopChange", m_raiseOnDesktopChange); config.writeEntry("raiseOnActivityChange", m_raiseOnActivityChange); @@ -659,9 +678,11 @@ void VisibilityManager::restoreConfig() auto config = m_latteView->containment()->config(); m_timerShow.setInterval(config.readEntry("timerShow", 0)); - m_timerHide.setInterval(qMax(HIDEMINIMUMINTERVAL, config.readEntry("timerHide", 700))); emit timerShowChanged(); - emit timerHideChanged(); + + m_normalHideInterval = qMax(HIDEMINIMUMINTERVAL, config.readEntry("timerHide", 700)); + m_floatHideInterval = qMax(HIDEMINIMUMINTERVAL, config.readEntry("timerFloatHide", 2700)); + updateHideTimer(); m_enableKWinEdgesFromUser = config.readEntry("enableKWinEdges", true); emit enableKWinEdgesChanged(); diff --git a/app/view/visibilitymanager.h b/app/view/visibilitymanager.h index e80a2468e..41e0cad75 100644 --- a/app/view/visibilitymanager.h +++ b/app/view/visibilitymanager.h @@ -143,6 +143,8 @@ private slots: //! KWin Edges Support functions void updateKWinEdgesSupport(); + void updateHideTimer(); + private: void setContainsMouse(bool contains); @@ -157,6 +159,8 @@ private: void updateStrutsBasedOnLayoutsAndActivities(bool forceUpdate = false); void viewEventManager(QEvent *ev); + bool floatHideInterval() const; + QRect acceptableStruts(); private slots: @@ -184,6 +188,9 @@ private: bool m_raiseOnActivityChange{false}; bool m_hideNow{false}; + int m_normalHideInterval{700}; + int m_floatHideInterval{2700}; + QRect m_publishedStruts; //! KWin Edges diff --git a/shell/package/contents/configuration/pages/BehaviorConfig.qml b/shell/package/contents/configuration/pages/BehaviorConfig.qml index 72a4a9d63..4e05e347f 100644 --- a/shell/package/contents/configuration/pages/BehaviorConfig.qml +++ b/shell/package/contents/configuration/pages/BehaviorConfig.qml @@ -554,6 +554,8 @@ PlasmaComponents.Page { Layout.preferredWidth: width text: latteView.visibility.timerHide + maxValue: 6000 + onValueChanged: { latteView.visibility.timerHide = value }