Commit 97cf9026 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii Committed by Vlad Zahorodnii
Browse files

Start accepting client connections after creating workspace

Sub-classes of the AbstractClient class need a valid instance of the
Workspace class to function as desired. We should not create xdg-shell
clients until the workspace is created.
parent d1b35f30
......@@ -135,7 +135,6 @@ void WaylandTestApplication::finalizeStartup()
if (m_xwayland) {
disconnect(m_xwayland, &Xwl::Xwayland::initialized, this, &WaylandTestApplication::finalizeStartup);
}
createWorkspace();
notifyStarted();
}
......@@ -143,6 +142,12 @@ void WaylandTestApplication::continueStartupWithScene()
{
disconnect(Compositor::self(), &Compositor::sceneCreated, this, &WaylandTestApplication::continueStartupWithScene);
createWorkspace();
if (!waylandServer()->start()) {
qFatal("Failed to initialize the Wayland server, exiting now");
}
if (operationMode() == OperationModeWaylandOnly) {
finalizeStartup();
return;
......
......@@ -39,8 +39,9 @@ void NoXdgRuntimeDirTest::initTestCase()
void NoXdgRuntimeDirTest::testInitFails()
{
// this test verifies that without an XDG_RUNTIME_DIR the WaylandServer fials to init
QVERIFY(!waylandServer()->init(s_socketName.toLocal8Bit()));
// this test verifies that without an XDG_RUNTIME_DIR the WaylandServer fails to start
QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit()));
QVERIFY(!waylandServer()->start());
}
WAYLANDTEST_MAIN(NoXdgRuntimeDirTest)
......
......@@ -191,7 +191,6 @@ void ApplicationWayland::finalizeStartup()
disconnect(m_xwayland, &Xwl::Xwayland::initialized, this, &ApplicationWayland::finalizeStartup);
}
startSession();
createWorkspace();
notifyStarted();
}
......@@ -199,6 +198,13 @@ void ApplicationWayland::continueStartupWithScene()
{
disconnect(Compositor::self(), &Compositor::sceneCreated, this, &ApplicationWayland::continueStartupWithScene);
// Note that we start accepting client connections after creating the Workspace.
createWorkspace();
if (!waylandServer()->start()) {
qFatal("Failed to initialze the Wayland server, exiting now");
}
if (operationMode() == OperationModeWaylandOnly) {
finalizeStartup();
return;
......
......@@ -291,6 +291,11 @@ public:
}
};
bool WaylandServer::start()
{
return m_display->start();
}
bool WaylandServer::init(const QByteArray &socketName, InitializationFlags flags)
{
m_initFlags = flags;
......@@ -300,10 +305,6 @@ bool WaylandServer::init(const QByteArray &socketName, InitializationFlags flags
} else {
m_display->setAutomaticSocketNaming(true);
}
m_display->start();
if (!m_display->isRunning()) {
return false;
}
m_compositor = m_display->createCompositor(m_display);
connect(m_compositor, &CompositorInterface::surfaceCreated, this,
[this] (SurfaceInterface *surface) {
......
......@@ -96,6 +96,7 @@ public:
~WaylandServer() override;
bool init(const QByteArray &socketName = QByteArray(), InitializationFlags flags = InitializationFlag::NoOptions);
bool start();
void terminateClientConnections();
KWaylandServer::Display *display() const
......
......@@ -66,7 +66,9 @@ void WaylandXdgShellIntegration::registerXdgToplevel(XdgToplevelInterface *tople
void WaylandXdgShellIntegration::createXdgToplevelClient(XdgToplevelInterface *toplevel)
{
if (!workspace()) {
return; // TODO: Shouldn't we create the client when workspace is initialized?
qCWarning(KWIN_CORE, "An xdg-toplevel surface has been created while the compositor "
"is still not fully initialized. That is a compositor bug!");
return;
}
emit clientCreated(new XdgToplevelClient(toplevel));
......@@ -75,7 +77,9 @@ void WaylandXdgShellIntegration::createXdgToplevelClient(XdgToplevelInterface *t
void WaylandXdgShellIntegration::registerXdgPopup(XdgPopupInterface *popup)
{
if (!workspace()) {
return; // TODO: Shouldn't we create the client when workspace is initialized?
qCWarning(KWIN_CORE, "An xdg-popup surface has been created while the compositor is "
"still not fully initialized. That is a compositor bug!");
return;
}
emit clientCreated(new XdgPopupClient(popup));
......
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