xcb_send_event(3)

πŸ“¦
version 1.17.0 Β· 4 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, debian trixie, fedora 43, fedora 44, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– 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 if propagate is true and literally no clients have selected any event on destination, then destination gets replaced with the closest ancestor of destination for which some client has selected a type in event_mask and 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 and InputFocus was 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 in event_mask. periodt.
  • destination β€” the window to send this event to πŸ’Œ. Every client which selects any event within event_mask on destination will 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. See destination and propagate above, 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 πŸŒˆβœ¨πŸ’–