From be32a1b1f5fa99a7d6855a6922bc752b8174cc47 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Thu, 9 Dec 2021 13:55:13 +0200 Subject: [PATCH] Move createDecoration() and destroyDecoration() from AbstractClient to InternalClient They are used only by InternalClient. AbstractClient doesn't need to handle the destruction of DecorationBridge because its lifetime matches kwin's lifetime. --- src/abstract_client.cpp | 17 ----------------- src/abstract_client.h | 2 -- src/internal_client.cpp | 15 +++++++++++++++ src/internal_client.h | 2 ++ src/x11client.h | 4 ++-- src/xdgshellclient.cpp | 2 +- 6 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/abstract_client.cpp b/src/abstract_client.cpp index ac87702b43..e73e992600 100644 --- a/src/abstract_client.cpp +++ b/src/abstract_client.cpp @@ -72,8 +72,6 @@ AbstractClient::AbstractClient() connect(this, &AbstractClient::paletteChanged, this, &AbstractClient::triggerDecorationRepaint); - connect(Decoration::DecorationBridge::self(), &QObject::destroyed, this, &AbstractClient::destroyDecoration); - // If the user manually moved the window, don't restore it after the keyboard closes connect(this, &AbstractClient::clientFinishUserMovedResized, this, [this] () { m_keyboardGeometryRestore = QRect(); @@ -2308,21 +2306,6 @@ void AbstractClient::endInteractiveMoveResize() updateCursor(); } -void AbstractClient::createDecoration(const QRect &oldGeometry) -{ - setDecoration(QSharedPointer(Decoration::DecorationBridge::self()->createDecoration(this))); - moveResize(oldGeometry); - - Q_EMIT geometryShapeChanged(this, oldGeometry); -} - -void AbstractClient::destroyDecoration() -{ - const QSize clientSize = frameSizeToClientSize(moveResizeGeometry().size()); - setDecoration(nullptr); - resize(clientSize); -} - void AbstractClient::setDecoration(QSharedPointer decoration) { if (m_decoration.decoration.data() == decoration) { diff --git a/src/abstract_client.h b/src/abstract_client.h index a9505a17f4..5645cc26e8 100644 --- a/src/abstract_client.h +++ b/src/abstract_client.h @@ -1198,8 +1198,6 @@ protected: } void setDecoration(QSharedPointer decoration); - virtual void createDecoration(const QRect &oldGeometry); - virtual void destroyDecoration(); void startDecorationDoubleClickTimer(); void invalidateDecorationDoubleClickTimer(); void updateDecorationInputShape(); diff --git a/src/internal_client.cpp b/src/internal_client.cpp index d02f6d7065..48f5ef07cc 100644 --- a/src/internal_client.cpp +++ b/src/internal_client.cpp @@ -308,6 +308,21 @@ void InternalClient::setNoBorder(bool set) updateDecoration(true); } +void InternalClient::createDecoration(const QRect &oldGeometry) +{ + setDecoration(QSharedPointer(Decoration::DecorationBridge::self()->createDecoration(this))); + moveResize(oldGeometry); + + Q_EMIT geometryShapeChanged(this, oldGeometry); +} + +void InternalClient::destroyDecoration() +{ + const QSize clientSize = frameSizeToClientSize(moveResizeGeometry().size()); + setDecoration(nullptr); + resize(clientSize); +} + void InternalClient::updateDecoration(bool check_workspace_pos, bool force) { if (!force && isDecorated() == !noBorder()) { diff --git a/src/internal_client.h b/src/internal_client.h index 21bc66f8b6..0de85cf16f 100644 --- a/src/internal_client.h +++ b/src/internal_client.h @@ -81,6 +81,8 @@ private: void syncGeometryToInternalWindow(); void updateInternalWindowGeometry(); void updateDecoration(bool check_workspace_pos, bool force = false); + void createDecoration(const QRect &oldGeometry); + void destroyDecoration(); QWindow *m_internalWindow = nullptr; QString m_captionNormal; diff --git a/src/x11client.h b/src/x11client.h index e271dd99c4..a53d9a312e 100644 --- a/src/x11client.h +++ b/src/x11client.h @@ -400,7 +400,6 @@ private: void establishCommandWindowGrab(uint8_t button); void establishCommandAllGrab(uint8_t button); void resizeDecoration(); - void createDecoration(const QRect &oldgeom) override; void pingWindow(); void killProcess(bool ask, xcb_timestamp_t timestamp = XCB_TIME_CURRENT_TIME); @@ -410,7 +409,6 @@ private: void embedClient(xcb_window_t w, xcb_visualid_t visualid, xcb_colormap_t colormap, uint8_t depth); void detectNoBorder(); - void destroyDecoration() override; void updateFrameExtents(); void setClientFrameExtents(const NETStrut &strut); @@ -444,6 +442,8 @@ private: void maybeCreateX11DecorationRenderer(); void maybeDestroyX11DecorationRenderer(); void updateDecoration(bool check_workspace_pos, bool force = false); + void createDecoration(const QRect &oldgeom); + void destroyDecoration(); Xcb::Window m_client; Xcb::Window m_wrapper; diff --git a/src/xdgshellclient.cpp b/src/xdgshellclient.cpp index c30a11bda4..fa2b6a0719 100644 --- a/src/xdgshellclient.cpp +++ b/src/xdgshellclient.cpp @@ -340,7 +340,7 @@ void XdgSurfaceClient::destroyClient() Q_EMIT windowClosed(this, deleted); StackingUpdatesBlocker blocker(workspace()); RuleBook::self()->discardUsed(this, true); - destroyDecoration(); + setDecoration(nullptr); cleanGrouping(); waylandServer()->removeClient(this); deleted->unrefWindow();