From 5e9023948efe9c6adffd46bf600441b96a428b53 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Sat, 23 Feb 2019 12:17:50 +0000 Subject: [PATCH] [wayland] Keep application startup flow inside main_wayland Summary: In a recent patch the newly added xwayland class ended up being responsible for continuing the startup, calling back into the main app to spawn the workspace. It moves the flow of startup about so it's not very readable or following class structure. This patch moves the code back into main_wayland and removes the duplication between xwayland and non-xwayland modes. There was also a misnaming of methods. Previously: continueStartupWithScreens was called after platform screens are created continueStartupWithScene was called after the scene was created continueStartupWithXwayland was called before xwayland is created This was confusing, so the names have been shuffled around to follow a consistent pattern of what has been done so far. Test Plan: Started kwin_wayland in normal and xwayland mode Ran unit tests (though some failed due to a local unrelated and as yet unindentified bug) Reviewers: #kwin, romangg Reviewed By: #kwin, romangg Subscribers: romangg, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D19232 --- autotests/integration/kwin_wayland_test.cpp | 26 +++++++++++---------- autotests/integration/kwin_wayland_test.h | 2 +- main_wayland.cpp | 24 ++++++++++--------- main_wayland.h | 2 +- xwl/xwayland.cpp | 5 +--- xwl/xwayland.h | 1 + 6 files changed, 31 insertions(+), 29 deletions(-) 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: