diff --git a/autotests/integration/kwin_wayland_test.cpp b/autotests/integration/kwin_wayland_test.cpp index a31741ea1e..fe07f1de23 100644 --- a/autotests/integration/kwin_wayland_test.cpp +++ b/autotests/integration/kwin_wayland_test.cpp @@ -126,25 +126,26 @@ void WaylandTestApplication::continueStartupWithScreens() { disconnect(kwinApp()->platform(), &Platform::screensQueried, this, &WaylandTestApplication::continueStartupWithScreens); createScreens(); - - if (operationMode() == OperationModeWaylandOnly) { - createCompositor(); - connect(Compositor::self(), &Compositor::sceneCreated, this, &WaylandTestApplication::continueStartupWithScene); - return; - } createCompositor(); - connect(Compositor::self(), &Compositor::sceneCreated, this, &WaylandTestApplication::continueStartupWithXwayland); + connect(Compositor::self(), &Compositor::sceneCreated, this, &WaylandTestApplication::continueStartupWithScene); +} + +void WaylandTestApplication::finalizeStartup() +{ + if (m_xwayland) { + disconnect(m_xwayland, &Xwl::Xwayland::initialized, this, &WaylandTestApplication::finalizeStartup); + } + createWorkspace(); } void WaylandTestApplication::continueStartupWithScene() { disconnect(Compositor::self(), &Compositor::sceneCreated, this, &WaylandTestApplication::continueStartupWithScene); - createWorkspace(); -} -void WaylandTestApplication::continueStartupWithXwayland() -{ - disconnect(Compositor::self(), &Compositor::sceneCreated, this, &WaylandTestApplication::continueStartupWithXwayland); + if (operationMode() == OperationModeWaylandOnly) { + finalizeStartup(); + return; + } m_xwayland = new Xwl::Xwayland(this); connect(m_xwayland, &Xwl::Xwayland::criticalError, this, [](int code) { @@ -153,6 +154,7 @@ void WaylandTestApplication::continueStartupWithXwayland() std::cerr << "Xwayland had a critical error. Going to exit now." << std::endl; exit(code); }); + connect(m_xwayland, &Xwl::Xwayland::initialized, this, &WaylandTestApplication::finalizeStartup); m_xwayland->init(); } diff --git a/autotests/integration/kwin_wayland_test.h b/autotests/integration/kwin_wayland_test.h index c764b362ec..125ecf5a63 100644 --- a/autotests/integration/kwin_wayland_test.h +++ b/autotests/integration/kwin_wayland_test.h @@ -76,7 +76,7 @@ private: void createBackend(); void continueStartupWithScreens(); void continueStartupWithScene(); - void continueStartupWithXwayland(); + void finalizeStartup(); Xwl::Xwayland *m_xwayland = nullptr; }; diff --git a/main_wayland.cpp b/main_wayland.cpp index a12e5bd7ff..39d777c944 100644 --- a/main_wayland.cpp +++ b/main_wayland.cpp @@ -180,27 +180,28 @@ void ApplicationWayland::continueStartupWithScreens() { disconnect(kwinApp()->platform(), &Platform::screensQueried, this, &ApplicationWayland::continueStartupWithScreens); createScreens(); - - if (operationMode() == OperationModeWaylandOnly) { - createCompositor(); - connect(Compositor::self(), &Compositor::sceneCreated, this, &ApplicationWayland::continueStartupWithScene); - return; - } createCompositor(); - connect(Compositor::self(), &Compositor::sceneCreated, this, &ApplicationWayland::continueStartupWithXwayland); + connect(Compositor::self(), &Compositor::sceneCreated, this, &ApplicationWayland::continueStartupWithScene); } -void ApplicationWayland::continueStartupWithScene() +void ApplicationWayland::finalizeStartup() { - disconnect(Compositor::self(), &Compositor::sceneCreated, this, &ApplicationWayland::continueStartupWithScene); + if (m_xwayland) { + disconnect(m_xwayland, &Xwl::Xwayland::initialized, this, &ApplicationWayland::finalizeStartup); + } startSession(); createWorkspace(); notifyKSplash(); } -void ApplicationWayland::continueStartupWithXwayland() +void ApplicationWayland::continueStartupWithScene() { - disconnect(Compositor::self(), &Compositor::sceneCreated, this, &ApplicationWayland::continueStartupWithXwayland); + disconnect(Compositor::self(), &Compositor::sceneCreated, this, &ApplicationWayland::continueStartupWithScene); + + if (operationMode() == OperationModeWaylandOnly) { + finalizeStartup(); + return; + } m_xwayland = new Xwl::Xwayland(this); connect(m_xwayland, &Xwl::Xwayland::criticalError, this, [](int code) { @@ -209,6 +210,7 @@ void ApplicationWayland::continueStartupWithXwayland() std::cerr << "Xwayland had a critical error. Going to exit now." << std::endl; exit(code); }); + connect(m_xwayland, &Xwl::Xwayland::initialized, this, &ApplicationWayland::finalizeStartup); m_xwayland->init(); } diff --git a/main_wayland.h b/main_wayland.h index 911f3a360e..23c2fdfb4d 100644 --- a/main_wayland.h +++ b/main_wayland.h @@ -63,7 +63,7 @@ private: void createBackend(); void continueStartupWithScreens(); void continueStartupWithScene(); - void continueStartupWithXwayland(); + void finalizeStartup(); void startSession() override; bool m_startXWayland = false; diff --git a/xwl/xwayland.cpp b/xwl/xwayland.cpp index a521f27c0e..3d7c2465ad 100644 --- a/xwl/xwayland.cpp +++ b/xwl/xwayland.cpp @@ -262,12 +262,9 @@ void Xwayland::continueStartupWithX() env.insert(QStringLiteral("DISPLAY"), QString::fromUtf8(qgetenv("DISPLAY"))); m_app->setProcessStartupEnvironment(env); - m_app->startSession(); - m_app->createWorkspace(); + emit initialized(); Xcb::sync(); // Trigger possible errors, there's still a chance to abort - - m_app->notifyKSplash(); } DragEventReply Xwayland::dragMoveFilter(Toplevel *target, QPoint pos) diff --git a/xwl/xwayland.h b/xwl/xwayland.h index 2ee1e607fb..efbbb5eb35 100644 --- a/xwl/xwayland.h +++ b/xwl/xwayland.h @@ -56,6 +56,7 @@ public: } Q_SIGNALS: + void initialized(); void criticalError(int code); private: