From 215f3d2e0f2a4ef6fc2f2c08fb991e1f00b747c8 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Wed, 19 Mar 2014 20:46:41 -0700 Subject: os: Add AddClientOnOpenFD() to create a new client for an file descriptor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the Xwayland server is socket-activated, we need to connect and initialize the window manager before the activating client gets to proceed with connecting. We do this by passing a socket file descriptor for the window manager connection to the Xwayland server, which then uses this new function to set it up as an X client. Signed-off-by: Kristian Høgsberg Reviewed-by: Peter Hutterer Signed-off-by: Peter Hutterer --- os/connection.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'os') diff --git a/os/connection.c b/os/connection.c index b50f9e914..b3640b8e4 100644 --- a/os/connection.c +++ b/os/connection.c @@ -1312,3 +1312,30 @@ ListenOnOpenFD(int fd, int noxauth) XdmcpReset(); #endif } + +/* based on TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status) */ +Bool +AddClientOnOpenFD(int fd) +{ + XtransConnInfo ciptr; + CARD32 connect_time; + char port[20]; + + snprintf(port, sizeof(port), ":%d", atoi(display)); + ciptr = _XSERVTransReopenCOTSServer(5, fd, port); + if (ciptr == NULL) + return FALSE; + + _XSERVTransSetOption(ciptr, TRANS_NONBLOCKING, 1); + ciptr->flags |= TRANS_NOXAUTH; + + connect_time = GetTimeInMillis(); + + if (!AllocNewConnection(ciptr, fd, connect_time)) { + ErrorConnMax(ciptr); + _XSERVTransClose(ciptr); + return FALSE; + } + + return TRUE; +} -- cgit v1.2.3