querying current mouse state

Martin Flöser mgraesslin at kde.org
Sun Aug 6 15:19:59 UTC 2017


Am 2017-08-05 17:23, schrieb René J. V.  Bertin:
> David Edmundson wrote:
> 
>> In wayland you never query anything, only track events.
> 
> There are applications for which this isn't good enough but I guess 
> there must
> be other, low-level ways to query the current state of a given input 
> device or
> sensor.

Short answer: no there isn't. Even libinput does not provide the state 
of the buttons, but just sends the press events. I'm pretty sure that 
not even the kernel knows it, otherwise libinput would expose it.

> 
>> What actually do you want to do?
> 
> I'm toying around with a click-and-hold-opens-the-contextmenu feature 
> (ported
> from Mac where this makes a bit more sense), based on the TapAndHold
> gesture. It
> looks like that event is good demonstration why event tracking isn't 
> 100%
> reliable. When I activate processing of that gesture on a QToolButton 
> with a
> menu, it finishes (triggers) even when I am not holding any mouse 
> button. The
> event filter in which I implement this feature also catches 
> MouseRelease and
> MouseMove events (to turn off the gesture processing); I'm not getting 
> those
> either when the QToolButton's menu is open.
> 
> IOW, when I click once on the button to open its menu, the contextmenu
> is opened
> too after the expected delay. The only reliable way I found to prevent 
> this is
> to check if the mouse button is still pressed when the TapAndHold
> gesture claims
> to be finished.

For Wayland you can use the KWayland Client library to low level listen 
to the button press/release events. Example code for how to do this is 
in breeze kstyle for manual moving of the window.

Cheers
Martin


More information about the Plasma-devel mailing list