gdk: Adapt to direct/indirect touch device types
We use the XITouchClass.mode information to determine if a device is direct or indirect.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user