[RFC XI 2.1 - libXi] Add multitouch support from Xi 2.1
Chase Douglas
chase.douglas at canonical.com
Fri Nov 12 14:35:14 PST 2010
Add support to libXi for all the Xi 2.1 additions to the spec:
TouchClass, TouchBegin, TouchEnd and TouchMotion, as well as touch grabs.
Based on an initial patch by Daniel Stone.
Signed-off-by: Daniel Stone <daniel at fooishbar.org>
Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
---
configure.ac | 4 +-
include/X11/extensions/XInput2.h | 19 +++++++++++++++
src/XExtInt.c | 47 +++++++++++++++++++++++++++++++++++++-
3 files changed, 67 insertions(+), 3 deletions(-)
diff --git a/configure.ac b/configure.ac
index 2f773f9..b5a28e1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@ dnl Process this file with autoconf to create configure.
AC_PREREQ([2.60])
-AC_INIT(libXi, 1.3, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], libXi)
+AC_INIT(libXi, 1.4, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], libXi)
AM_INIT_AUTOMAKE([foreign dist-bzip2])
AM_MAINTAINER_MODE
@@ -24,7 +24,7 @@ AC_PROG_LIBTOOL
AC_PROG_SED
# Checks for pkg-config packages
-PKG_CHECK_MODULES(XI, [xproto >= 7.0.13] [x11 >= 1.2.99.1] [xextproto >= 7.0.3] [xext >= 1.0.99.1] [inputproto >= 1.9.99.902])
+PKG_CHECK_MODULES(XI, [xproto >= 7.0.13] [x11 >= 1.2.99.1] [xextproto >= 7.0.3] [xext >= 1.0.99.1] [inputproto >= 2.1])
# Check for xmlto and asciidoc for man page conversion
# (only needed by people building tarballs)
diff --git a/include/X11/extensions/XInput2.h b/include/X11/extensions/XInput2.h
index e6c7b30..05df3fc 100644
--- a/include/X11/extensions/XInput2.h
+++ b/include/X11/extensions/XInput2.h
@@ -135,6 +135,25 @@ typedef struct
typedef struct
{
+ int type;
+ int sourceid;
+ int mode;
+ int num_touches;
+} XITouchClassInfo;
+
+typedef struct
+{
+ int type;
+ int sourceid;
+ int number;
+ Atom label;
+ double min;
+ double max;
+ int resolution;
+} XITouchValuatorClassInfo;
+
+typedef struct
+{
int deviceid;
char *name;
int use;
diff --git a/src/XExtInt.c b/src/XExtInt.c
index eed6637..a1ade31 100644
--- a/src/XExtInt.c
+++ b/src/XExtInt.c
@@ -268,7 +268,8 @@ static XExtensionVersion versions[] = { {XI_Absent, 0, 0},
XI_Add_DevicePresenceNotify_Minor},
{XI_Present, XI_Add_DeviceProperties_Major,
XI_Add_DeviceProperties_Minor},
-{XI_Present, XI_2_Major, XI_2_Minor}
+{XI_Present, XI_2_Major, XI_2_Minor},
+{XI_Present, XI_2_Major, XI_2_1_Minor}
};
/***********************************************************************
@@ -924,6 +925,9 @@ XInputWireToCookie(
case XI_ButtonRelease:
case XI_KeyPress:
case XI_KeyRelease:
+ case XI_TouchBegin:
+ case XI_TouchMotion:
+ case XI_TouchEnd:
*cookie = *(XGenericEventCookie*)save;
if (!wireToDeviceEvent((xXIDeviceEvent*)event, cookie))
{
@@ -1037,6 +1041,12 @@ sizeDeviceClassType(int type, int num_elements)
case XIValuatorClass:
l = sizeof(XIValuatorClassInfo);
break;
+ case XITouchClass:
+ l = sizeof(XITouchClassInfo);
+ break;
+ case XITouchValuatorClass:
+ l = sizeof(XITouchValuatorClassInfo);
+ break;
default:
printf("sizeDeviceClassType: unknown type %d\n", type);
break;
@@ -1426,6 +1436,12 @@ size_classes(xXIAnyInfo* from, int nclasses)
case XIValuatorClass:
l = sizeDeviceClassType(XIValuatorClass, 0);
break;
+ case XITouchClass:
+ l = sizeDeviceClassType(XITouchClass, 0);
+ break;
+ case XITouchValuatorClass:
+ l = sizeDeviceClassType(XITouchValuatorClass, 0);
+ break;
}
len += l;
@@ -1526,6 +1542,35 @@ copy_classes(XIDeviceInfo* to, xXIAnyInfo* from, int nclasses)
}
break;
+ case XITouchClass:
+ {
+ XITouchClassInfo *cls_lib;
+ xXITouchInfo *cls_wire;
+
+ cls_wire = (xXITouchInfo*)any_wire;
+ cls_lib = next_block(&ptr_lib, sizeof(XITouchClassInfo));
+
+ cls_lib->mode = cls_wire->mode;
+ cls_lib->num_touches = cls_wire->num_touches;
+ }
+ break;
+ case XITouchValuatorClass:
+ {
+ XITouchValuatorClassInfo *cls_lib;
+ xXITouchValuatorInfo *cls_wire;
+
+ cls_wire = (xXITouchValuatorInfo*)any_wire;
+ cls_lib = next_block(&ptr_lib,
+ sizeof(XITouchValuatorClassInfo));
+
+ cls_lib->number = cls_wire->number;
+ cls_lib->label = cls_wire->label;
+ /* FIXME: fractional parts */
+ cls_lib->min = cls_wire->min.integral;
+ cls_lib->max = cls_wire->max.integral;
+ cls_lib->resolution = cls_wire->resolution;
+ }
+ break;
}
len += any_wire->length * 4;
ptr_wire += any_wire->length * 4;
--
1.7.1
More information about the xorg-devel
mailing list