From d9e18794c8199bbfd609b4daf13a92ae49999cdf Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Thu, 26 Dec 2019 21:10:11 +0200 Subject: [PATCH] simplify keepabove/below calling --start a bit to work with "Windows Always Cover" visibility mode --- app/lattecorona.cpp | 2 +- app/view/visibilitymanager.cpp | 9 ++++++++ app/wm/abstractwindowinterface.h | 1 - app/wm/waylandinterface.cpp | 20 +++++++++--------- app/wm/waylandinterface.h | 1 - app/wm/xwindowinterface.cpp | 22 +++++++++++--------- app/wm/xwindowinterface.h | 1 - containment/package/contents/config/main.xml | 3 ++- 8 files changed, 34 insertions(+), 25 deletions(-) diff --git a/app/lattecorona.cpp b/app/lattecorona.cpp index bc89c8185..b92c4ff5e 100644 --- a/app/lattecorona.cpp +++ b/app/lattecorona.cpp @@ -763,7 +763,7 @@ void Corona::aboutApplication() aboutDialog = new KAboutApplicationDialog(KAboutData::applicationData()); connect(aboutDialog.data(), &QDialog::finished, aboutDialog.data(), &QObject::deleteLater); m_wm->skipTaskBar(*aboutDialog); - m_wm->setKeepAbove(*aboutDialog, true); + m_wm->setKeepAbove(aboutDialog->winId(), true); aboutDialog->show(); } diff --git a/app/view/visibilitymanager.cpp b/app/view/visibilitymanager.cpp index 1d90e6f84..af96ecc5a 100644 --- a/app/view/visibilitymanager.cpp +++ b/app/view/visibilitymanager.cpp @@ -141,6 +141,12 @@ void VisibilityManager::setMode(Latte::Types::Visibility mode) m_timerHide.stop(); m_mode = mode; + if (m_mode == Types::WindowsCanCover || m_mode == Types::WindowsAlwaysCover) { + m_wm->setViewExtraFlags(m_latteView, false, mode); + } else { + m_wm->setViewExtraFlags(m_latteView, true, mode); + } + if (mode != Types::AlwaysVisible && mode != Types::WindowsGoBelow) { m_connections[0] = connect(m_wm, &WindowSystem::AbstractWindowInterface::currentDesktopChanged, this, [&] { if (m_raiseOnDesktopChange) { @@ -227,6 +233,9 @@ void VisibilityManager::setMode(Latte::Types::Visibility mode) case Types::WindowsGoBelow: break; + case Types::WindowsCanCover: + break; + case Types::WindowsAlwaysCover: break; diff --git a/app/wm/abstractwindowinterface.h b/app/wm/abstractwindowinterface.h index ed7765415..e690915df 100644 --- a/app/wm/abstractwindowinterface.h +++ b/app/wm/abstractwindowinterface.h @@ -92,7 +92,6 @@ public: virtual WindowInfoWrap requestInfo(WindowId wid) const = 0; virtual WindowInfoWrap requestInfoActive() const = 0; - virtual void setKeepAbove(const QDialog &dialog, bool above = true) const = 0; virtual void skipTaskBar(const QDialog &dialog) const = 0; virtual void slideWindow(QWindow &view, Slide location) const = 0; virtual void enableBlurBehind(QWindow &view) const = 0; diff --git a/app/wm/waylandinterface.cpp b/app/wm/waylandinterface.cpp index c5a486c9e..5f7714b4e 100644 --- a/app/wm/waylandinterface.cpp +++ b/app/wm/waylandinterface.cpp @@ -24,7 +24,8 @@ #include "view/screenedgeghostwindow.h" #include "view/view.h" #include "../lattecorona.h" -#include "../liblatte2/extras.h" +#include "../../liblatte2/extras.h" +#include "../../liblatte2/types.h" // Qt #include @@ -351,15 +352,6 @@ WindowId WaylandInterface::activeWindow() const return wid ? wid->internalId() : 0; } -void WaylandInterface::setKeepAbove(const QDialog &dialog, bool above) const -{ - if (above) { - KWindowSystem::setState(dialog.winId(), NET::KeepAbove); - } else { - KWindowSystem::clearState(dialog.winId(), NET::KeepAbove); - } -} - void WaylandInterface::skipTaskBar(const QDialog &dialog) const { KWindowSystem::setState(dialog.winId(), NET::SkipTaskbar); @@ -620,6 +612,10 @@ void WaylandInterface::setKeepAbove(WindowId wid, bool active) const auto w = windowFor(wid); if (w) { + if (active) { + setKeepBelow(wid, false); + } + if ((w->isKeepAbove() && active) || (!w->isKeepAbove() && !active)) { return; } @@ -633,6 +629,10 @@ void WaylandInterface::setKeepBelow(WindowId wid, bool active) const auto w = windowFor(wid); if (w) { + if (active) { + setKeepAbove(wid, false); + } + if ((w->isKeepBelow() && active) || (!w->isKeepBelow() && !active)) { return; } diff --git a/app/wm/waylandinterface.h b/app/wm/waylandinterface.h index 84d22af6f..146c9cb2a 100644 --- a/app/wm/waylandinterface.h +++ b/app/wm/waylandinterface.h @@ -70,7 +70,6 @@ public: WindowInfoWrap requestInfo(WindowId wid) const override; WindowInfoWrap requestInfoActive() const override; - void setKeepAbove(const QDialog &dialog, bool above = true) const override; void skipTaskBar(const QDialog &dialog) const override; void slideWindow(QWindow &view, Slide location) const override; void enableBlurBehind(QWindow &view) const override; diff --git a/app/wm/xwindowinterface.cpp b/app/wm/xwindowinterface.cpp index 97eb2103e..1652f0b35 100644 --- a/app/wm/xwindowinterface.cpp +++ b/app/wm/xwindowinterface.cpp @@ -24,7 +24,8 @@ #include "tasktools.h" #include "view/screenedgeghostwindow.h" #include "view/view.h" -#include "../liblatte2/extras.h" +#include "../../liblatte2/extras.h" +#include "../../liblatte2/types.h" // Qt #include @@ -105,10 +106,18 @@ void XWindowInterface::setViewExtraFlags(QObject *view,bool isPanelWindow, Latte if (isPanelWindow) { KWindowSystem::setType(winId, NET::Dock); + } else { + KWindowSystem::setType(winId, NET::Normal); } KWindowSystem::setState(winId, NET::SkipTaskbar | NET::SkipPager); KWindowSystem::setOnAllDesktops(winId, true); + + if (mode == Latte::Types::WindowsCanCover || mode == Latte::Types::WindowsAlwaysCover) { + setKeepBelow(winId, true); + } else { + setKeepAbove(winId, true); + } } void XWindowInterface::setViewStruts(QWindow &view, const QRect &rect @@ -217,15 +226,6 @@ WindowId XWindowInterface::activeWindow() const return KWindowSystem::self()->activeWindow(); } -void XWindowInterface::setKeepAbove(const QDialog &dialog, bool above) const -{ - if (above) { - KWindowSystem::setState(dialog.winId(), NET::KeepAbove); - } else { - KWindowSystem::clearState(dialog.winId(), NET::KeepAbove); - } -} - void XWindowInterface::skipTaskBar(const QDialog &dialog) const { KWindowSystem::setState(dialog.winId(), NET::SkipTaskbar); @@ -560,6 +560,7 @@ void XWindowInterface::setKeepAbove(WindowId wid, bool active) const if (active) { KWindowSystem::setState(wid.toUInt(), NET::KeepAbove); + KWindowSystem::clearState(wid.toUInt(), NET::KeepBelow); } else { KWindowSystem::clearState(wid.toUInt(), NET::KeepAbove); } @@ -573,6 +574,7 @@ void XWindowInterface::setKeepBelow(WindowId wid, bool active) const if (active) { KWindowSystem::setState(wid.toUInt(), NET::KeepBelow); + KWindowSystem::clearState(wid.toUInt(), NET::KeepAbove); } else { KWindowSystem::clearState(wid.toUInt(), NET::KeepBelow); } diff --git a/app/wm/xwindowinterface.h b/app/wm/xwindowinterface.h index 29d16c677..4771dbfec 100644 --- a/app/wm/xwindowinterface.h +++ b/app/wm/xwindowinterface.h @@ -54,7 +54,6 @@ public: WindowInfoWrap requestInfo(WindowId wid) const override; WindowInfoWrap requestInfoActive() const override; - void setKeepAbove(const QDialog &dialog, bool above = true) const override; void skipTaskBar(const QDialog &dialog) const override; void slideWindow(QWindow &view, Slide location) const override; void enableBlurBehind(QWindow &view) const override; diff --git a/containment/package/contents/config/main.xml b/containment/package/contents/config/main.xml index 5f4e9d055..e1abc83fc 100644 --- a/containment/package/contents/config/main.xml +++ b/containment/package/contents/config/main.xml @@ -36,7 +36,8 @@ - 0 + 5 +