From 4cf929ea81b753229b6fb4d016ed9d55d28bebd1 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Fri, 27 Dec 2019 13:38:22 +0200 Subject: [PATCH] support containsMouse behavior for WindowsCanCover --- app/view/visibilitymanager.cpp | 68 ++++++++++++++----- app/view/visibilitymanager.h | 10 +++ .../package/contents/ui/VisibilityManager.qml | 15 +++- .../configuration/pages/BehaviorConfig.qml | 1 - 4 files changed, 74 insertions(+), 20 deletions(-) diff --git a/app/view/visibilitymanager.cpp b/app/view/visibilitymanager.cpp index fbccca39d..44159fcaf 100644 --- a/app/view/visibilitymanager.cpp +++ b/app/view/visibilitymanager.cpp @@ -88,13 +88,13 @@ VisibilityManager::VisibilityManager(PlasmaQuick::ContainmentView *view) m_timerHide.setSingleShot(true); connect(&m_timerShow, &QTimer::timeout, this, [&]() { - if (m_isHidden) { + if (m_isHidden || m_isBelowLayer) { // qDebug() << "must be shown"; emit mustBeShown(); } }); connect(&m_timerHide, &QTimer::timeout, this, [&]() { - if (!m_blockHiding && !m_isHidden && !m_dragEnter) { + if (!m_blockHiding && !m_isHidden && !m_isBelowLayer && !m_dragEnter) { // qDebug() << "must be hide"; emit mustBeHide(); } @@ -120,21 +120,25 @@ Types::Visibility VisibilityManager::mode() const void VisibilityManager::initViewFlags() { - if (KWindowSystem::isPlatformX11()) { - if ((m_mode == Types::WindowsCanCover || m_mode == Types::WindowsAlwaysCover) && (!m_latteView->inEditMode())) { - m_wm->setViewExtraFlags(m_latteView, false, m_mode); - } else { - m_wm->setViewExtraFlags(m_latteView, true); - } + if ((m_mode == Types::WindowsCanCover || m_mode == Types::WindowsAlwaysCover) && (!m_latteView->inEditMode())) { + setViewOnBackLayer(); } else { - if ((m_mode == Types::WindowsCanCover || m_mode == Types::WindowsAlwaysCover) && (!m_latteView->inEditMode())) { - m_wm->setViewExtraFlags(m_latteView, false, m_mode); - } else { - m_wm->setViewExtraFlags(m_latteView, true); - } + setViewOnFrontLayer(); } } +void VisibilityManager::setViewOnBackLayer() +{ + m_wm->setViewExtraFlags(m_latteView, false, Types::WindowsAlwaysCover); + setIsBelowLayer(true); +} + +void VisibilityManager::setViewOnFrontLayer() +{ + m_wm->setViewExtraFlags(m_latteView, true); + setIsBelowLayer(false); +} + void VisibilityManager::setMode(Latte::Types::Visibility mode) { if (m_mode == mode) @@ -249,6 +253,11 @@ void VisibilityManager::setMode(Latte::Types::Visibility mode) break; case Types::WindowsCanCover: + m_connections[base] = connect(this, &VisibilityManager::containsMouseChanged, this, [&]() { + raiseView(m_containsMouse); + }); + + raiseView(m_containsMouse); break; case Types::WindowsAlwaysCover: @@ -350,6 +359,26 @@ void VisibilityManager::setRaiseOnActivity(bool enable) emit raiseOnActivityChanged(); } +bool VisibilityManager::isBelowLayer() const +{ + return m_isBelowLayer; +} + +void VisibilityManager::setIsBelowLayer(bool below) +{ + if (m_isBelowLayer == below) { + return; + } + + m_isBelowLayer = below; + + if (m_mode == Latte::Types::WindowsCanCover) { + updateGhostWindowState(); + } + + emit isBelowLayerChanged(); +} + bool VisibilityManager::isHidden() const { return m_isHidden; @@ -445,7 +474,11 @@ void VisibilityManager::updateGhostWindowState() && m_latteView->layout()->isCurrent())); if (inCurrentLayout) { - m_wm->setEdgeStateFor(m_edgeGhostWindow, m_isHidden); + if (m_mode == Latte::Types::WindowsCanCover) { + m_wm->setEdgeStateFor(m_edgeGhostWindow, m_isBelowLayer); + } else { + m_wm->setEdgeStateFor(m_edgeGhostWindow, m_isHidden); + } } else { m_wm->setEdgeStateFor(m_edgeGhostWindow, false); } @@ -516,6 +549,7 @@ void VisibilityManager::updateHiddenState() switch (m_mode) { case Types::AutoHide: + case Types::WindowsCanCover: raiseView(m_containsMouse); break; @@ -724,15 +758,15 @@ void VisibilityManager::updateKWinEdgesSupport() if ((m_mode == Types::AutoHide || m_mode == Types::DodgeActive || m_mode == Types::DodgeAllWindows - || m_mode == Types::DodgeMaximized) + || m_mode == Types::DodgeMaximized + || m_mode == Types::WindowsCanCover) && (!m_latteView->byPassWM()) ) { if (m_enableKWinEdgesFromUser) { createEdgeGhostWindow(); } else if (!m_enableKWinEdgesFromUser) { deleteEdgeGhostWindow(); } - } else if (m_mode == Types::AlwaysVisible - || m_mode == Types::WindowsGoBelow) { + } else { deleteEdgeGhostWindow(); } } diff --git a/app/view/visibilitymanager.h b/app/view/visibilitymanager.h index 6e6680ea9..e80a2468e 100644 --- a/app/view/visibilitymanager.h +++ b/app/view/visibilitymanager.h @@ -56,6 +56,7 @@ class VisibilityManager : public QObject Q_PROPERTY(bool raiseOnDesktop READ raiseOnDesktop WRITE setRaiseOnDesktop NOTIFY raiseOnDesktopChanged) Q_PROPERTY(bool raiseOnActivity READ raiseOnActivity WRITE setRaiseOnActivity NOTIFY raiseOnActivityChanged) Q_PROPERTY(bool isHidden READ isHidden WRITE setIsHidden NOTIFY isHiddenChanged) + Q_PROPERTY(bool isBelowLayer READ isBelowLayer NOTIFY isBelowLayerChanged) Q_PROPERTY(bool blockHiding READ blockHiding WRITE setBlockHiding NOTIFY blockHidingChanged) Q_PROPERTY(bool containsMouse READ containsMouse NOTIFY containsMouseChanged) @@ -81,6 +82,8 @@ public: bool raiseOnActivity() const; void setRaiseOnActivity(bool enable); + bool isBelowLayer() const; + bool isHidden() const; void setIsHidden(bool isHidden); @@ -105,6 +108,9 @@ public slots: Q_INVOKABLE void hide(); Q_INVOKABLE void show(); + Q_INVOKABLE void setViewOnBackLayer(); + Q_INVOKABLE void setViewOnFrontLayer(); + void initViewFlags(); signals: @@ -117,6 +123,7 @@ signals: void modeChanged(); void raiseOnDesktopChanged(); void raiseOnActivityChanged(); + void isBelowLayerChanged(); void isHiddenChanged(); void blockHidingChanged(); void containsMouseChanged(); @@ -131,6 +138,8 @@ private slots: void saveConfig(); void restoreConfig(); + void setIsBelowLayer(bool below); + //! KWin Edges Support functions void updateKWinEdgesSupport(); @@ -165,6 +174,7 @@ private: QTimer m_timerHide; QTimer m_timerStartUp; + bool m_isBelowLayer{false}; bool m_isHidden{false}; bool m_dragEnter{false}; bool m_blockHiding{false}; diff --git a/containment/package/contents/ui/VisibilityManager.qml b/containment/package/contents/ui/VisibilityManager.qml index 7f249dc33..3e9d65d91 100644 --- a/containment/package/contents/ui/VisibilityManager.qml +++ b/containment/package/contents/ui/VisibilityManager.qml @@ -340,19 +340,30 @@ Item{ } function slotMustBeShown() { - // console.log("show..."); + //! WindowsCanCover case + if (latteView && latteView.visibility.mode === Latte.Types.WindowsCanCover) { + latteView.visibility.setViewOnFrontLayer(); + return; + } + + //! Normal Dodge/AutoHide case if (!slidingAnimationAutoHiddenIn.running && !inTempHiding && !inForceHiding){ slidingAnimationAutoHiddenIn.init(); } } function slotMustBeHide() { + if (latteView && latteView.visibility.mode === Latte.Types.WindowsCanCover) { + latteView.visibility.setViewOnBackLayer(); + return; + } + //! prevent sliding-in on startup if the dodge modes have sent a hide signal if (inStartupTimer.running && root.inStartup) { root.inStartup = false; } - // console.log("hide...."); + //! Normal Dodge/AutoHide case if((!slidingAnimationAutoHiddenOut.running && !latteView.visibility.blockHiding && !latteView.visibility.containsMouse) || inForceHiding) { slidingAnimationAutoHiddenOut.init(); diff --git a/shell/package/contents/configuration/pages/BehaviorConfig.qml b/shell/package/contents/configuration/pages/BehaviorConfig.qml index 25784e966..4d0c9bf73 100644 --- a/shell/package/contents/configuration/pages/BehaviorConfig.qml +++ b/shell/package/contents/configuration/pages/BehaviorConfig.qml @@ -482,7 +482,6 @@ PlasmaComponents.Page { enabled: !(latteView.visibility.mode === Latte.Types.AlwaysVisible || latteView.visibility.mode === Latte.Types.WindowsGoBelow - || latteView.visibility.mode === Latte.Types.WindowsCanCover || latteView.visibility.mode === Latte.Types.WindowsAlwaysCover) LatteComponents.Header {