diff --git a/app/abstractwindowinterface.h b/app/abstractwindowinterface.h index 76f65b61e..2877de4b7 100644 --- a/app/abstractwindowinterface.h +++ b/app/abstractwindowinterface.h @@ -9,8 +9,11 @@ #include #include +#include #include +#include + namespace Latte { class AbstractWindowInterface : public QObject { @@ -27,6 +30,9 @@ public: virtual WindowInfoWrap requestInfoActive() = 0; virtual const std::list &windows() = 0; + virtual void setDockStruts(const QRect &dockRect, Plasma::Types::Location location) = 0; + virtual void removeDockStruts() = 0; + signals: void activeWindowChanged(WId wid); void windowChanged(const WindowInfoWrap &winfo); diff --git a/app/xwindowinterface.cpp b/app/xwindowinterface.cpp index 37d712e9c..411c567b4 100644 --- a/app/xwindowinterface.cpp +++ b/app/xwindowinterface.cpp @@ -1,5 +1,7 @@ #include "xwindowinterface.h" +#include "../liblattedock/extras.h" +#include #include #include @@ -64,6 +66,54 @@ const std::list &XWindowInterface::windows() return m_windows; } +void XWindowInterface::setDockStruts(const QRect &dockRect, Plasma::Types::Location location) +{ + NETExtendedStrut strut; + + switch (location) { + case Plasma::Types::TopEdge: + strut.top_width = dockRect.height(); + strut.top_start = dockRect.x(); + strut.top_end = dockRect.x() + dockRect.width() - 1; + break; + + case Plasma::Types::BottomEdge: + strut.bottom_width = dockRect.height(); + strut.bottom_start = dockRect.x(); + strut.bottom_end = dockRect.x() + dockRect.width() - 1; + break; + + case Plasma::Types::LeftEdge: + strut.left_width = dockRect.width(); + strut.left_start = dockRect.y(); + strut.left_end = dockRect.y() + dockRect.height() - 1; + break; + + case Plasma::Types::RightEdge: + strut.right_width = dockRect.width(); + strut.right_start = dockRect.y(); + strut.right_end = dockRect.y() + dockRect.height() - 1; + break; + + default: + qWarning() << "wrong location:" << qEnumToStr(location); + return; + } + + + KWindowSystem::setExtendedStrut(m_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, + strut.bottom_width, strut.bottom_start, strut.bottom_end + ); +} + +void XWindowInterface::removeDockStruts() +{ + KWindowSystem::setStrut(m_view->winId(), 0, 0, 0, 0); +} + WindowInfoWrap XWindowInterface::requestInfoActive() { return requestInfo(KWindowSystem::activeWindow()); diff --git a/app/xwindowinterface.h b/app/xwindowinterface.h index 4fd3f51d9..b73f741b3 100644 --- a/app/xwindowinterface.h +++ b/app/xwindowinterface.h @@ -1,11 +1,12 @@ #ifndef XWINDOWINTERFACE_H #define XWINDOWINTERFACE_H +#include "abstractwindowinterface.h" + #include #include - -#include "abstractwindowinterface.h" +#include namespace Latte { @@ -14,7 +15,7 @@ class XWindowInterface : public AbstractWindowInterface { public: XWindowInterface(QQuickWindow *const view, QObject *parent); - virtual ~XWindowInterface(); + ~XWindowInterface() override; void setDockDefaultFlags() override; @@ -23,6 +24,9 @@ public: WindowInfoWrap requestInfoActive() override; const std::list &windows() override; + void setDockStruts(const QRect &dockRect, Plasma::Types::Location location) override; + void removeDockStruts() override; + private: bool isValidWindow(const KWindowInfo &winfo); void windowChangedProxy(WId wid, NET::Properties prop1, NET::Properties2 prop2);