Bug 94487 - XIGrabButton stops working after open and closing Wacom pad device
Summary: XIGrabButton stops working after open and closing Wacom pad device
Status: RESOLVED NOTOURBUG
Alias: None
Product: xorg
Classification: Unclassified
Component: Input/wacom (show other bugs)
Version: unspecified
Hardware: Other All
: medium major
Assignee: Xorg Project Team
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-11 09:38 UTC by Bastien Nocera
Modified: 2016-03-16 12:29 UTC (History)
4 users (show)

See Also:
i915 platform:
i915 features:


Attachments
foo.c (3.62 KB, text/plain)
2016-03-11 09:38 UTC, Bastien Nocera
no flags Details
mouse, common: Fix Wacom buttons not receiving events (12.68 KB, patch)
2016-03-16 12:27 UTC, Bastien Nocera
no flags Details | Splinter Review

Description Bastien Nocera 2016-03-11 09:38:48 UTC
Created attachment 122218 [details]
foo.c

xorg-x11-drv-wacom-0.30.0-3.fc23.x86_64

With the test case included, you'll receive the pad events correctly, but after opening and closing the device (in the "#if 0") you'll stop receiving events.
Comment 1 Bastien Nocera 2016-03-11 09:39:31 UTC
Original GNOME bug:
https://bugzilla.gnome.org/show_bug.cgi?id=763092
Comment 2 Peter Hutterer 2016-03-14 01:25:30 UTC
Confirmed but after a check of the code this looks to be correct behaviour. From the man page:

           When a client makes an XCloseDevice request, any active grabs
           that the client has on the device are released. Any event
           selections that the client has are deleted, as well as any
           passive grabs. If the requesting client is the last client
           accessing the device, the server may disable all access by X to
           the device.

I admit, the crossover between XI1 and XI2 is what's a bit confusing here though and makes this behaviour non-obvious.
Comment 3 Bastien Nocera 2016-03-14 10:04:35 UTC
(In reply to Peter Hutterer from comment #2)
> Confirmed but after a check of the code this looks to be correct behaviour.
> From the man page:
> 
>            When a client makes an XCloseDevice request, any active grabs
>            that the client has on the device are released. Any event
>            selections that the client has are deleted, as well as any
>            passive grabs. If the requesting client is the last client
>            accessing the device, the server may disable all access by X to
>            the device.
> 
> I admit, the crossover between XI1 and XI2 is what's a bit confusing here
> though and makes this behaviour non-obvious.

It's really not the XI1/XI2 cross-over that makes it weird for me, it's the fact that XIGrabButton() doesn't require opening the device, but will be cancelled if the device is closed for another reason.

What would be the work-around? Open the device before XIGrabButton() and close it when ungrabbing (in case another part of g-s-d keeps the device opened)? Find a way to check properties without opening the device?
Comment 4 Bastien Nocera 2016-03-16 12:06:43 UTC
(In reply to Bastien Nocera from comment #3)
<snip>
> What would be the work-around? Open the device before XIGrabButton() and
> close it when ungrabbing (in case another part of g-s-d keeps the device
> opened)?

That doesn't work, it ungrabs as soon as you close one of the handles.

> Find a way to check properties without opening the device?

XIGetProperty() looks like a good way to do it, and that's already the way we check for libinput drivers.
Comment 5 Bastien Nocera 2016-03-16 12:27:43 UTC
Created attachment 122345 [details] [review]
mouse, common: Fix Wacom buttons not receiving events

When configuring mice and touchpads, we might stumble upon a Wacom pad
device. To check whether it's a synaptics device, we open the device,
get the properties, and close it back up.

But when we close it, we end up releasing whatever grab the wacom plugin
might have had on the pad buttons:

           When a client makes an XCloseDevice request, any active grabs
           that the client has on the device are released.  Any event
           selections that the client has are deleted, as well as any
           passive grabs. If the requesting client is the last client
           accessing the device, the server may disable all access by X to
           the device.

As we cannot change that behaviour, we'll use a call that doesn't
require opening the device so we don't have to close it.
Comment 6 Bastien Nocera 2016-03-16 12:29:50 UTC
Comment on attachment 122345 [details] [review]
mouse, common: Fix Wacom buttons not receiving events

Sorry, wrong bug tracker.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.