[gtk+/touch-for-3.4-2: 4/44] xi2: Use the new device types for touch-capable devices
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/touch-for-3.4-2: 4/44] xi2: Use the new device types for touch-capable devices
- Date: Thu, 1 Mar 2012 20:26:31 +0000 (UTC)
commit d4c7234e70b194db06414514eed0c8d28f3f87af
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Feb 29 22:00:18 2012 -0500
xi2: Use the new device types for touch-capable devices
Any device with a XITouchClassInfo with num_touches > 0
qualifies as multitouch.
gdk/x11/gdkdevicemanager-xi2.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c
index 3cf947a..7b66d92 100644
--- a/gdk/x11/gdkdevicemanager-xi2.c
+++ b/gdk/x11/gdkdevicemanager-xi2.c
@@ -248,18 +248,54 @@ translate_device_classes (GdkDisplay *display,
g_object_thaw_notify (G_OBJECT (device));
}
+static gboolean
+is_touch_device (XIAnyClassInfo **classes,
+ guint n_classes,
+ GdkInputSource *device_type)
+{
+#ifdef XINPUT_2_2
+ guint i;
+
+ for (i = 0; i < n_classes; i++)
+ {
+ XITouchClassInfo *class = (XITouchClassInfo *) classes[i];
+
+ if (class->type != XITouchClass)
+ continue;
+
+ if (class->num_touches > 0)
+ {
+ if (class->mode == XIDirectTouch)
+ *device_type = GDK_SOURCE_TOUCHSCREEN;
+ else if (class->mode == XIDependentTouch)
+ *device_type = GDK_SOURCE_TOUCHPAD;
+ else
+ continue;
+
+ return TRUE;
+ }
+ }
+#endif
+
+ return FALSE;
+}
+
static GdkDevice *
create_device (GdkDeviceManager *device_manager,
GdkDisplay *display,
XIDeviceInfo *dev)
{
GdkInputSource input_source;
+ GdkInputSource touch_source;
GdkDeviceType type;
GdkDevice *device;
GdkInputMode mode;
if (dev->use == XIMasterKeyboard || dev->use == XISlaveKeyboard)
input_source = GDK_SOURCE_KEYBOARD;
+ else if (dev->use == XISlavePointer &&
+ is_touch_device (dev->classes, dev->num_classes, &touch_source))
+ input_source = touch_source;
else
{
gchar *tmp_name;
@@ -270,6 +306,10 @@ create_device (GdkDeviceManager *device_manager,
input_source = GDK_SOURCE_ERASER;
else if (strstr (tmp_name, "cursor"))
input_source = GDK_SOURCE_CURSOR;
+ else if (strstr (tmp_name, "finger") ||
+ (strstr (tmp_name, "touch") &&
+ !strstr (tmp_name, "touchpad")))
+ input_source = GDK_SOURCE_TOUCHSCREEN;
else if (strstr (tmp_name, "wacom") ||
strstr (tmp_name, "pen"))
input_source = GDK_SOURCE_PEN;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]