From a903fb2c64a96a28dccd590648ed8649aac5526b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 25 Jul 2014 11:20:34 +0200 Subject: [PATCH] Implement borderingScreenEdges for the DecoratedClientImpl Uses the QuickTileMode of the Client to indicate which borders to remove. This could be extended to be in general when a window borders the screen edge and not just for quick tile mode. --- decorations/decoratedclient.cpp | 32 ++++++++++++++++++++++++++++++++ decorations/decoratedclient.h | 2 ++ 2 files changed, 34 insertions(+) diff --git a/decorations/decoratedclient.cpp b/decorations/decoratedclient.cpp index 14ae4f91a7..e155925ba7 100644 --- a/decorations/decoratedclient.cpp +++ b/decorations/decoratedclient.cpp @@ -86,6 +86,11 @@ DecoratedClientImpl::DecoratedClientImpl(Client *client, KDecoration2::Decorated decoration->update(); } ); + connect(client, &Client::quickTileModeChanged, decoratedClient, + [this, decoratedClient]() { + emit decoratedClient->borderingScreenEdgesChanged(borderingScreenEdges()); + } + ); } DecoratedClientImpl::~DecoratedClientImpl() = default; @@ -188,6 +193,33 @@ bool DecoratedClientImpl::isMaximizedHorizontally() const return m_client->maximizeMode() & KDecorationDefines::MaximizeHorizontal; } +Qt::Edges DecoratedClientImpl::borderingScreenEdges() const +{ + Qt::Edges edges; + const KDecorationDefines::QuickTileMode mode = m_client->quickTileMode(); + if (mode.testFlag(KDecorationDefines::QuickTileLeft)) { + edges |= Qt::LeftEdge; + if (!mode.testFlag(KDecorationDefines::QuickTileTop) && !mode.testFlag(KDecorationDefines::QuickTileBottom)) { + // using complete side + edges |= Qt::TopEdge | Qt::BottomEdge; + } + } + if (mode.testFlag(KDecorationDefines::QuickTileTop)) { + edges |= Qt::TopEdge; + } + if (mode.testFlag(KDecorationDefines::QuickTileRight)) { + edges |= Qt::RightEdge; + if (!mode.testFlag(KDecorationDefines::QuickTileTop) && !mode.testFlag(KDecorationDefines::QuickTileBottom)) { + // using complete side + edges |= Qt::TopEdge | Qt::BottomEdge; + } + } + if (mode.testFlag(KDecorationDefines::QuickTileBottom)) { + edges |= Qt::BottomEdge; + } + return edges; +} + void DecoratedClientImpl::createRenderer() { if (Compositor::self()->hasScene()) { diff --git a/decorations/decoratedclient.h b/decorations/decoratedclient.h index 100b9c3290..65951a0e16 100644 --- a/decorations/decoratedclient.h +++ b/decorations/decoratedclient.h @@ -65,6 +65,8 @@ public: int width() const override; WId windowId() const override; + Qt::Edges borderingScreenEdges() const override; + void requestClose() override; void requestContextHelp() override; void requestMaximize(Qt::MouseButtons buttons) override;