How to learn the number of mouse buttons from Wayland?

Jonas Ådahl jadahl at redhat.com
Fri Sep 2 14:11:44 UTC 2022


On Fri, Sep 02, 2022 at 04:14:26PM +0300, Maxim Kartashev wrote:
> Java has an API that is supposed to return the number of buttons of the
> mouse - MouseInfo.getNumberOfButtons()
> <https://docs.oracle.com/javase/8/docs/api/java/awt/MouseInfo.html#getNumberOfButtons-->.
> I wonder if it's possible to learn this number from Wayland somehow? The
> protocol seems to not put any cap on the value of the button code in the
> corresponding event.

This information is currently not exposed via Wayland. What is exposed
is a single abstracted "pointer" device for all combined pointing
devices, including touchpads, traditional mouse devices, track points,
and so on.

It also doesn't expose current active global state to anyone wanting to
query it, as pointer state is sent via events in response to focus
changes or pointer movements, and are localized to surface local
coordinates for the surface that currently has pointer focus.

It appears that MouseInfo.getNumberOfButtons(), as well as
PointerInfo.getDevice() and PointerInfo.getLocation() have no existing
way to be implemented.

Note that Wayland's approach to input events make this "hard" by design,
as the intention is that clients react to abstracted high level
localized input events only when they have active focus, to avoid
leaking otherwise potentially sensitive information to clients not
currently being actively used.


Jonas



More information about the wakefield-dev mailing list