IT lexicon › Infra & Ops › ButtonPress and ButtonRelease

ButtonPress and ButtonRelease

Infra & Ops På svenska → Updated: 2026-10-11

X11's mouse-button events, which also carry the scroll wheel ever since it was disguised as buttons 4 and 5.

The event carries the button number, modifier state, a timestamp, and the pointer position relative to both the window and the root. The core protocol assumes five buttons. When scroll wheels showed up in the late 90s there was no slot for them, so XFree86 had wheel-up and wheel-down pose as buttons 4 and 5, pressed and released in quick succession. The convention held for more than a decade, until XInput 2.1 gave smooth scrolling a channel of its own.

Two quirks set the mouse apart from the keyboard. A ButtonPress automatically starts an active grab that lasts until every button is released, so a drag that leaves the window is still reported to where it began. And only one client at a time may select ButtonPressMask on a given window; the second one gets BadAccess.

← Back to the lexicon