XISELECTEVENTS(3)
π XISELECTEVENTS π
okay bestie, sit down, hydrate, and let me tell you about XISelectEvents and XIGetSelectedEvents β they're the girlies that let you select for or get selected XI2 events on a window. yes, this is a section 3 (library functions) situation, and yes, we're gonna get through it together. π«Ά
β¨ NAME β¨
XISelectEvents, XIGetSelectedEvents β select for or get selected XI2 events on the window. that's the whole vibe. that's the mission statement. π
πΈ SYNOPSIS πΈ
#include <X11/extensions/XInput2.h>
Status XISelectEvents( Display *display,
Window win,
XIEventMask *masks,
int num_masks);
display β Specifies the connection to the X server. (your link to the mothership, no cap)
masks β Device event mask.
num_masks β Number of masks in masks.
win β Specifies the window.
XIEventMask *XIGetSelectedEvents( Display *display,
Window win,
int *num_masks_return);
display</purl> β Specifies the connection to the X server.
num_masks_return β Number of masks in the return value.
win β Specifies the window.
ngl the two functions share three arg names and it's giving twin energy π― but they are NOT the same function, don't mix them up.
π¦ DESCRIPTION π¦
okay so, the β¨loreβ¨:
XI2 events must be selected using XISelectEvents. that's not optional, that's the whole entrance exam. π₯
XISelectEvents sets the event mask for this client on win. Further events are only reported to this client if the event type matches the selected event mask. The masks overrides the previously selected event mask for the given device. (yes β overrides, like when your old hyperfixation gets replaced by a new one. gone. replaced. no notes.)
If deviceid is a valid device, the event mask is selected only for this device. If deviceid is XIAllDevices or XIAllMasterDevices, the event mask is selected for all devices or all master devices, respectively. The effective event mask is the bit-wise OR of the XIAllDevices, XIAllMasterDevices and the respective device's event mask.
and now, the moment you've been waiting for, the struct reveal π:
typedef struct {
int deviceid;
int mask_len;
unsigned char* mask;
} XIEventMask;
The mask_len specifies the length of mask in bytes. mask is a binary mask in the form of (1 << event type). deviceid must be either a device or XIAllDevices or XIAllMasterDevices. A client may submit several masks with the same deviceid in one request but only the last mask will be effective.
π¨ bestie listen: only the last mask will be effective if you send several with the same deviceid. the earlier ones are getting ghosted. if that's not what you want, don't do it. periodt.
XISelectEvents can generate a BadValue, a BadDevice, and a BadWindow error.
π XIGetSelectedEvents β the reading era π
XIGetSelectedEvents returns the events selected by this client on the given window. If no events were selected on this window, XIGetSelectedEvents returns NULL and num_masks_return is set to 0. If an internal error occurs, XIGetSelectedEvents returns NULL and num_masks_return is set to -1. Otherwise, XIGetSelectedEvent returns the selected event masks for all devices including the masks for XIAllDevices and XIAllMasterDevices
β οΈ okay soNULL+0andNULL+-1are two completely different moods. one is "nothing selected, all chill π", the other is "internal error, something is wrong π". checknum_masks_return, always, fr fr.
The caller must free the returned data using XFree().
π not me reminding you again: free it with XFree(). the returned data is yours to clean up, it's not going to tidy itself. main character energy includes memory hygiene, iykyk.
π DIAGNOSTICS π
BadValueβ A value is outside of the permitted range.BadWindowβ A value for a Window argument does not name a defined window.BadDeviceβ An invalid device was specified. The device does not exist.
and that's the whole page, bestie β every option, every field, every error, nothing skipped, nothing invented. ate and left no crumbs. π β¨
this was XISELECTEVENTS(3) from the XISELECTEVENTS(3) manual, dated 05/18/2026 β shoutout to the source and version for keeping it iconic. mwah. ππ¦
π¦ where this page comes from
- fedora 44: libXi-devel 1.8.3-1.fc44 Β· MIT-open-group AND SMLNJ AND MIT
- fedora 44: libXi-devel 1.8.3-1.fc44 Β· MIT-open-group AND SMLNJ AND MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms