From 5cc626c1026138b3dc096015f0619ecc56169229 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Tue, 27 Aug 2019 12:42:58 +0200 Subject: [PATCH] Remove outputs handling alternative Summary: With f013a4369c2e, cd6b69a4d2db, d960be4b3f39 and edb200f6bcd5 all possible backends of a Wayland session have been ported to using the internal functions of AbstractWaylandOutput's for managing outputs. This removes the alternative code path used before in these backends, what simplifies the code and is also a prerequisite to removing the Screens global in the future. Reviewers: #kwin, apol, zzag Reviewed By: #kwin, apol, zzag Subscribers: apol, kwin Tags: #kwin Maniphest Tasks: T11459, T11098 Differential Revision: https://phabricator.kde.org/D23485 --- platform.h | 8 ---- plugins/platforms/drm/drm_backend.cpp | 1 - plugins/platforms/fbdev/fb_backend.cpp | 1 - .../hwcomposer/hwcomposer_backend.cpp | 1 - plugins/platforms/virtual/virtual_backend.cpp | 1 - plugins/platforms/wayland/wayland_backend.cpp | 1 - .../x11/windowed/x11windowed_backend.cpp | 1 - wayland_server.cpp | 43 ------------------- wayland_server.h | 2 - 9 files changed, 59 deletions(-) diff --git a/platform.h b/platform.h index 1488aeccde..97e059a45a 100644 --- a/platform.h +++ b/platform.h @@ -321,10 +321,6 @@ public: bool isCursorHidden() const { return m_hideCursorCounter > 0; } - - bool handlesOutputs() const { - return m_handlesOutputs; - } bool isReady() const { return m_ready; } @@ -490,9 +486,6 @@ Q_SIGNALS: protected: explicit Platform(QObject *parent = nullptr); void setSoftWareCursor(bool set); - void handleOutputs() { - m_handlesOutputs = true; - } void repaint(const QRect &rect); void setReady(bool ready); QSize initialWindowSize() const { @@ -538,7 +531,6 @@ private: struct { QRect lastRenderedGeometry; } m_cursor; - bool m_handlesOutputs = false; bool m_ready = false; QSize m_initialWindowSize; QByteArray m_deviceIdentifier; diff --git a/plugins/platforms/drm/drm_backend.cpp b/plugins/platforms/drm/drm_backend.cpp index 8d6b260b3f..8883e68e06 100644 --- a/plugins/platforms/drm/drm_backend.cpp +++ b/plugins/platforms/drm/drm_backend.cpp @@ -83,7 +83,6 @@ DrmBackend::DrmBackend(QObject *parent) } #endif setSupportsGammaControl(true); - handleOutputs(); } DrmBackend::~DrmBackend() diff --git a/plugins/platforms/fbdev/fb_backend.cpp b/plugins/platforms/fbdev/fb_backend.cpp index 2b8c5c5ad3..5760c040f3 100644 --- a/plugins/platforms/fbdev/fb_backend.cpp +++ b/plugins/platforms/fbdev/fb_backend.cpp @@ -51,7 +51,6 @@ void FramebufferOutput::init(const QSize &pixelSize, const QSize &physicalSize) FramebufferBackend::FramebufferBackend(QObject *parent) : Platform(parent) { - handleOutputs(); } FramebufferBackend::~FramebufferBackend() diff --git a/plugins/platforms/hwcomposer/hwcomposer_backend.cpp b/plugins/platforms/hwcomposer/hwcomposer_backend.cpp index b74bc9f2ca..e8e41cda99 100644 --- a/plugins/platforms/hwcomposer/hwcomposer_backend.cpp +++ b/plugins/platforms/hwcomposer/hwcomposer_backend.cpp @@ -152,7 +152,6 @@ HwcomposerBackend::HwcomposerBackend(QObject *parent) SLOT(screenBrightnessChanged(int)))) { qCWarning(KWIN_HWCOMPOSER) << "Failed to connect to brightness control"; } - handleOutputs(); } HwcomposerBackend::~HwcomposerBackend() diff --git a/plugins/platforms/virtual/virtual_backend.cpp b/plugins/platforms/virtual/virtual_backend.cpp index 4a3b661e9a..2cfa23ed14 100644 --- a/plugins/platforms/virtual/virtual_backend.cpp +++ b/plugins/platforms/virtual/virtual_backend.cpp @@ -49,7 +49,6 @@ VirtualBackend::VirtualBackend(QObject *parent) } setSupportsPointerWarping(true); setSupportsGammaControl(true); - handleOutputs(); } VirtualBackend::~VirtualBackend() diff --git a/plugins/platforms/wayland/wayland_backend.cpp b/plugins/platforms/wayland/wayland_backend.cpp index a868e994af..0b10029d0e 100644 --- a/plugins/platforms/wayland/wayland_backend.cpp +++ b/plugins/platforms/wayland/wayland_backend.cpp @@ -454,7 +454,6 @@ WaylandBackend::WaylandBackend(QObject *parent) , m_connectionThread(nullptr) { connect(this, &WaylandBackend::connectionFailed, this, &WaylandBackend::initFailed); - handleOutputs(); } WaylandBackend::~WaylandBackend() diff --git a/plugins/platforms/x11/windowed/x11windowed_backend.cpp b/plugins/platforms/x11/windowed/x11windowed_backend.cpp index 1523f2985f..244a091cbd 100644 --- a/plugins/platforms/x11/windowed/x11windowed_backend.cpp +++ b/plugins/platforms/x11/windowed/x11windowed_backend.cpp @@ -54,7 +54,6 @@ X11WindowedBackend::X11WindowedBackend(QObject *parent) { setSupportsPointerWarping(true); connect(this, &X11WindowedBackend::sizeChanged, this, &X11WindowedBackend::screenSizeChanged); - handleOutputs(); } X11WindowedBackend::~X11WindowedBackend() diff --git a/wayland_server.cpp b/wayland_server.cpp index 2feede0965..f5c5ad0f21 100644 --- a/wayland_server.cpp +++ b/wayland_server.cpp @@ -97,8 +97,6 @@ WaylandServer::WaylandServer(QObject *parent) : QObject(parent) { qRegisterMetaType(); - - connect(kwinApp(), &Application::screensCreated, this, &WaylandServer::initOutputs); } WaylandServer::~WaylandServer() @@ -541,47 +539,6 @@ void WaylandServer::initScreenLocker() emit initialized(); } -void WaylandServer::initOutputs() -{ - if (kwinApp()->platform()->handlesOutputs()) { - return; - } - syncOutputsToWayland(); - connect(screens(), &Screens::changed, this, - [this] { - // when screens change we need to sync this to Wayland. - // Unfortunately we don't have much information and cannot properly match a KWin screen - // to a Wayland screen. - // Thus we just recreate all outputs and delete the old ones - const auto outputs = m_display->outputs(); - syncOutputsToWayland(); - qDeleteAll(outputs); - } - ); -} - -void WaylandServer::syncOutputsToWayland() -{ - Screens *s = screens(); - Q_ASSERT(s); - for (int i = 0; i < s->count(); ++i) { - OutputInterface *output = m_display->createOutput(m_display); - auto xdgOutput = xdgOutputManager()->createXdgOutput(output, output); - - output->setScale(s->scale(i)); - const QRect &geo = s->geometry(i); - output->setGlobalPosition(geo.topLeft()); - output->setPhysicalSize(s->physicalSize(i).toSize()); - output->addMode(geo.size()); - - xdgOutput->setLogicalPosition(geo.topLeft()); - xdgOutput->setLogicalSize(geo.size()); - xdgOutput->done(); - - output->create(); - } -} - WaylandServer::SocketPairConnection WaylandServer::createConnection() { SocketPairConnection ret; diff --git a/wayland_server.h b/wayland_server.h index 686458a88a..5a1940e6e7 100644 --- a/wayland_server.h +++ b/wayland_server.h @@ -233,8 +233,6 @@ Q_SIGNALS: private: void shellClientShown(Toplevel *t); - void initOutputs(); - void syncOutputsToWayland(); quint16 createClientId(KWayland::Server::ClientConnection *c); void destroyInternalConnection(); void configurationChangeRequested(KWayland::Server::OutputConfigurationInterface *config);