xcb_send_event(3)
π NAME π
xcb_send_event β bestie, it literally sends an event β¨
So you're in the xcb_send_event(3) era of your life, and the manual is called XCB Requests. Buckle up, we're sending events π
β¨ SYNOPSIS β¨
#include <xcb/xproto.h>
π¦ Request function π¦
xcb_void_cookie_t xcb_send_event(xcb_connection_t *conn,
uint8_t propagate, xcb_window_t destination, uint32_t event_mask,
const char *event);
π«Ά REQUEST ARGUMENTS π«Ά
connβ the XCB connection to X11. your link to the whole vibe, no cap.propagateβ okay so ifpropagateis true and literally no clients have selected any event ondestination, thendestinationgets replaced with the closest ancestor ofdestinationfor which some client has selected a type inevent_maskand for which no intervening window has that type in its do-not-propagate-mask. (iconic behaviour honestly.) And if no such window exists, or if the window is an ancestor of the focus window andInputFocuswas originally specified as the destination, then the event is not sent to any clients at all π. Otherwise, the event is reported to every client selecting on the final destination any of the types specified inevent_mask. periodt.destinationβ the window to send this event to π. Every client which selects any event withinevent_maskondestinationwill get the event.
The special value XCB_SEND_EVENT_DEST_POINTER_WINDOW refers to the window that contains the mouse pointer π±οΈβ¨
The special value XCB_SEND_EVENT_DEST_ITEM_FOCUS refers to the window which has the keyboard focus β¨οΈπ
event_maskβ event_mask for determining which clients should receive the specified event. Seedestinationandpropagateabove, bestie π«Άeventβ the event to send to the specified destination. it's giving delivery service fr fr π¦
π DESCRIPTION π
So what this does is identify the destination window, figure out which clients should receive the specified event, and ignore any active grabs. yes ma'am, grabs don't matter here π
The event must be one of the core events or an event defined by an extension, so that the X server can correctly byte-swap the contents as necessary. Like, it's not optional, that's the rule π₯ The contents of event are otherwise unaltered and unchecked β except for the send_event field, which is forced to 'true'. The library does that part for you, no takebacks πΈ
π RETURN VALUE π
Returns an xcb_void_cookie_t. Errors (if any) have to be handled in the event loop, so don't come crying to the return value, she doesn't know anything π
If you want to handle errors directly with xcb_request_check instead, use xcb_send_event_checked. See xcb-requests(3) for details β¨
π ERRORS π
xcb_value_error_tβ the given event is neither a core event nor an event defined by an extension. rude of you honestly πxcb_window_error_tβ the specified destination window does not exist. it's not there. it left. ghosted π
πΈ EXAMPLE πΈ
/*
* Tell the given window that it was configured to a size of 800x600 pixels.
*
*/
void my_example(xcb_connection_t *conn, xcb_window_t window) {
/* Every X11 event is 32 bytes long. Therefore, XCB will copy 32 bytes.
* In order to properly initialize these bytes, we allocate 32 bytes even
* though we only need less for an xcb_configure_notify_event_t */
xcb_configure_notify_event_t *event = calloc(32, 1);
event->event = window;
event->window = window;
event->response_type = XCB_CONFIGURE_NOTIFY;
event->x = 0;
event->y = 0;
event->width = 800;
event->height = 600;
event->border_width = 0;
event->above_sibling = XCB_NONE;
event->override_redirect = false;
xcb_send_event(conn, false, window, XCB_EVENT_MASK_STRUCTURE_NOTIFY,
(char*)event);
xcb_flush(conn);
free(event);
}
note the calloc(32, 1) bestie β every X11 event is 32 bytes long, so XCB is gonna copy 32 bytes whether you like it or not. we allocate all 32 to keep those bytes properly initialized even though xcb_configure_notify_event_t needs less π and yes, free(event) at the end. memory hygiene is main character energy π§
π SEE ALSO π
xcb-requests(3), xcb-examples(3), xcb_configure_notify_event_t(3)
go read them, iykyk π
π AUTHOR π
Generated from xproto.xml. Contact xcb@lists.freedesktop.org for corrections and improvements β they're literally taking notes, so tell them if something's off π«Ά
and that's the whole page, bestie!! this one shipped as part of X Version 11, libxcb 1.17.0, and yes the page you just read is literally called xcb_send_event(3) π
slay, now go send some events πβ¨π
π¦ where this page comes from
- alpine 3.22: libxcb-doc 1.17.0-r0 Β· MIT
- alpine 3.23: libxcb-doc 1.17.0-r1 Β· MIT
- alpine 3.24: libxcb-doc 1.17.0-r2 Β· MIT
- arch rolling: libxcb 1.17.0-1 Β· X11
- centos-stream 10: libxcb-devel 1.17.0-3.el10 Β· X11
- debian trixie: libxcb-doc 1.17.0-2
- fedora 43: libxcb-devel 1.17.0-6.fc43 Β· X11
- fedora 43: libxcb-devel 1.17.0-6.fc43 Β· X11
- fedora 44: libxcb-devel 1.17.0-7.fc44 Β· X11
- fedora 44: libxcb-devel 1.17.0-7.fc44 Β· X11
- nixpkgs unstable: libxcb 1.17.0
- opensuse-leap 16.0: libxcb-devel-doc 1.17.0-160000.2.2 Β· MIT
- ubuntu questing: libxcb-doc 1.17.0-2build1
- ubuntu resolute: libxcb-doc 1.17.0-2ubuntu1
- ubuntu stonking: libxcb-doc 1.17.0-2ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms