diff --git a/composite.cpp b/composite.cpp index 14076ad7a8..f369a4e244 100644 --- a/composite.cpp +++ b/composite.cpp @@ -201,6 +201,8 @@ void Compositor::slotCompositingOptionsInitialized() } } + emit aboutToToggleCompositing(); + auto supportedCompositors = kwinApp()->platform()->supportedCompositors(); const auto userConfigIt = std::find(supportedCompositors.begin(), supportedCompositors.end(), options->compositingMode()); if (userConfigIt != supportedCompositors.end()) { @@ -373,6 +375,8 @@ void Compositor::finish() m_finishing = true; m_releaseSelectionTimer.start(); + emit aboutToToggleCompositing(); + // Some effects might need access to effect windows when they are about to // be destroyed, for example to unreference deleted windows, so we have to // make sure that effect windows outlive effects. @@ -1192,9 +1196,6 @@ bool Client::setupCompositing() if (!Toplevel::setupCompositing()){ return false; } - if (isDecorated()) { - decoratedClient()->destroyRenderer(); - } updateVisibility(); // for internalKeep() return true; } @@ -1203,11 +1204,6 @@ void Client::finishCompositing(ReleaseReason releaseReason) { Toplevel::finishCompositing(releaseReason); updateVisibility(); - if (!deleting) { - if (isDecorated()) { - decoratedClient()->destroyRenderer(); - } - } // for safety in case KWin is just resizing the window resetHaveResizeEffect(); } diff --git a/composite.h b/composite.h index 9a0317bb80..12c7db3640 100644 --- a/composite.h +++ b/composite.h @@ -176,6 +176,7 @@ public Q_SLOTS: Q_SIGNALS: void compositingToggled(bool active); void aboutToDestroy(); + void aboutToToggleCompositing(); void sceneCreated(); protected: diff --git a/decorations/decoratedclient.cpp b/decorations/decoratedclient.cpp index c574edd655..1d3785b73b 100644 --- a/decorations/decoratedclient.cpp +++ b/decorations/decoratedclient.cpp @@ -87,10 +87,9 @@ DecoratedClientImpl::DecoratedClientImpl(AbstractClient *client, KDecoration2::D &Decoration::DecoratedClientImpl::signalShadeChange); connect(client, &AbstractClient::keepAboveChanged, decoratedClient, &KDecoration2::DecoratedClient::keepAboveChanged); connect(client, &AbstractClient::keepBelowChanged, decoratedClient, &KDecoration2::DecoratedClient::keepBelowChanged); + connect(Compositor::self(), &Compositor::aboutToToggleCompositing, this, &DecoratedClientImpl::destroyRenderer); m_compositorToggledConnection = connect(Compositor::self(), &Compositor::compositingToggled, this, [this, decoration]() { - delete m_renderer; - m_renderer = nullptr; createRenderer(); decoration->update(); } diff --git a/decorations/decoratedclient.h b/decorations/decoratedclient.h index f21503256d..e9c1b3b79b 100644 --- a/decorations/decoratedclient.h +++ b/decorations/decoratedclient.h @@ -95,7 +95,6 @@ public: Renderer *renderer() { return m_renderer; } - void destroyRenderer(); KDecoration2::DecoratedClient *decoratedClient() { return KDecoration2::DecoratedClientPrivate::client(); } @@ -107,6 +106,7 @@ private Q_SLOTS: private: void createRenderer(); + void destroyRenderer(); AbstractClient *m_client; QSize m_clientSize; Renderer *m_renderer;