XSELECTEXTENSIONEVEN(3)

πŸ’– XSELECTEXTENSIONEVEN(3) πŸ’–

okay bestie, welcome to the XSELECTEXTENSIONEVEN(3) page, aka the manual for XSelectExtensionEvent and XGetSelectedExtensionEvents β€” yes it's the X Input extension, yes it's giving old-school X11, and yes we're gonna get through it together 🫢

NAME

XSelectExtensionEvent, XGetSelectedExtensionEvents β€” select extension events, get the list of currently selected extension events. that's it, that's the whole vibe ✨


🌈 SYNOPSIS 🌈

first things first, you gotta pull in the header, no skipping:

#include <X11/extensions/XInput.h>

then the two functions, looking all main-character:

XSelectExtensionEvent( Display *display,
                       Window w,
                       XEventClass *event_list,
                       int event_count);

XGetSelectedExtensionEvents( Display *display,
                             Window w,
                             int *this_client_event_count_return,
                             XEventClass **this_client_event_list_return,
                             int *all_clients_event_count_return,
                             XEventClass **all_clients_event_list_return);

πŸŽ€ the args, explained πŸŽ€

  • display β€” the connection to the X server. your link to the mothership fr fr πŸ’…
  • w β€” the window whose events you are interested in. the one you're obsessed with, basically πŸ‘‘
  • event_list β€” the list of event classes that describe the events you are interested in. like your saved-for-later, but for events ✨
  • event_count β€” the count of event classes in the event list. math time, but make it cute πŸŽ€
  • this_client_event_count_return β€” returns the count of event classes selected by this client. that's you, bestie πŸ’–
  • this_client_event_list_return β€” returns a pointer to the list of event classes selected by this client. pointer, so you better XFree it later, iykyk πŸ™ˆ
  • all_clients_event_count_return β€” returns the count of event classes selected by all clients. the whole group chat 🌸
  • all_clients_event_list_return β€” returns a pointer to the list of event classes selected by all clients. again, pointer, again, free it πŸ’€

✨ DESCRIPTION ✨

the XSelectExtensionEvent request causes the X server to report the events associated with the specified list of event classes. initially, X will not report any of these events β€” no cap, you have to ask. events are reported relative to a window. if a window is not interested in a device event, it usually propagates to the closest ancestor that is interested, unless the do_not_propagate mask prohibits it. so like, the event goes looking for someone who cares, and if the mask blocks it, it just... doesn't πŸ¦‹

multiple clients can select for the same events on the same window, but with these restrictions, bestie, listen up:

  • multiple clients can select events on the same window because their event masks are disjoint. when the X server generates an event, it reports it to all interested clients. sharing is caring πŸ’ž
  • only one client at a time can select a DeviceButtonPress event with automatic passive grabbing enabled, which is associated with the event class DeviceButtonPressGrab. to receive DeviceButtonPress events without automatic passive grabbing, use event class DeviceButtonPress but do not specify event class DeviceButtonPressGrab. one at a time, bestie, no fighting 😭

the server reports the event to all interested clients. periodt.

information contained in the XDevice structure returned by XOpenDevice is used by macros to obtain the event classes that clients use in making XSelectExtensionEvent requests. currently defined macros include DeviceKeyPress, DeviceKeyRelease, DeviceButtonPress, DeviceButtonRelease, DeviceMotionNotify, DeviceFocusIn, DeviceFocusOut, ProximityIn, ProximityOut, DeviceStateNotify, DeviceMappingNotify, ChangeDeviceNotify, DevicePointerMotionHint, DeviceButton1Motion, DeviceButton2Motion, DeviceButton3Motion, DeviceButton4Motion, DeviceButton5Motion, DeviceButtonMotion, DeviceOwnerGrabButton, DeviceButtonPressGrab, and NoExtensionEvent. iconic lineup honestly πŸ‘‘

to obtain the proper event class for a particular device, one of the above macros is invoked using the XDevice structure for that device. for example:

DeviceKeyPress (*device, type, eventclass);

this returns the DeviceKeyPress event type and the eventclass for selecting DeviceKeyPress events from this device. slay πŸŽ€

XSelectExtensionEvent can generate a BadWindow or BadClass error. noted. 🚨

the XGetSelectedExtensionEvents request reports the extension events selected by this client and all clients for the specified window. this request returns pointers to two XEventClass arrays. one lists the input extension events selected by this client from the specified window. the other lists the event classes selected by all clients from the specified window. you should use XFree to free these two arrays. do not forget this β€” memory leaks are not the vibe πŸ’€

XGetSelectedExtensionEvents can generate a BadWindow error.


πŸ’… DIAGNOSTICS πŸ’…

  • BadWindow β€” a value for a Window argument does not name a defined window. that window does not exist, bestie, she's not real 🌸
  • BadClass β€” a value for an XEventClass is invalid. wrong class, wrong energy, rejected 😭

and that's the whole page, you ate it πŸ’– this was XSELECTEXTENSIONEVEN(3) from the X11 manual, dated 05/18/2026 β€” go forth and select those extension events, bestie, you've got this πŸ¦‹βœ¨

πŸ“¦ where this page comes from