Commit 79c49e84 authored by Martin Flöser's avatar Martin Flöser

[kwin_wayland] Pass socket file descriptor to QtWayland

WaylandServer allows to create a ClientConnection which is intended for
QtWayland. This allows us to easily identify our "own" surfaces. The
created file descriptor is set as env variable WAYLAND_SOCKET prior to
creating the Application. Wayland will unset it after connecting, so we
don't need to unset it. This removes the hack of setting and resetting
the WAYLAND_DISPLAY environment variable.
parent 69a13a77
......@@ -318,12 +318,8 @@ KWIN_EXPORT int kdemain(int argc, char * argv[])
if (signal(SIGHUP, KWin::sighandler) == SIG_IGN)
signal(SIGHUP, SIG_IGN);
// we want QtWayland to connect to our Wayland display, but the WaylandBackend to the existing Wayland backend
// so fiddling around with the env variables.
const QByteArray systemDisplay = qgetenv("WAYLAND_DISPLAY");
qputenv("WAYLAND_DISPLAY", waylandSocket.isEmpty() ? QByteArrayLiteral("wayland-0") : waylandSocket);
qputenv("WAYLAND_SOCKET", QByteArray::number(server->createQtConnection()));
KWin::ApplicationWayland a(argc, argv);
qputenv("WAYLAND_DISPLAY", systemDisplay);
a.setupTranslator();
server->setParent(&a);
......
......@@ -102,4 +102,15 @@ int WaylandServer::createXWaylandConnection()
return sx[1];
}
int WaylandServer::createQtConnection()
{
int sx[2];
if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, sx) < 0) {
qCWarning(KWIN_CORE) << "Could not create socket";
return -1;
}
m_qtConnection = m_display->createClient(sx[0]);
return sx[1];
}
}
......@@ -66,12 +66,18 @@ public:
**/
int createXWaylandConnection();
/**
* @returns file descriptor for QtWayland
**/
int createQtConnection();
private:
KWayland::Server::Display *m_display = nullptr;
KWayland::Server::CompositorInterface *m_compositor = nullptr;
KWayland::Server::SeatInterface *m_seat = nullptr;
KWayland::Server::ShellInterface *m_shell = nullptr;
KWayland::Server::ClientConnection *m_xwaylandConnection = nullptr;
KWayland::Server::ClientConnection *m_qtConnection = nullptr;
KWIN_SINGLETON(WaylandServer)
};
......
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