XI2 SD grabs

Thomas Jaeger thjaeger at gmail.com
Sun Jul 26 13:35:01 PDT 2009


Peter Hutterer wrote:
> On Sun, Jul 26, 2009 at 01:20:56AM +0200, Thomas Jaeger wrote:
>> Sorry for bringing this up so late, I hadn't noticed this earlier
>> because easystroke is still causing mysterious server crashes. In commit
>> 0c0ef42292f4c910c73b308cd75d77637312da53, you removed the code that was
>> responsible for detaching slave devices when a grab was activated to
>> bring things more in line with how XI1 grabs worked.  I'd argue that the
>> old XI2 way was the right way to go about things and that sending core
>> events during XI2 grabs is less than ideal:  The point of XI2 grabs is
>> to get complete control over the device; if other clients should still
>> receive events, it would suffice to select for events.  It is very
>> difficult right now for the grabbing client to ensure that other clients
>> don't receive any core events, at least in the case of passive grabs and
>> probably inherently racy.
>>
>> I don't understand why gimp thinks it needs device grabs at all, but if
>> compatibility is an issue, I think it would be better to treat XI1 and
>> XI2 grabs differently and only detach the device for the latter.
> 
> Just to clarify, it's not actually gimp, it's GTK.
What exactly is the problem here?  gimp is the only gtk application that
I'm aware of that grabs devices.  I've noticed that the current
development version of gtk seems to get utterly confused with XI events,
but I doubt this is related to me running master in any way.

> anyway. grabs are mainly to ensure event delivery from a device is
> guaranteed to exactly one client. Up until server 1.4 this meant that if you
> had a device grabbed, no-one else would get events from this device (afaik
> anyway). Since 1.4 the behaviour has already changed. A device that sends
> core events will send core events even if it is grabbed.
What was the rationale for changing the behavior then?  The idea that a
grab prevents other clients from receiving events from this device seems
 sound to me.

> Detaching a slave device during a grab constitutes a quite significant
> change in behaviour, and perhaps unnecessary so. I reverted the change
> simply because clients have a long inertia and breaking the behaviour (even
> if the protocol doesn't specify it) is problematic.
Since XI2 is a fresh start, there's no reason why we should have to
treat XI1 and XI2 grabs the same way here, so we could have XI1 apps
continue to work while XI2 grabs do the right thing.

> Now, the question is - what is your exact use-case and can it be solved
> without detaching the devices?
Same as always: easystroke, i.e. gesture recognition.  Basically, the
user presses a button and flips the cursor around a little bit, and as a
result pretty much anything may happen: the gesture might be ignored,
the motion might be replayed, buttons might get "remapped" etc.  I had
this all working beautifully (modulo mysterious crashes that I could
never get a handle on) up until that commit.  Even with XI1-style grabs,
I could probably make things work well enough in practice (the XI1 code
is absolutely insane and basically unmaintainable, but strangely enough,
it works smoothly), but it would be very hackish and difficult to write
and maintain.

This is incidentally the only legitimate use of SD grabs that I'm aware
of, even in XI1-land gimp could have selected events instead of grabbing
the device, and with XI2 it can even do without touching SDs at all.

Tom


More information about the xorg-devel mailing list