From be3146873fcdea3fadc4731789b6c1e05ca15856 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Fri, 11 Nov 2022 10:46:19 +0200 Subject: [PATCH] core: Drop OutputBackend::isReady() OutputBackend has a concept of readiness. When the host compositor goes down, the OutputBackend will be marked as not ready, and when it reappears, the output backend will be marked ready again. On the other hand, host compositor going down is a niche case, it's not something that often happens and it's hard to justify adding more moving parts to the startup code. It's easier to call initialize() and check whether it fails rather than call initialize() and then monitor isReady. Therefore, this change drops OutputBackend::isReady() to make startup simpler. --- src/backends/drm/drm_backend.cpp | 1 - src/backends/virtual/virtual_backend.cpp | 1 - src/backends/wayland/wayland_backend.cpp | 1 - .../x11/standalone/x11_standalone_backend.cpp | 5 +---- src/backends/x11/windowed/x11_windowed_backend.cpp | 1 - src/composite.cpp | 13 +------------ src/core/outputbackend.cpp | 9 --------- src/core/outputbackend.h | 7 ------- 8 files changed, 2 insertions(+), 36 deletions(-) diff --git a/src/backends/drm/drm_backend.cpp b/src/backends/drm/drm_backend.cpp index 37efbc9ba1..11e450925c 100644 --- a/src/backends/drm/drm_backend.cpp +++ b/src/backends/drm/drm_backend.cpp @@ -218,7 +218,6 @@ bool DrmBackend::initialize() m_udevMonitor->enable(); } } - setReady(true); return true; } diff --git a/src/backends/virtual/virtual_backend.cpp b/src/backends/virtual/virtual_backend.cpp index 452c67e520..1b19be4eb5 100644 --- a/src/backends/virtual/virtual_backend.cpp +++ b/src/backends/virtual/virtual_backend.cpp @@ -40,7 +40,6 @@ VirtualBackend::~VirtualBackend() bool VirtualBackend::initialize() { - setReady(true); return true; } diff --git a/src/backends/wayland/wayland_backend.cpp b/src/backends/wayland/wayland_backend.cpp index 22643f99e4..0a0aee57d3 100644 --- a/src/backends/wayland/wayland_backend.cpp +++ b/src/backends/wayland/wayland_backend.cpp @@ -608,7 +608,6 @@ bool WaylandBackend::initialize() m_waylandCursor->init(); }); - setReady(true); return true; } diff --git a/src/backends/x11/standalone/x11_standalone_backend.cpp b/src/backends/x11/standalone/x11_standalone_backend.cpp index 651b136935..51741328d6 100644 --- a/src/backends/x11/standalone/x11_standalone_backend.cpp +++ b/src/backends/x11/standalone/x11_standalone_backend.cpp @@ -128,9 +128,7 @@ X11StandaloneBackend::~X11StandaloneBackend() if (sceneEglDisplay() != EGL_NO_DISPLAY) { eglTerminate(sceneEglDisplay()); } - if (isReady()) { - XRenderUtils::cleanup(); - } + XRenderUtils::cleanup(); } bool X11StandaloneBackend::initialize() @@ -139,7 +137,6 @@ bool X11StandaloneBackend::initialize() return false; } XRenderUtils::init(kwinApp()->x11Connection(), kwinApp()->x11RootWindow()); - setReady(true); initOutputs(); if (Xcb::Extensions::self()->isRandrAvailable()) { diff --git a/src/backends/x11/windowed/x11_windowed_backend.cpp b/src/backends/x11/windowed/x11_windowed_backend.cpp index 850f8ad54f..9117ec4b0c 100644 --- a/src/backends/x11/windowed/x11_windowed_backend.cpp +++ b/src/backends/x11/windowed/x11_windowed_backend.cpp @@ -206,7 +206,6 @@ bool X11WindowedBackend::initialize() KWin::Cursor *c = KWin::Cursors::self()->currentCursor(); createCursor(c->image(), c->hotspot()); }); - setReady(true); m_pointerDevice = std::make_unique(); m_pointerDevice->setPointer(true); m_keyboardDevice = std::make_unique(); diff --git a/src/composite.cpp b/src/composite.cpp index c98b67b9ea..c037a28a5c 100644 --- a/src/composite.cpp +++ b/src/composite.cpp @@ -141,18 +141,7 @@ Compositor::Compositor(QObject *workspace) // The ctor of this class is invoked from the Workspace ctor, that means before // Workspace is completely constructed, so calling Workspace::self() would result // in undefined behavior. This is fixed by using a delayed invocation. - if (kwinApp()->outputBackend()->isReady()) { - QTimer::singleShot(0, this, &Compositor::start); - } - connect( - kwinApp()->outputBackend(), &OutputBackend::readyChanged, this, [this](bool ready) { - if (ready) { - start(); - } else { - stop(); - } - }, - Qt::QueuedConnection); + QTimer::singleShot(0, this, &Compositor::start); connect(kwinApp(), &Application::x11ConnectionChanged, this, &Compositor::initializeX11); connect(kwinApp(), &Application::x11ConnectionAboutToBeDestroyed, this, &Compositor::cleanupX11); diff --git a/src/core/outputbackend.cpp b/src/core/outputbackend.cpp index 8227ebefdc..8ee42c103b 100644 --- a/src/core/outputbackend.cpp +++ b/src/core/outputbackend.cpp @@ -91,15 +91,6 @@ Output *OutputBackend::findOutput(const QString &name) const return nullptr; } -void OutputBackend::setReady(bool ready) -{ - if (m_ready == ready) { - return; - } - m_ready = ready; - Q_EMIT readyChanged(m_ready); -} - Output *OutputBackend::createVirtualOutput(const QString &name, const QSize &size, double scale) { return nullptr; diff --git a/src/core/outputbackend.h b/src/core/outputbackend.h index 8836a36c51..8779226185 100644 --- a/src/core/outputbackend.h +++ b/src/core/outputbackend.h @@ -74,10 +74,6 @@ public: */ void setSceneEglGlobalShareContext(EGLContext context); - bool isReady() const - { - return m_ready; - } void setInitialWindowSize(const QSize &size) { m_initialWindowSize = size; @@ -135,7 +131,6 @@ public Q_SLOTS: Q_SIGNALS: void outputsQueried(); - void readyChanged(bool); /** * This signal is emitted when an output has been connected. The @a output is not ready * for compositing yet. @@ -148,7 +143,6 @@ Q_SIGNALS: protected: explicit OutputBackend(QObject *parent = nullptr); - void setReady(bool ready); QSize initialWindowSize() const { return m_initialWindowSize; @@ -159,7 +153,6 @@ protected: } private: - bool m_ready = false; QSize m_initialWindowSize; QByteArray m_deviceIdentifier; int m_initialOutputCount = 1;