From 8c047613c5234203f4643674bb2715baac6c9b5c Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Tue, 2 Jul 2019 22:30:27 +0200 Subject: [PATCH] Partly remove Compositor restart functionality Summary: This removes the restart function of the Compositor class and renames the internal reinitialize function. Instead of the restart function reinitialize can be called. Reading again the settings in this case is fine, since it is done rarely. This reduces the code complexity. Test Plan: Manually on Wayland and X. 100% autotests pass. Reviewers: #kwin, zzag Reviewed By: #kwin, zzag Subscribers: davidedmundson, zzag, kwin Tags: #kwin Maniphest Tasks: T11071 Differential Revision: https://phabricator.kde.org/D22225 --- .../dont_crash_reinitialize_compositor.cpp | 2 +- .../integration/generic_scene_opengl_test.cpp | 2 +- autotests/integration/scene_qpainter_test.cpp | 2 +- composite.cpp | 14 +++----------- composite.h | 7 +------ dbusinterface.cpp | 2 +- 6 files changed, 8 insertions(+), 21 deletions(-) diff --git a/autotests/integration/dont_crash_reinitialize_compositor.cpp b/autotests/integration/dont_crash_reinitialize_compositor.cpp index 38f0269c33..b0fceac718 100644 --- a/autotests/integration/dont_crash_reinitialize_compositor.cpp +++ b/autotests/integration/dont_crash_reinitialize_compositor.cpp @@ -158,7 +158,7 @@ void DontCrashReinitializeCompositorTest::testReinitializeCompositor() QVERIFY(effect->isActive()); // Re-initialize the compositor, effects will be destroyed and created again. - Compositor::self()->slotReinitialize(); + Compositor::self()->reinitialize(); // By this time, KWin should still be alive. } diff --git a/autotests/integration/generic_scene_opengl_test.cpp b/autotests/integration/generic_scene_opengl_test.cpp index 33a9cf48d6..02402dde5b 100644 --- a/autotests/integration/generic_scene_opengl_test.cpp +++ b/autotests/integration/generic_scene_opengl_test.cpp @@ -102,7 +102,7 @@ void GenericSceneOpenGLTest::testRestart() QSignalSpy sceneCreatedSpy(KWin::Compositor::self(), &Compositor::sceneCreated); QVERIFY(sceneCreatedSpy.isValid()); - KWin::Compositor::self()->slotReinitialize(); + KWin::Compositor::self()->reinitialize(); if (sceneCreatedSpy.isEmpty()) { QVERIFY(sceneCreatedSpy.wait()); } diff --git a/autotests/integration/scene_qpainter_test.cpp b/autotests/integration/scene_qpainter_test.cpp index 61ff40e0c1..4c10a477b7 100644 --- a/autotests/integration/scene_qpainter_test.cpp +++ b/autotests/integration/scene_qpainter_test.cpp @@ -283,7 +283,7 @@ void SceneQPainterTest::testCompositorRestart() QVERIFY(oldScene); QSignalSpy sceneCreatedSpy(KWin::Compositor::self(), &KWin::Compositor::sceneCreated); QVERIFY(sceneCreatedSpy.isValid()); - KWin::Compositor::self()->slotReinitialize(); + KWin::Compositor::self()->reinitialize(); if (sceneCreatedSpy.isEmpty()) { QVERIFY(sceneCreatedSpy.wait()); } diff --git a/composite.cpp b/composite.cpp index 207114c4da..ed73220628 100644 --- a/composite.cpp +++ b/composite.cpp @@ -110,7 +110,7 @@ Compositor::Compositor(QObject* workspace) , m_composeAtSwapCompletion(false) { qRegisterMetaType("Compositor::SuspendReason"); - connect(&compositeResetTimer, &QTimer::timeout, this, &Compositor::restart); + connect(&compositeResetTimer, &QTimer::timeout, this, &Compositor::reinitialize); connect(options, &Options::configChanged, this, &Compositor::slotConfigChanged); compositeResetTimer.setSingleShot(true); m_monotonicClock.start(); @@ -277,7 +277,7 @@ void Compositor::slotCompositingOptionsInitialized() QQuickWindow::setSceneGraphBackend(QSGRendererInterface::Software); } - connect(m_scene, &Scene::resetCompositing, this, &Compositor::restart); + connect(m_scene, &Scene::resetCompositing, this, &Compositor::reinitialize); emit sceneCreated(); if (Workspace::self()) { @@ -503,7 +503,7 @@ void Compositor::slotConfigChanged() finish(); } -void Compositor::slotReinitialize() +void Compositor::reinitialize() { // Reparse config. Config options will be reloaded by setup() kwinApp()->config()->reparseConfiguration(); @@ -590,14 +590,6 @@ void Compositor::resume(Compositor::SuspendReason reason) setup(); // signal "toggled" is eventually emitted from within setup } -void Compositor::restart() -{ - if (hasScene()) { - finish(); - QTimer::singleShot(0, this, &Compositor::setup); - } -} - void Compositor::addRepaint(int x, int y, int w, int h) { if (!hasScene()) diff --git a/composite.h b/composite.h index ac2e5e91bb..09bf9eedd1 100644 --- a/composite.h +++ b/composite.h @@ -115,7 +115,7 @@ public: * Re-initializes the Compositor completely. * Connected to the D-Bus signal org.kde.KWin /KWin reinitCompositing **/ - void slotReinitialize(); + void reinitialize(); /** * Whether the Compositor is active. That is a Scene is present and the Compositor is @@ -187,11 +187,6 @@ private: **/ void slotCompositingOptionsInitialized(); void finish(); - /** - * Restarts the Compositor if running. - * That is the Compositor will be stopped and started again. - **/ - void restart(); void claimCompositorSelection(); diff --git a/dbusinterface.cpp b/dbusinterface.cpp index 8aa02ca285..56b561edc3 100644 --- a/dbusinterface.cpp +++ b/dbusinterface.cpp @@ -319,7 +319,7 @@ void CompositorDBusInterface::suspend() void CompositorDBusInterface::reinitialize() { - m_compositor->slotReinitialize(); + m_compositor->reinitialize(); } QStringList CompositorDBusInterface::supportedOpenGLPlatformInterfaces() const