[gtk+/multitouch: 15/27] xi2: Use GDK_SOURCE_MULTITOUCH for multitouch devices
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/multitouch: 15/27] xi2: Use GDK_SOURCE_MULTITOUCH for multitouch devices
- Date: Tue, 13 Dec 2011 18:59:08 +0000 (UTC)
commit 55bda5929a518ebb0ec8bb071bb094fb49283386
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Oct 27 22:30:14 2011 +0200
xi2: Use GDK_SOURCE_MULTITOUCH for multitouch devices
Any device with XITouchValuatorClassInfo classes qualify as
multitouch now.
gdk/x11/gdkdevicemanager-xi2.c | 26 ++++++++++++++++++++++++--
1 files changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c
index c423fa5..6e35dee 100644
--- a/gdk/x11/gdkdevicemanager-xi2.c
+++ b/gdk/x11/gdkdevicemanager-xi2.c
@@ -246,6 +246,28 @@ translate_device_classes (GdkDisplay *display,
g_object_thaw_notify (G_OBJECT (device));
}
+static gint
+count_device_touches (XIAnyClassInfo **classes,
+ guint n_classes)
+{
+ gint n_touches = 0;
+#ifdef XINPUT_2_1
+ guint i;
+
+ for (i = 0; i < n_classes; i++)
+ {
+ XITouchValuatorClassInfo *valuator_info = (XITouchValuatorClassInfo *) classes[i];
+
+ if (valuator_info->type != XITouchValuatorClass)
+ continue;
+
+ n_touches = MAX (n_touches, valuator_info->number);
+ }
+#endif
+
+ return n_touches;
+}
+
static GdkDevice *
create_device (GdkDeviceManager *device_manager,
GdkDisplay *display,
@@ -258,6 +280,8 @@ create_device (GdkDeviceManager *device_manager,
if (dev->use == XIMasterKeyboard || dev->use == XISlaveKeyboard)
input_source = GDK_SOURCE_KEYBOARD;
+ else if (count_device_touches (dev->classes, dev->num_classes) > 0)
+ input_source = GDK_SOURCE_MULTITOUCH;
else
{
gchar *tmp_name;
@@ -275,8 +299,6 @@ create_device (GdkDeviceManager *device_manager,
else if (strstr (tmp_name, "wacom") ||
strstr (tmp_name, "pen"))
input_source = GDK_SOURCE_PEN;
- else if (strstr (tmp_name, "multitouch"))
- input_source = GDK_SOURCE_TOUCH;
else
input_source = GDK_SOURCE_MOUSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]