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>
This commit is contained in:
Kristian Høgsberg 2014-03-19 20:46:41 -07:00 committed by Peter Hutterer
parent 44fe1b8ea2
commit 215f3d2e0f
2 changed files with 29 additions and 0 deletions

View File

@ -168,6 +168,8 @@ extern _X_EXPORT void MakeClientGrabPervious(ClientPtr /*client */ );
extern _X_EXPORT void ListenOnOpenFD(int /* fd */ , int /* noxauth */ );
extern _X_EXPORT Bool AddClientOnOpenFD(int /* fd */ );
extern _X_EXPORT CARD32 GetTimeInMillis(void);
extern _X_EXPORT CARD64 GetTimeInMicros(void);

View File

@ -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;
}