IT lexicon › Programming › Event mask (X11)

Event mask (X11)

Programming På svenska → Updated: 2026-10-08

The bitmask each X client sets per window to say which events the server should send — keys, mouse buttons, exposure, resizes — and which therefore decides what the program gets to know at all.

The X server sends nothing unasked. When a window is created, or later through XSelectInput in Xlib, the client supplies a mask with bits such as KeyPressMask, ButtonPressMask, ExposureMask, PointerMotionMask and StructureNotifyMask. Only matching events are delivered. Several clients may select events on the same window and the server keeps one mask per client, with three exceptions that only one client at a time may own: ButtonPress, ResizeRedirect and SubstructureRedirect. The last is the window manager's key to power, and it is why only one window manager can run at once.

Key and button events nobody selected on a window propagate up the window tree until some ancestor has asked for them, or until a window's do_not_propagate_mask stops them. That lets an application listen on its top-level window and still receive clicks from its children. PointerMotionHintMask exists for programs that want to know the mouse moved without drowning in coordinates. An event that never arrives because the mask lacks the bit is the classic beginner's mistake in Xlib code, and xev is the tool that shows what actually gets through.

← Back to the lexicon