From eb6f8daca5dc15af321d0bcc54cd6cb8b6779257 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 30 May 2021 13:26:48 +0300 Subject: [PATCH] Xi: Work around broken libxcb that doesn't ignore unknown device classes libxcb 14.1 and older are not forwards-compatible with new device classes as it does not properly ignore unknown device classes. Since breaking libxcb would break quite a lot of applications, we instead report Gesture device class only if the client advertised support for XI 2.4. Clients may still not work in cases when a client advertises XI 2.4 support and then a completely separate module within the client uses broken libxcb to call XIQueryDevice. Signed-off-by: Povilas Kanapickas --- Xi/xiquerydevice.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Xi/xiquerydevice.c b/Xi/xiquerydevice.c index 5c6799a7c..e4731a119 100644 --- a/Xi/xiquerydevice.c +++ b/Xi/xiquerydevice.c @@ -43,6 +43,9 @@ #include "xace.h" #include "inpututils.h" +#include "exglobals.h" +#include "privates.h" + #include "xiquerydevice.h" static Bool ShouldSkipDevice(ClientPtr client, int deviceid, DeviceIntPtr d); @@ -467,6 +470,22 @@ SwapTouchInfo(DeviceIntPtr dev, xXITouchInfo * touch) swaps(&touch->sourceid); } +static Bool ShouldListGestureInfo(ClientPtr client) +{ + /* libxcb 14.1 and older are not forwards-compatible with new device classes as it does not + * properly ignore unknown device classes. Since breaking libxcb would break quite a lot of + * applications, we instead report Gesture device class only if the client advertised support + * for XI 2.4. Clients may still not work in cases when a client advertises XI 2.4 support + * and then a completely separate module within the client uses broken libxcb to call + * XIQueryDevice. + */ + XIClientPtr pXIClient = dixLookupPrivate(&client->devPrivates, XIClientPrivateKey); + if (pXIClient->major_version) { + return version_compare(pXIClient->major_version, pXIClient->minor_version, 2, 4) >= 0; + } + return FALSE; +} + /** * List gesture information * @@ -594,7 +613,7 @@ ListDeviceClasses(ClientPtr client, DeviceIntPtr dev, total_len += len; } - if (dev->gesture) { + if (dev->gesture && ShouldListGestureInfo(client)) { (*nclasses)++; len = ListGestureInfo(dev, (xXIGestureInfo *) any); any += len;