From bdefcf11d24e898fb3015a50050916ce637f7196 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sun, 19 Dec 2021 14:45:31 +0200 Subject: [PATCH] try to enable layershell exclusivezone --- app/view/visibilitymanager.cpp | 8 +- app/wm/abstractwindowinterface.h | 5 +- app/wm/waylandinterface.cpp | 126 ++++++------------------------- app/wm/waylandinterface.h | 16 +--- app/wm/xwindowinterface.cpp | 19 +++-- app/wm/xwindowinterface.h | 4 +- 6 files changed, 47 insertions(+), 131 deletions(-) diff --git a/app/view/visibilitymanager.cpp b/app/view/visibilitymanager.cpp index 5095e022a..25569a4da 100644 --- a/app/view/visibilitymanager.cpp +++ b/app/view/visibilitymanager.cpp @@ -157,7 +157,7 @@ VisibilityManager::VisibilityManager(PlasmaQuick::ContainmentView *view) VisibilityManager::~VisibilityManager() { qDebug() << "VisibilityManager deleting..."; - m_wm->removeViewStruts(*m_latteView); + m_wm->removeViewStruts(m_latteView); if (m_edgeGhostWindow) { m_edgeGhostWindow->deleteLater(); @@ -234,7 +234,7 @@ void VisibilityManager::setMode(Latte::Types::Visibility mode) if (m_mode == Types::AlwaysVisible) { //! remove struts for old always visible mode - m_wm->removeViewStruts(*m_latteView); + m_wm->removeViewStruts(m_latteView); } m_timerShow.stop(); @@ -419,11 +419,11 @@ void VisibilityManager::updateStrutsBasedOnLayoutsAndActivities(bool forceUpdate //! though they should not. In such case setting struts when the windows are hidden //! the struts do not take any effect m_publishedStruts = computedStruts; - m_wm->setViewStruts(*m_latteView, m_publishedStruts, m_latteView->location()); + m_wm->setViewStruts(m_latteView, m_publishedStruts, m_latteView->location()); } } else { m_publishedStruts = QRect(); - m_wm->removeViewStruts(*m_latteView); + m_wm->removeViewStruts(m_latteView); } } diff --git a/app/wm/abstractwindowinterface.h b/app/wm/abstractwindowinterface.h index b7f89acd4..11cab2828 100644 --- a/app/wm/abstractwindowinterface.h +++ b/app/wm/abstractwindowinterface.h @@ -69,11 +69,10 @@ public: virtual ~AbstractWindowInterface(); virtual void setViewExtraFlags(QObject *view,bool isPanelWindow = true, Latte::Types::Visibility mode = Latte::Types::WindowsGoBelow) = 0; - virtual void setViewStruts(QWindow &view, const QRect &rect - , Plasma::Types::Location location) = 0; + virtual void setViewStruts(QWindow *view, const QRect &rect, Plasma::Types::Location location) = 0; virtual void setWindowOnActivities(const WindowId &wid, const QStringList &activities) = 0; - virtual void removeViewStruts(QWindow &view) = 0; + virtual void removeViewStruts(QWindow *view) = 0; virtual WindowId activeWindow() = 0; virtual WindowInfoWrap requestInfo(WindowId wid) = 0; diff --git a/app/wm/waylandinterface.cpp b/app/wm/waylandinterface.cpp index eca42ba56..3b7770bba 100644 --- a/app/wm/waylandinterface.cpp +++ b/app/wm/waylandinterface.cpp @@ -40,83 +40,6 @@ using namespace KWayland::Client; namespace Latte { -class Private::GhostWindow : public QQuickView -{ - Q_OBJECT - -public: - WindowSystem::WindowId m_winId; - - GhostWindow(WindowSystem::WaylandInterface *waylandInterface) - : m_waylandInterface(waylandInterface) { - setFlags(Qt::FramelessWindowHint - | Qt::WindowStaysOnTopHint - | Qt::NoDropShadowWindowHint - | Qt::WindowDoesNotAcceptFocus); - - setColor(QColor(Qt::transparent)); - setClearBeforeRendering(true); - - connect(m_waylandInterface, &WindowSystem::AbstractWindowInterface::latteWindowAdded, this, &GhostWindow::identifyWinId); - - setupWaylandIntegration(); - show(); - } - - ~GhostWindow() { - m_waylandInterface->unregisterIgnoredWindow(m_winId); - // delete m_shellSurface; - } - - void setGeometry(const QRect &rect) { - if (geometry() == rect) { - return; - } - - m_validGeometry = rect; - - setMinimumSize(rect.size()); - setMaximumSize(rect.size()); - resize(rect.size()); - - // m_shellSurface->setPosition(rect.topLeft()); - } - - void setupWaylandIntegration() { - /* using namespace KWayland::Client; - - if (m_shellSurface) - return; - - Surface *s{Surface::fromWindow(this)}; - - if (!s) - return; - - m_shellSurface = m_waylandInterface->waylandCoronaInterface()->createSurface(s, this); - qDebug() << "wayland ghost window surface was created..."; - - m_shellSurface->setSkipTaskbar(true); - m_shellSurface->setPanelTakesFocus(false); - m_shellSurface->setRole(PlasmaShellSurface::Role::Panel); - m_shellSurface->setPanelBehavior(PlasmaShellSurface::PanelBehavior::AlwaysVisible);*/ - } - - // KWayland::Client::PlasmaShellSurface *m_shellSurface{nullptr}; - WindowSystem::WaylandInterface *m_waylandInterface{nullptr}; - - //! geometry() function under wayland does not return nice results - QRect m_validGeometry; - -public slots: - void identifyWinId() { - if (m_winId.isNull()) { - m_winId = m_waylandInterface->winIdFor("latte-dock", m_validGeometry); - m_waylandInterface->registerIgnoredWindow(m_winId); - } - } -}; - namespace WindowSystem { WaylandInterface::WaylandInterface(QObject *parent) @@ -293,28 +216,20 @@ void WaylandInterface::setViewExtraFlags(QObject *view, bool isPanelWindow, Latt }*/ } -void WaylandInterface::setViewStruts(QWindow &view, const QRect &rect, Plasma::Types::Location location) +void WaylandInterface::setViewStruts(QWindow *view, const QRect &rect, Plasma::Types::Location location) { - /* if (!m_ghostWindows.contains(view.winId())) { - m_ghostWindows[view.winId()] = new Private::GhostWindow(this); + if (!view) { + return; } - auto w = m_ghostWindows[view.winId()]; - - switch (location) { - case Plasma::Types::TopEdge: - case Plasma::Types::BottomEdge: - w->setGeometry({rect.x() + rect.width() / 2, rect.y(), 1, rect.height()}); - break; - - case Plasma::Types::LeftEdge: - case Plasma::Types::RightEdge: - w->setGeometry({rect.x(), rect.y() + rect.height() / 2, rect.width(), 1}); - break; + auto layerWindow = LayerShellQt::Window::get(view); - default: - break; - }*/ + if (location == Plasma::Types::LeftEdge + || location == Plasma::Types::RightEdge) { + layerWindow->setExclusiveZone(rect.width()); + } else { + layerWindow->setExclusiveZone(rect.height()); + } } void WaylandInterface::switchToNextVirtualDesktop() @@ -415,9 +330,15 @@ void WaylandInterface::setWindowOnActivities(const WindowId &wid, const QStringL #endif } -void WaylandInterface::removeViewStruts(QWindow &view) +void WaylandInterface::removeViewStruts(QWindow *view) { - delete m_ghostWindows.take(view.winId()); + if (!view) { + return; + } + + auto layerWindow = LayerShellQt::Window::get(view); + + layerWindow->setExclusiveZone(0); } WindowId WaylandInterface::activeWindow() @@ -471,11 +392,11 @@ void WaylandInterface::enableBlurBehind(QWindow &view) void WaylandInterface::setActiveEdge(QWindow *view, bool active) { - ViewPart::ScreenEdgeGhostWindow *window = qobject_cast(view); + //ViewPart::ScreenEdgeGhostWindow *window = qobject_cast(view); - if (!window) { - return; - } + //if (!window) { + // return; + //} /*if (window->parentView()->surface() && window->parentView()->visibility() && (window->parentView()->visibility()->mode() == Types::DodgeActive @@ -508,7 +429,8 @@ void WaylandInterface::setWindowPosition(QWindow *window, const Plasma::Types::L margins.setTop(geometry.top() - window->screen()->geometry().top()); margins.setLeft(geometry.left() - window->screen()->geometry().left()); - /*if (location == Plasma::Types::TopEdge || location == Plasma::Types::LeftEdge) { + /* + if (location == Plasma::Types::TopEdge || location == Plasma::Types::LeftEdge) { anchors = LayerShellQt::Window::AnchorTop; anchors = anchors | LayerShellQt::Window::AnchorLeft; margins.setTop(geometry.top() - window->screen()->geometry().top()); diff --git a/app/wm/waylandinterface.h b/app/wm/waylandinterface.h index c17f1ad10..8f4689350 100644 --- a/app/wm/waylandinterface.h +++ b/app/wm/waylandinterface.h @@ -25,14 +25,6 @@ #include #endif -namespace Latte { -class Corona; -namespace Private { -//! this class is used to create the struts inside wayland -class GhostWindow; -} -} - namespace Latte { namespace WindowSystem { @@ -45,11 +37,10 @@ public: ~WaylandInterface() override; void setViewExtraFlags(QObject *view, bool isPanelWindow = true, Latte::Types::Visibility mode = Latte::Types::WindowsGoBelow) override; - void setViewStruts(QWindow &view, const QRect &rect - , Plasma::Types::Location location) override; + void setViewStruts(QWindow *view, const QRect &rect, Plasma::Types::Location location) override; void setWindowOnActivities(const WindowId &wid, const QStringList &nextactivities) override; - void removeViewStruts(QWindow &view) override; + void removeViewStruts(QWindow *view) override; WindowId activeWindow() override; WindowInfoWrap requestInfo(WindowId wid) override; @@ -121,9 +112,6 @@ private: #endif private: - friend class Private::GhostWindow; - mutable QMap m_ghostWindows; - KWayland::Client::PlasmaWindowManagement *m_windowManagement{nullptr}; #if KF5_VERSION_MINOR >= 52 diff --git a/app/wm/xwindowinterface.cpp b/app/wm/xwindowinterface.cpp index 397397f6b..bcea3c5cb 100644 --- a/app/wm/xwindowinterface.cpp +++ b/app/wm/xwindowinterface.cpp @@ -112,12 +112,15 @@ void XWindowInterface::setViewExtraFlags(QObject *view,bool isPanelWindow, Latte } } -void XWindowInterface::setViewStruts(QWindow &view, const QRect &rect - , Plasma::Types::Location location) +void XWindowInterface::setViewStruts(QWindow *view, const QRect &rect, Plasma::Types::Location location) { + if (!view) { + return; + } + NETExtendedStrut strut; - const auto screen = view.screen(); + const auto screen = view->screen(); const QRect currentScreen {screen->geometry()}; const QRect wholeScreen {{0, 0}, screen->virtualSize()}; @@ -160,7 +163,7 @@ void XWindowInterface::setViewStruts(QWindow &view, const QRect &rect return; } - KWindowSystem::setExtendedStrut(view.winId(), + KWindowSystem::setExtendedStrut(view->winId(), strut.left_width, strut.left_start, strut.left_end, strut.right_width, strut.right_start, strut.right_end, strut.top_width, strut.top_start, strut.top_end, @@ -216,9 +219,13 @@ void XWindowInterface::setWindowOnActivities(const WindowId &wid, const QStringL KWindowSystem::setOnActivities(wid.toUInt(), activities); } -void XWindowInterface::removeViewStruts(QWindow &view) +void XWindowInterface::removeViewStruts(QWindow *view) { - KWindowSystem::setStrut(view.winId(), 0, 0, 0, 0); + if (!view) { + return; + } + + KWindowSystem::setStrut(view->winId(), 0, 0, 0, 0); } WindowId XWindowInterface::activeWindow() diff --git a/app/wm/xwindowinterface.h b/app/wm/xwindowinterface.h index 2f4759698..171e23fb8 100644 --- a/app/wm/xwindowinterface.h +++ b/app/wm/xwindowinterface.h @@ -32,10 +32,10 @@ public: ~XWindowInterface() override; void setViewExtraFlags(QObject *view, bool isPanelWindow = true, Latte::Types::Visibility mode = Latte::Types::WindowsGoBelow) override; - void setViewStruts(QWindow &view, const QRect &rect, Plasma::Types::Location location) override; + void setViewStruts(QWindow *view, const QRect &rect, Plasma::Types::Location location) override; void setWindowOnActivities(const WindowId &wid, const QStringList &activities) override; - void removeViewStruts(QWindow &view) override; + void removeViewStruts(QWindow *view) override; WindowId activeWindow() override; WindowInfoWrap requestInfo(WindowId wid) override;