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.
This commit is contained in:
Martin Gräßlin 2014-07-25 11:20:34 +02:00
parent d3a91b67d9
commit a903fb2c64
2 changed files with 34 additions and 0 deletions

View file

@ -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()) {

View file

@ -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;