XNextEvent(3)
π
XNextEvent(3) π
okay so bestie, welcome to XLIB FUNCTIONS. this page is literally the group chat for selecting events by type, and the whole squad is XNextEvent, XPeekEvent, XWindowEvent, XCheckWindowEvent, XMaskEvent, XCheckMaskEvent, XCheckTypedEvent, and XCheckTypedWindowEvent. periodt. β¨
πΈ NAME πΈ
XNextEvent, XPeekEvent, XWindowEvent, XCheckWindowEvent, XMaskEvent, XCheckMaskEvent, XCheckTypedEvent, XCheckTypedWindowEvent β select events by type. iykyk π
π SYNTAX π
here's the exact tea, signatures and all β no edits, no cap:
int XNextEvent(Display *display, XEvent *event_return);
int XPeekEvent(Display *display, XEvent *event_return);
int XWindowEvent(Display *display, Window w, long event_mask, XEvent
*event_return);
Bool XCheckWindowEvent(Display *display, Window w, long event_mask,
XEvent *event_return);
int XMaskEvent(Display *display, long event_mask, XEvent *event_return);
Bool XCheckMaskEvent(Display *display, long event_mask, XEvent
*event_return);
Bool XCheckTypedEvent(Display *display, int event_type, XEvent
*event_return);
Bool XCheckTypedWindowEvent(Display *display, Window w, int event_type,
XEvent *event_return);
π ARGUMENTS π
the original lists event_return three whole times because different functions describe it differently, so we're keeping all three. not me being extra, it's just the facts π
displayβ Specifies the connection to the X server.event_maskβ Specifies the event mask.event_returnβ Returns the matched event's associated structure.event_returnβ Returns the next event in the queue.event_returnβ Returns a copy of the matched event's associated structure.event_typeβ Specifies the event type to be compared.wβ Specifies the window whose event you are interested in.
π¦ DESCRIPTION π¦
okay so here's the rundown, function by function, main-character energy only β¨
XNextEvent copies the first event from the event queue into the specified XEvent structure, then removes it from the queue. if the event queue is empty, XNextEvent flushes the output buffer and blocks until an event is received. patient queen behavior β³
XPeekEvent returns the first event from the event queue, but it does not remove the event from the queue. if the queue is empty, XPeekEvent flushes the output buffer and blocks until an event is received. it then copies the event into the client-supplied XEvent structure without removing it from the event queue. look but don't touch, iconic π
XWindowEvent searches the event queue for an event that matches both the specified window and event mask. when it finds a match, XWindowEvent removes that event from the queue and copies it into the specified XEvent structure. the other events stored in the queue are not discarded. if a matching event is not in the queue, XWindowEvent flushes the output buffer and blocks until one is received. π«Ά
XCheckWindowEvent searches the event queue and then the events available on the server connection for the first event that matches the specified window and event mask. if it finds a match, XCheckWindowEvent removes that event, copies it into the specified XEvent structure, and returns True. the other events stored in the queue are not discarded. if the event you requested is not available, XCheckWindowEvent returns False, and the output buffer will have been flushed. no waiting around, just vibes π¨
XMaskEvent searches the event queue for the events associated with the specified mask. when it finds a match, XMaskEvent removes that event and copies it into the specified XEvent structure. the other events stored in the queue are not discarded. if the event you requested is not in the queue, XMaskEvent flushes the output buffer and blocks until one is received. mask on, match found π
XCheckMaskEvent searches the event queue and then any events available on the server connection for the first event that matches the specified mask. if it finds a match, XCheckMaskEvent removes that event, copies it into the specified XEvent structure, and returns True. the other events stored in the queue are not discarded. if the event you requested is not available, XCheckMaskEvent returns False, and the output buffer will have been flushed. checking first, blocking never π§
XCheckTypedEvent searches the event queue and then any events available on the server connection for the first event that matches the specified type. if it finds a match, XCheckTypedEvent removes that event, copies it into the specified XEvent structure, and returns True. the other events in the queue are not discarded. if the event is not available, XCheckTypedEvent returns False, and the output buffer will have been flushed. type match? found it. type mismatch? moving on π₯
XCheckTypedWindowEvent searches the event queue and then any events available on the server connection for the first event that matches the specified type and window. if it finds a match, XCheckTypedWindowEvent removes the event from the queue, copies it into the specified XEvent structure, and returns True. the other events in the queue are not discarded. if the event is not available, XCheckTypedWindowEvent returns False, and the output buffer will have been flushed. type + window combo? that's the one π
π SEE ALSO π
go check these besties too: XAnyEvent(3), XIfEvent(3), XPutBackEvent(3), XSendEvent(3).
and the big one: Xlib - C Language X Interface π«Ά
mwah π that's the whole page. it's from X Version 11, libX11 1.8.14, and the page title is XNextEvent(3). slay, go handle your event queue π
π¦ 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