summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPovilas Kanapickas <povilas@radix.lt>2021-05-30 13:26:48 +0300
committerPovilas Kanapickas <povilas@radix.lt>2021-05-30 13:46:59 +0300
commiteb6f8daca5dc15af321d0bcc54cd6cb8b6779257 (patch)
treef2ef2bdaaf1b4506a1027ceb80eb5a6fefb421ec
parent7e692633fb9ab8e1ed2a88c3abb4fe04144c0a80 (diff)
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 <povilas@radix.lt>
-rw-r--r--Xi/xiquerydevice.c21
1 files changed, 20 insertions, 1 deletions
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;