WindowAbstractions Interface

Events

A large portion of this package is dedicated to handling the events reported by the X server and interfacing them into EventDetails instances.

In order to receive events from the server, we need to tell the server which types of event we want to be reported. This is done per-window, at their instantiation, through so-called event masks. In the future, it is intended to check which event we are subscribed to with the window callbacks that are provided to an event loop.

Input events

Input events can be classified into different types:

  • Key events which are generated by pressing or releasing a key from a keyboard,
  • Mouse events originating from pressing or releasing mouse buttons,
  • Pointer events such as moving out of or entering a window with the pointer, or moving around inside the window.

Although drag actions are technically just of combination of mouse state and pointer events, they are reported as separate events.

Key events

X and XCB do not offer much keystroke-related utilities, unless we look at some extensions such as XKB, which was used here for processing key inputs. It allows the storage of keyboard and keymap states, as well as functions to translate keystrokes into characters. The input processing using XKB was inspired from the XKB tutorial.

Mouse events

It is a lot simpler to handle mouse events. Mouse state (e.g. which buttons were already pressed before the current mouse event) and pressed/released buttons are simply extracted from related X events, exposed in XCB via xcb_button_press_release_event_t and xcb_button_release_event_t.

Pointer events

Pointer events are handled similarly to mouse events. Moving the pointer in the window, as well as leaving or entering it send a X event from which the relevant data is extracted.