Commit 5e902394 authored by David Edmundson's avatar David Edmundson

[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
parent 19793b94
......@@ -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::continueStartupWithScene()
void WaylandTestApplication::finalizeStartup()
{
disconnect(Compositor::self(), &Compositor::sceneCreated, this, &WaylandTestApplication::continueStartupWithScene);
if (m_xwayland) {
disconnect(m_xwayland, &Xwl::Xwayland::initialized, this, &WaylandTestApplication::finalizeStartup);
}
createWorkspace();
}
void WaylandTestApplication::continueStartupWithXwayland()
void WaylandTestApplication::continueStartupWithScene()
{
disconnect(Compositor::self(), &Compositor::sceneCreated, this, &WaylandTestApplication::continueStartupWithXwayland);
disconnect(Compositor::self(), &Compositor::sceneCreated, this, &WaylandTestApplication::continueStartupWithScene);
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();
}
......
......@@ -76,7 +76,7 @@ private:
void createBackend();
void continueStartupWithScreens();
void continueStartupWithScene();
void continueStartupWithXwayland();
void finalizeStartup();
Xwl::Xwayland *m_xwayland = nullptr;
};
......
......@@ -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();
}
......
......@@ -63,7 +63,7 @@ private:
void createBackend();
void continueStartupWithScreens();
void continueStartupWithScene();
void continueStartupWithXwayland();
void finalizeStartup();
void startSession() override;
bool m_startXWayland = false;
......
......@@ -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)
......
......@@ -56,6 +56,7 @@ public:
}
Q_SIGNALS:
void initialized();
void criticalError(int code);
private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment