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