diff options
author | Kristian Høgsberg <krh@bitplanet.net> | 2014-03-19 20:46:41 -0700 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2014-03-25 08:46:12 +1000 |
commit | 215f3d2e0f2a4ef6fc2f2c08fb991e1f00b747c8 (patch) | |
tree | ea64c13dbcf3d20e7ec0f0515ba64c5e09bfb1e2 /os | |
parent | 44fe1b8ea284df6bbaef67e246016d104665b2fe (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.c | 27 |
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; +} |