summaryrefslogtreecommitdiff
path: root/os
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2014-03-19 20:46:41 -0700
committerPeter Hutterer <peter.hutterer@who-t.net>2014-03-25 08:46:12 +1000
commit215f3d2e0f2a4ef6fc2f2c08fb991e1f00b747c8 (patch)
treeea64c13dbcf3d20e7ec0f0515ba64c5e09bfb1e2 /os
parent44fe1b8ea284df6bbaef67e246016d104665b2fe (diff)
os: Add AddClientOnOpenFD() to create a new client for an file descriptor
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 <krh@bitplanet.net> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'os')
-rw-r--r--os/connection.c27
1 files changed, 27 insertions, 0 deletions
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;
+}