XAddConnectionWatch(3)
π NAME π
okay bestie, welcome to the XAddConnectionWatch(3) page π
this one is all about handling Xlib internal connections, and the whole squad is here:
XAddConnectionWatchXRemoveConnectionWatchXProcessInternalConnectionXInternalConnectionNumbers
they all deal with Xlib internal connections. periodt β¨
β¨ SYNTAX β¨
typedef void (*XConnectionWatchProc)(Display *display, XPointer
client_data, int fd, Bool opening, XPointer *watch_data);
Status XAddConnectionWatch(Display *display, XConnectionWatchProc
procedure, XPointer client_data);
void XRemoveConnectionWatch(Display *display, XConnectionWatchProc
procedure, XPointer client_data);
void XProcessInternalConnection(Display *display, int fd);
Status XInternalConnectionNumbers(Display *display, int **fd_return, int
*count_return);
π ARGUMENTS π
client_dataβ specifies the additional client data. it's your little extra info stash π«Άcount_returnβ returns the number of file descriptors. yes, a count, returned through this pointer πdisplayβ specifies the connection to the X server. the main character connection πfdβ specifies the file descriptor. literally the fd in question πfd_returnβ returns the file descriptors. this is where the fd list comes back πΈprocedureβ specifies the procedure to be called. the callback cutie π¦
π¦ DESCRIPTION π¦
so, the XAddConnectionWatch function registers a procedure to be called every single time Xlib opens or closes an internal connection for the specified display π« the procedure gets passed the display, the specified client_data, the file descriptor for the connection, a Boolean indicating whether the connection is being opened or closed, and a pointer to a location for private watch data.
if opening is True, the procedure can store a pointer to private data in the location pointed to by watch_data; when the procedure is later called for this same connection and opening is False, the location pointed to by watch_data will hold this same private data pointer. iykyk β that's your little continuity trick β¨
this function can be called at any time after a display is opened. if internal connections already exist, the registered procedure will immediately be called for each of them, before XAddConnectionWatch returns. XAddConnectionWatch returns a nonzero status if the procedure is successfully registered; otherwise, it returns zero. okay so nonzero = slayed, zero = nope π
β οΈ the registered procedure should not call any Xlib functions. if the procedure directly or indirectly causes the state of internal connections or watch procedures to change, the result is not defined. no cap, that's the danger zone π
β οΈ if Xlib has been initialized for threads, the procedure is called with the display locked, and the result of a call by the procedure to any Xlib function that locks the display is not defined unless the executing thread has externally locked the display using XLockDisplay. this is the thread-lore you need to keep close π§
the XRemoveConnectionWatch function removes a previously registered connection watch procedure. the client_data must match the client_data used when the procedure was initially registered. match it exactly, bestie π―
the XProcessInternalConnection function processes input available on an internal connection. this function should be called for an internal connection only after an operating system facility (for example, select or poll) has indicated that input is available; otherwise, the effect is not defined. like, do not freestyle this one π«Ά
the XInternalConnectionNumbers function returns a list of the file descriptors for all internal connections currently open for the specified display. when the allocated list is no longer needed, free it by using XFree. this function returns a nonzero status if the list is successfully allocated; otherwise, it returns zero. so yes, you gotta clean up after yourself, iconic behavior π
π SEE ALSO π
Xlib - C Language X Interface
okay that's the whole page, mwah π stay hydrated, lock your displays, and remember the footer vibes: X Version 11, libX11 1.8.14, page XAddConnectionWatch(3) πβ¨
π¦ where this page comes from
- alpine 3.24: libx11-doc 1.8.14-r0 Β· X11
- arch rolling: libx11 1.8.14-1 Β· MIT AND X11
- nixos 26.05: libx11 1.8.14
- nixpkgs unstable: libx11 1.8.14
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms