[gtk+/touch-for-3.4] gdk: Adapt to direct/indirect touch device types
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/touch-for-3.4] gdk: Adapt to direct/indirect touch device types
- Date: Fri, 24 Feb 2012 20:14:53 +0000 (UTC)
commit eed8b9574425a658d886643ab481b493c9ca5cd2
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Feb 24 14:34:58 2012 -0500
gdk: Adapt to direct/indirect touch device types
We use the XITouchClass.mode information to determine if
a device is direct or indirect.
gdk/gdkdisplay.c | 3 ++-
gdk/gdkwindow.c | 12 ++++++++----
gdk/x11/gdkdevicemanager-xi2.c | 32 ++++++++++++++++++++++----------
3 files changed, 32 insertions(+), 15 deletions(-)
---
diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c
index ea1805e..0619f60 100644
--- a/gdk/gdkdisplay.c
+++ b/gdk/gdkdisplay.c
@@ -974,7 +974,8 @@ switch_to_pointer_grab (GdkDisplay *display,
* synthesized when needed.
*/
if (source_device &&
- gdk_device_get_source (source_device) == GDK_SOURCE_TOUCH)
+ (gdk_device_get_source (source_device) == GDK_SOURCE_DIRECT_TOUCH ||
+ gdk_device_get_source (source_device) == GDK_SOURCE_INDIRECT_TOUCH))
info->need_touch_press_enter = TRUE;
pointer_window = NULL;
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 2d9d9f6..d9516ea 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -9249,7 +9249,8 @@ proxy_pointer_event (GdkDisplay *display,
non_linear = TRUE;
if (pointer_info->need_touch_press_enter &&
- gdk_device_get_source (pointer_info->last_slave) != GDK_SOURCE_TOUCH &&
+ gdk_device_get_source (pointer_info->last_slave) != GDK_SOURCE_DIRECT_TOUCH &&
+ gdk_device_get_source (pointer_info->last_slave) != GDK_SOURCE_INDIRECT_TOUCH &&
(source_event->type != GDK_TOUCH_UPDATE ||
_gdk_event_get_pointer_emulated (source_event)))
{
@@ -9641,7 +9642,8 @@ proxy_button_event (GdkEvent *source_event,
* which synthesized a leave notify event, so synthesize another enter
* notify to tell the pointer is on the window.
*/
- if (gdk_device_get_source (source_device) == GDK_SOURCE_TOUCH)
+ if (gdk_device_get_source (source_device) == GDK_SOURCE_DIRECT_TOUCH ||
+ gdk_device_get_source (source_device) == GDK_SOURCE_INDIRECT_TOUCH)
mode = GDK_CROSSING_TOUCH_PRESS;
else
mode = GDK_CROSSING_DEVICE_SWITCH;
@@ -9679,7 +9681,8 @@ proxy_button_event (GdkEvent *source_event,
_gdk_event_button_generate (display, event);
else if (type == GDK_BUTTON_RELEASE &&
pointer_window == pointer_info->window_under_pointer &&
- gdk_device_get_source (source_device) == GDK_SOURCE_TOUCH)
+ (gdk_device_get_source (source_device) == GDK_SOURCE_DIRECT_TOUCH ||
+ gdk_device_get_source (source_device) == GDK_SOURCE_INDIRECT_TOUCH))
{
/* Synthesize a leave notify event
* whenever a touch device is released
@@ -9713,7 +9716,8 @@ proxy_button_event (GdkEvent *source_event,
if ((type == GDK_TOUCH_END &&
_gdk_event_get_pointer_emulated (source_event)) &&
pointer_window == pointer_info->window_under_pointer &&
- gdk_device_get_source (source_device) == GDK_SOURCE_TOUCH)
+ (gdk_device_get_source (source_device) == GDK_SOURCE_DIRECT_TOUCH ||
+ gdk_device_get_source (source_device) == GDK_SOURCE_INDIRECT_TOUCH))
{
/* Synthesize a leave notify event
* whenever a touch device is released
diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c
index 3036050..6b360ad 100644
--- a/gdk/x11/gdkdevicemanager-xi2.c
+++ b/gdk/x11/gdkdevicemanager-xi2.c
@@ -252,25 +252,36 @@ translate_device_classes (GdkDisplay *display,
g_object_thaw_notify (G_OBJECT (device));
}
-static gint
-count_device_touches (XIAnyClassInfo **classes,
- guint n_classes)
+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 *valuator_info = (XITouchClassInfo *) classes[i];
+ XITouchClassInfo *class = (XITouchClassInfo *) classes[i];
- if (valuator_info->type != XITouchClass)
+ if (class->type != XITouchClass)
continue;
- return valuator_info->num_touches;
+ if (class->num_touches > 0)
+ {
+ if (class->mode == XIDirectTouch)
+ *device_type = GDK_SOURCE_DIRECT_TOUCH;
+ else if (class->mode == XIDependentTouch)
+ *device_type = GDK_SOURCE_INDIRECT_TOUCH;
+ else
+ continue;
+
+ return TRUE;
+ }
}
#endif
- return 0;
+ return FALSE;
}
static GdkDevice *
@@ -279,6 +290,7 @@ create_device (GdkDeviceManager *device_manager,
XIDeviceInfo *dev)
{
GdkInputSource input_source;
+ GdkInputSource touch_source;
GdkDeviceType type;
GdkDevice *device;
GdkInputMode mode;
@@ -286,8 +298,8 @@ create_device (GdkDeviceManager *device_manager,
if (dev->use == XIMasterKeyboard || dev->use == XISlaveKeyboard)
input_source = GDK_SOURCE_KEYBOARD;
else if (dev->use == XISlavePointer &&
- count_device_touches (dev->classes, dev->num_classes) > 0)
- input_source = GDK_SOURCE_TOUCH;
+ is_touch_device (dev->classes, dev->num_classes, &touch_source))
+ input_source = touch_source;
else
{
gchar *tmp_name;
@@ -301,7 +313,7 @@ create_device (GdkDeviceManager *device_manager,
else if (strstr (tmp_name, "finger") ||
(strstr (tmp_name, "touch") &&
!strstr (tmp_name, "touchpad")))
- input_source = GDK_SOURCE_TOUCH;
+ input_source = GDK_SOURCE_DIRECT_TOUCH;
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]