From 15ed4f393e149926d1d4cd7ae623536d36ed01ed Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Thu, 14 Sep 2023 15:07:54 +0300 Subject: [PATCH] wayland: Simplify startup of compositor At the moment, the wayland compositor has to handle the case of having no workspace. This should be unnecessary and it creates a pesky cycling dependency between Workspace and Compositor. Given that the Workspace acts more like a container and kwin starts accepting client connections after starting compositing, it's possible to create the Workspace earlier and simplify the start() function a bit. --- autotests/integration/kwin_wayland_test.cpp | 8 ++++---- src/compositor_wayland.cpp | 7 +------ src/main_wayland.cpp | 7 +++---- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/autotests/integration/kwin_wayland_test.cpp b/autotests/integration/kwin_wayland_test.cpp index e2bbef3587..bbfbe51a96 100644 --- a/autotests/integration/kwin_wayland_test.cpp +++ b/autotests/integration/kwin_wayland_test.cpp @@ -146,6 +146,10 @@ void WaylandTestApplication::performStartup() createVirtualInputDevices(); WaylandCompositor::create(); + createWorkspace(); + createColorManager(); + createPlugins(); + connect(Compositor::self(), &Compositor::sceneCreated, this, &WaylandTestApplication::continueStartupWithScene); } @@ -153,10 +157,6 @@ void WaylandTestApplication::continueStartupWithScene() { disconnect(Compositor::self(), &Compositor::sceneCreated, this, &WaylandTestApplication::continueStartupWithScene); - createWorkspace(); - createColorManager(); - createPlugins(); - waylandServer()->initWorkspace(); if (!waylandServer()->start()) { diff --git a/src/compositor_wayland.cpp b/src/compositor_wayland.cpp index 320363be70..fde9ca1642 100644 --- a/src/compositor_wayland.cpp +++ b/src/compositor_wayland.cpp @@ -45,12 +45,7 @@ void WaylandCompositor::start() return; } - if (Workspace::self()) { - startupWithWorkspace(); - } else { - connect(kwinApp(), &Application::workspaceCreated, - this, &WaylandCompositor::startupWithWorkspace); - } + startupWithWorkspace(); } } // namespace KWin diff --git a/src/main_wayland.cpp b/src/main_wayland.cpp index b3d496045e..2013b520c8 100644 --- a/src/main_wayland.cpp +++ b/src/main_wayland.cpp @@ -145,6 +145,9 @@ void ApplicationWayland::performStartup() createTabletModeManager(); WaylandCompositor::create(); + createWorkspace(); + createColorManager(); + createPlugins(); connect(Compositor::self(), &Compositor::sceneCreated, outputBackend(), &OutputBackend::sceneInitialized); connect(Compositor::self(), &Compositor::sceneCreated, this, &ApplicationWayland::continueStartupWithScene, Qt::SingleShotConnection); @@ -153,10 +156,6 @@ void ApplicationWayland::performStartup() void ApplicationWayland::continueStartupWithScene() { // Note that we start accepting client connections after creating the Workspace. - createWorkspace(); - createColorManager(); - createPlugins(); - if (!waylandServer()->start()) { qFatal("Failed to initialze the Wayland server, exiting now"); }