IT lexicon › Programming › FocusIn and FocusOut

FocusIn and FocusOut

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

The pair of events the X server sends when keyboard focus moves from one window to another — technically precise, and for that very reason almost impossible to interpret correctly.

Focus is set with XSetInputFocus, usually by the window manager, and every window that selected FocusChangeMask and is touched by the move gets a FocusOut or FocusIn. Simple enough until you read the fields. mode separates ordinary changes from those caused by a keyboard grab starting or ending (NotifyGrab, NotifyUngrab, NotifyWhileGrabbed). detail has eight values — NotifyAncestor, NotifyVirtual, NotifyInferior, NotifyNonlinear, NotifyNonlinearVirtual, NotifyPointer, NotifyPointerRoot and NotifyDetailNone — describing where in the window tree focus came from and where it went.

The spec spends pages on which windows receive which combination. Most programs read the event type, ignore the NotifyPointer cases and hope. The result is the classic X bug of a cursor blinking in two windows at once, or in none.

← Back to the lexicon