An Introduction to Relative and Constrained Pointers in Enlightenment

Recent development in Enlightenment’s Wayland compositor has focused on implementing cross-desktop protocols and improving stability. One of the recently handled protocol series has been relative and constrained pointers.

Relative pointer motion is a method for providing pointer movement deltas directly to applications. This is useful for a number of cases, though the easiest to imagine might be first person shooter games. In this case, the application receives movement deltas, allowing the player to endlessly scroll the screen in one direction without hitting the boundaries of the screen.

Under Enlightenment, this is handled in different ways depending on the output backend being used. For backends using libinput, e.g., DRM, it’s possible to get relative motion deltas directly from the events and then emit them for compositor use. Other backends, however, such as nested Wayland compositors, have no access to libinput’s hardware events. In this case, Enlightenment must manually calculate the deltas between motion events to pass to applications. This case is less precise, but for the case where there is no device directly attached to the compositor then there is no other method of getting relative motion data. In this way, all backends can now supply relative motion events when requested.

Pointer Confinement and Locking in Wayland

The pointer constraints protocol under Wayland consists of two separate concepts: pointer confinement and pointer locking. Pointer confinement, in this case, is where the pointer’s position is confined to a number of specified regions. Once confined, the pointer is unable to leave the specified region until the application releases the confinement or the compositor policy results in the confinement being released. Pointer locking, on the other hand, is when the pointer’s position is locked to a specific location, preventing motion events from being propagated to the client. A locked pointer similarly will not be unlocked either until the client releases the lock or the compositor policy requires the lock to end.

Confined pointers are implemented in Enlightenment primarily using calculation of motion deltas in relation to the confinement regions. By converting the deltas into simple linear equations, it becomes easy to determine whether the delta has occurred within the confined region as well as whether the pointer motion terminated within the confined region. If the motion would result in the pointer leaving the confined region, substitution into the equation allows for the calculation of the closest point to the end of the allowed confinement region, letting the pointer be confined as close to the hardware pointer position as possible.

An Introduction to Relative and Constrained Pointers in Enlightenment - confine

Locked pointers are perhaps the simplest to implement in any compositor: simply stop providing motion events to the pointer-focused surface once the lock begins.

All of these protocols are now implemented in Enlightenment as well as a number of other Wayland compositors, allowing for desktop applications to begin using the functionalities within the protocol.

Author: Mike Blumenkrantz

Mike is the release manager for Enlightenment as well as a core developer of the EFL toolkit.