diff --git a/abstract_client.h b/abstract_client.h --- a/abstract_client.h +++ b/abstract_client.h @@ -1176,6 +1176,7 @@ void setDecoration(KDecoration2::Decoration *decoration) { m_decoration.decoration = decoration; } + virtual void createDecoration(const QRect &oldGeometry); virtual void destroyDecoration(); void startDecorationDoubleClickTimer(); void invalidateDecorationDoubleClickTimer(); diff --git a/abstract_client.cpp b/abstract_client.cpp --- a/abstract_client.cpp +++ b/abstract_client.cpp @@ -2137,6 +2137,27 @@ updateCursor(); } +void AbstractClient::createDecoration(const QRect &oldGeometry) +{ + KDecoration2::Decoration *decoration = Decoration::DecorationBridge::self()->createDecoration(this); + if (decoration) { + QMetaObject::invokeMethod(decoration, "update", Qt::QueuedConnection); + connect(decoration, &KDecoration2::Decoration::shadowChanged, this, &Toplevel::updateShadow); + connect(decoration, &KDecoration2::Decoration::bordersChanged, this, [this]() { + GeometryUpdatesBlocker blocker(this); + const QRect oldGeometry = frameGeometry(); + if (!isShade()) { + checkWorkspacePosition(oldGeometry); + } + emit geometryShapeChanged(this, oldGeometry); + }); + } + setDecoration(decoration); + setFrameGeometry(QRect(oldGeometry.topLeft(), clientSizeToFrameSize(clientSize()))); + + emit geometryShapeChanged(this, oldGeometry); +} + void AbstractClient::destroyDecoration() { delete m_decoration.decoration; diff --git a/internal_client.h b/internal_client.h --- a/internal_client.h +++ b/internal_client.h @@ -90,13 +90,11 @@ protected: bool acceptsFocus() const override; bool belongsToSameApplication(const AbstractClient *other, SameApplicationChecks checks) const override; - void destroyDecoration() override; void doMove(int x, int y) override; void doResizeSync() override; void updateCaption() override; private: - void createDecoration(const QRect &rect); void requestGeometry(const QRect &rect); void commitGeometry(const QRect &rect); void setCaption(const QString &caption); diff --git a/internal_client.cpp b/internal_client.cpp --- a/internal_client.cpp +++ b/internal_client.cpp @@ -496,17 +496,6 @@ return qobject_cast(other) != nullptr; } -void InternalClient::destroyDecoration() -{ - if (!isDecorated()) { - return; - } - - const QRect clientGeometry = frameRectToClientRect(frameGeometry()); - AbstractClient::destroyDecoration(); - setFrameGeometry(clientGeometry); -} - void InternalClient::doMove(int x, int y) { Q_UNUSED(x) @@ -537,32 +526,6 @@ } } -void InternalClient::createDecoration(const QRect &rect) -{ - KDecoration2::Decoration *decoration = Decoration::DecorationBridge::self()->createDecoration(this); - if (decoration) { - QMetaObject::invokeMethod(decoration, "update", Qt::QueuedConnection); - connect(decoration, &KDecoration2::Decoration::shadowChanged, this, &Toplevel::updateShadow); - connect(decoration, &KDecoration2::Decoration::bordersChanged, this, - [this]() { - GeometryUpdatesBlocker blocker(this); - const QRect oldGeometry = frameGeometry(); - if (!isShade()) { - checkWorkspacePosition(oldGeometry); - } - emit geometryShapeChanged(this, oldGeometry); - } - ); - } - - const QRect oldFrameGeometry = frameGeometry(); - - setDecoration(decoration); - setFrameGeometry(clientRectToFrameRect(rect)); - - emit geometryShapeChanged(this, oldFrameGeometry); -} - void InternalClient::requestGeometry(const QRect &rect) { if (m_internalWindow) { diff --git a/x11client.h b/x11client.h --- a/x11client.h +++ b/x11client.h @@ -433,7 +433,7 @@ void grabButton(int mod); void ungrabButton(int mod); void resizeDecoration(); - void createDecoration(const QRect &oldgeom); + void createDecoration(const QRect &oldgeom) override; void pingWindow(); void killProcess(bool ask, xcb_timestamp_t timestamp = XCB_TIME_CURRENT_TIME); diff --git a/xdgshellclient.h b/xdgshellclient.h --- a/xdgshellclient.h +++ b/xdgshellclient.h @@ -170,7 +170,6 @@ * At this point all initial properties should have been set by the client. */ void finishInit(); - void createDecoration(const QRect &oldgeom); void createWindowId(); void updateIcon(); bool shouldExposeToWindowManagement(); diff --git a/xdgshellclient.cpp b/xdgshellclient.cpp --- a/xdgshellclient.cpp +++ b/xdgshellclient.cpp @@ -460,31 +460,6 @@ updateShowOnScreenEdge(); } -void XdgShellClient::createDecoration(const QRect &oldGeom) -{ - KDecoration2::Decoration *decoration = Decoration::DecorationBridge::self()->createDecoration(this); - if (decoration) { - QMetaObject::invokeMethod(decoration, "update", Qt::QueuedConnection); - connect(decoration, &KDecoration2::Decoration::shadowChanged, this, &Toplevel::updateShadow); - connect(decoration, &KDecoration2::Decoration::bordersChanged, this, - [this]() { - GeometryUpdatesBlocker blocker(this); - RequestGeometryBlocker requestBlocker(this); - const QRect oldGeometry = frameGeometry(); - if (!isShade()) { - checkWorkspacePosition(oldGeometry); - } - emit geometryShapeChanged(this, oldGeometry); - } - ); - } - setDecoration(decoration); - // TODO: ensure the new geometry still fits into the client area (e.g. maximized windows) - doSetGeometry(QRect(oldGeom.topLeft(), m_windowGeometry.size() + QSize(borderLeft() + borderRight(), borderBottom() + borderTop()))); - - emit geometryShapeChanged(this, oldGeom); -} - void XdgShellClient::updateDecoration(bool check_workspace_pos, bool force) { if (!force &&