XIfEvent(3)
π XIfEvent(3) β event queue check with a predicate, bestie β¨
okay so this page is from XLIB FUNCTIONS, and itβs all about XIfEvent, XCheckIfEvent, and XPeekIfEvent β three functions with main-character energy for checking the event queue with a predicate procedure. no cap. π«Ά
πΈ NAME πΈ
XIfEvent, XCheckIfEvent, XPeekIfEvent β check the event queue with a predicate procedure. periodt. π
β¨ SYNTAX β¨
int XIfEvent(Display *display, XEvent *event_return, Bool
(*predicate)(), XPointer arg);
Bool XCheckIfEvent(Display *display, XEvent *event_return, Bool
(*predicate)(), XPointer arg);
int XPeekIfEvent(Display *display, XEvent *event_return, Bool
(*predicate)(), XPointer arg);
π ARGUMENTS π
argβ this is the user-supplied argument that gets passed to the predicate procedure. iykyk.displayβ the connection to the X server. iconic, essential, we love her. πevent_returnβ returns either a copy of, or the matched eventβs associated structure. yes bestie, itβs giving βhereβs your event.β πpredicateβ the procedure that gets called to decide if the next event in the queue matches what you want. vibe check: event edition. π₯
π DESCRIPTION π
okay so XIfEvent completes only when the specified predicate procedure returns True for an event, which means an event in the queue matches. XIfEvent flushes the output buffer if it blocks waiting for additional events. then it removes the matching event from the queue and copies the structure into the client-supplied XEvent structure. slay. β¨
when the predicate procedure finds a match, XCheckIfEvent copies the matched event into the client-supplied XEvent structure and returns True. (this event is removed from the queue.) if the predicate procedure finds no match, XCheckIfEvent returns False, and the output buffer will have been flushed. and listen β all earlier events stored in the queue are not discarded. they stay. periodt. π
XPeekIfEvent returns only when the specified predicate procedure returns True for an event. after the predicate procedure finds a match, XPeekIfEvent copies the matched event into the client-supplied XEvent structure without removing the event from the queue. XPeekIfEvent flushes the output buffer if it blocks waiting for additional events. peek but donβt yeet. ππ
each of these functions requires you to pass a predicate procedure that determines if an event matches what you want. your predicate procedure must decide if the event is useful without calling any Xlib functions. if the predicate directly or indirectly causes the state of the event queue to change, the result is not defined. not me warning you dramatically, itβs just facts. π
if Xlib has been initialized for threads, the predicate is called with the display locked, and the result of a call by the predicate to any Xlib function that locks the display is not defined unless the caller has first called XLockDisplay. bestie, thatβs a big lock-energy caveat. ππ
the predicate procedure and its associated arguments are:
Bool (*predicate)(Display *display, XEvent *event, XPointer arg)
displayβ specifies the connection to the X server. yes, again, sheβs everywhere. πeventβ specifies theXEventstructure. the event in question, the moment, the main character. βargβ specifies the argument passed in from theXIfEvent,XCheckIfEvent, orXPeekIfEventfunction. π«Ά
the predicate procedure is called once for each event in the queue until it finds a match. after finding a match, the predicate procedure must return True. if it did not find a match, it must return False. no cap, those are the rules. π
note that the predicate procedure is called with the display locked, and thus is not allowed to call any function that would take the display lock again. π¨
π¦ SEE ALSO π¦
XAnyEvent(3),XNextEvent(3),XPutBackEvent(3)XSendEvent(3)Xlib - C Language X Interface
π footer tea, served fresh: X Version 11, libX11 1.8.14 β source/version noted, bestie. slay and goodbye π«Άβ¨
π¦ 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