XSelectInput(3)
π XSelectInput(3) β the "hey bestie, tell the server what u care about" era
okay so this is a page from the Xlib functions manual (the XLIB FUNCTIONS girlies, iykyk) and honestly? it's giving "select input events" and we're obsessed. let's get into it fr fr.
β¨ SYNTAX β¨
int XSelectInput(Display *display, Window w, long event_mask);
no cap, that's the whole signature. three args, iconic behavior. π
πΈ ARGUMENTS πΈ
displayβ specifies the connection to the X server. literally your lil link to the whole vibe.event_maskβ specifies the event mask. like, the actual menu of things u want reported. πwβ specifies the window whose events you are interested in. yes bestie, that window.
π¦ DESCRIPTION π¦
so XSelectInput is the function that requests that the X server report the events associated with the specified event mask. periodt. u tell the server "hey, i wanna know when these things happen," and it says "bet."
initially, X will not report any of these events. like, zero. nothing. it's on silent mode until u say otherwise. π
events are reported relative to a window. real "everything is about context" energy. if a window is not interested in a device event, it usually propagates to the closest ancestor that is interested β unless the do_not_propagate mask prohibits it. so basically the event floats up the family tree until someone claims it. the way that works is so satisfying tbh. π§
setting the event-mask attribute of a window overrides any previous call for the same window but not for other clients. so like, u can change your mind, but u can't change someone else's. mind ya business respectfully. π
multiple clients can select for the same events on the same window with the following restrictions:
- multiple clients can select events on the same window because their event masks are disjoint. when the X server generates an event, it reports it to all interested clients. sharing is caring bestie. π«Ά
- only one client at a time can select
CirculateRequest,ConfigureRequest, orMapRequestevents, which are associated with the event maskSubstructureRedirectMask. exclusive access, no plus-ones. π - only one client at a time can select a
ResizeRequestevent, which is associated with the event maskResizeRedirectMask. same energy. one at a time. β - only one client at a time can select a
ButtonPressevent, which is associated with the event maskButtonPressMask. literally one. don't even try it. π
and then, the moment we've all been waiting for: the server reports the event to all interested clients. highkey the most equitable thing ever. π
also important: XSelectInput can generate a BadWindow error. so like, do a vibe check on your window handle before u call this. π₯
π DIAGNOSTICS π
BadWindowβ a value for aWindowargument does not name a definedWindow. translation: that window does not exist bestie. it's giving "you tried to text a number that blocked you." ππ
π SEE ALSO π
Xlib - C Language X Interfaceβ the classic. the blueprint. read it if u want the full lore. π
ngl the propagation + multi-client rules are lowkey the whole personality of this function. respect the boundaries, select ur events, slay. π β¨
kisses and X server blessings, this has been the libX11 1.8.14 edition of the page, dated X Version 11 β mwah, stay iconic bestie. πΈπ¦π
π¦ 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