Tuesday, May 23, 2017

xinput list shows a "xwayland-pointer" device but not my real devices and what to do about it

TLDR: If you see devices like "xwayland-pointer" show up in your xinput list output, then you are running under a Wayland compositor and debugging/configuration with xinput will not work.

For many years, the xinput tool has been a useful tool to debug
configuration issues (it's not
a configuration UI btw). It works by listing the various devices
detected by the X server. So a typical output from xinput list under
X could look like this:

Alas, xinput is scheduled to go
the way of the dodo. More and more systems are running a Wayland session
instead of an X session, and xinput just doesn't work there. Here's an
example output from xinput list under a Wayland session:

As you can see, none of the physical devices are available, the only ones
visible are the virtual devices created by XWayland. On a Wayland session,
the X server doesn't have access to the physical devices. Instead, it talks
via the Wayland protocol to the compositor.
This image from the Wayland
documentation shows the architecture:

In the above graphic, devices are known to the Wayland compositor (1), but not to the X server.
The Wayland protocol doesn't expose physical devices, it merely provides a
'pointer' device, a 'keyboard' device and, where available, a touch and
tablet tool/pad devices (2). XWayland wraps these into virtual devices and
provides them via the X protocol (3), but they don't represent the physical
devices.

This usually doesn't matter, but when it comes to debugging or configuring devices with xinput we run into a few issues. First, configuration via xinput usually means changing driver-specific properties but in the XWayland case there is no driver involved - it's all handled by libinput inside the compositor. Second, debugging via xinput only shows what the wayland protocol sends to XWayland and what XWayland then passes on to the client. For low-level issues with devices, this is all but useless.

The takeaway here is that if you see devices like "xwayland-pointer" show up in your xinput list output, then you are running under a Wayland compositor and debugging with xinput will not work. If you're trying to configure a device, use the compositor's configuration system (e.g. gsettings). If you are debugging a device, use libinput-debug-events. Or compare the behaviour between the Wayland session and the X session to narrow down where the failure point is.