diff --git a/autotests/integration/kwin_wayland_test.cpp b/autotests/integration/kwin_wayland_test.cpp index 7889109fd0..4c71d7dea2 100644 --- a/autotests/integration/kwin_wayland_test.cpp +++ b/autotests/integration/kwin_wayland_test.cpp @@ -133,7 +133,6 @@ void WaylandTestApplication::performStartup() if (!platform()->initialize()) { std::exit(1); } - waylandServer()->initPlatform(); // try creating the Wayland Backend createInput(); diff --git a/src/main_wayland.cpp b/src/main_wayland.cpp index 590e69949b..142141d420 100644 --- a/src/main_wayland.cpp +++ b/src/main_wayland.cpp @@ -147,8 +147,6 @@ void ApplicationWayland::performStartup() std::exit(1); } - waylandServer()->initPlatform(); - createInput(); createInputMethod(); createTabletModeManager(); diff --git a/src/wayland_server.cpp b/src/wayland_server.cpp index 3be876609f..e8779a738a 100644 --- a/src/wayland_server.cpp +++ b/src/wayland_server.cpp @@ -272,30 +272,6 @@ void WaylandServer::registerXdgGenericWindow(Window *window) qCDebug(KWIN_CORE) << "Received invalid xdg shell window:" << window->surface(); } -void WaylandServer::initPlatform() -{ - connect(kwinApp()->platform(), &Platform::outputAdded, this, &WaylandServer::handleOutputAdded); - connect(kwinApp()->platform(), &Platform::outputRemoved, this, &WaylandServer::handleOutputRemoved); - - connect(kwinApp()->platform(), &Platform::outputEnabled, this, &WaylandServer::handleOutputEnabled); - connect(kwinApp()->platform(), &Platform::outputDisabled, this, &WaylandServer::handleOutputDisabled); - - connect(kwinApp()->platform(), &Platform::primaryOutputChanged, this, [this](Output *primaryOutput) { - m_primary->setPrimaryOutput(primaryOutput ? primaryOutput->name() : QString()); - }); - if (auto primaryOutput = kwinApp()->platform()->primaryOutput()) { - m_primary->setPrimaryOutput(primaryOutput->name()); - } - - const QVector outputs = kwinApp()->platform()->outputs(); - for (Output *output : outputs) { - handleOutputAdded(output); - if (output->isEnabled()) { - handleOutputEnabled(output); - } - } -} - void WaylandServer::handleOutputAdded(Output *output) { if (!output->isPlaceholder() && !output->isNonDesktop()) { @@ -561,6 +537,27 @@ void WaylandServer::initWorkspace() }); } + connect(kwinApp()->platform(), &Platform::primaryOutputChanged, this, [this](Output *primaryOutput) { + m_primary->setPrimaryOutput(primaryOutput ? primaryOutput->name() : QString()); + }); + if (auto primaryOutput = kwinApp()->platform()->primaryOutput()) { + m_primary->setPrimaryOutput(primaryOutput->name()); + } + + const auto availableOutputs = kwinApp()->platform()->outputs(); + for (Output *output : availableOutputs) { + handleOutputAdded(output); + } + connect(kwinApp()->platform(), &Platform::outputAdded, this, &WaylandServer::handleOutputAdded); + connect(kwinApp()->platform(), &Platform::outputRemoved, this, &WaylandServer::handleOutputRemoved); + + const auto outputs = workspace()->outputs(); + for (Output *output : outputs) { + handleOutputEnabled(output); + } + connect(workspace(), &Workspace::outputAdded, this, &WaylandServer::handleOutputEnabled); + connect(workspace(), &Workspace::outputRemoved, this, &WaylandServer::handleOutputDisabled); + if (hasScreenLockerIntegration()) { initScreenLocker(); } diff --git a/src/wayland_server.h b/src/wayland_server.h index eb87ae5249..9929e77cc9 100644 --- a/src/wayland_server.h +++ b/src/wayland_server.h @@ -179,7 +179,6 @@ public: */ bool hasGlobalShortcutSupport() const; - void initPlatform(); void initWorkspace(); KWaylandServer::ClientConnection *xWaylandConnection() const;