forked from AuroraMiddleware/gtk
gdk: Listen to touch events by default on the native window
GDK will only receive touch events when dealing with a multitouch device, so these must be transformed to pointer events if the client-side window receiving the event doesn't listen to touch events, and the touch sequence the event is from does emulate the pointer. If a sequence emulates pointer events, it will result in a button-press, N motions with GDK_BUTTON1_MASK set and a button-release event, and it will deliver crossing events as specified by the current device grab.
This commit is contained in:
parent
0a80c26cdf
commit
6efe116715
@ -1243,11 +1243,12 @@ get_native_device_event_mask (GdkWindow *private,
|
||||
* lists due to some non-native child window.
|
||||
*/
|
||||
if (gdk_window_is_toplevel (private) ||
|
||||
mask & GDK_BUTTON_PRESS_MASK)
|
||||
mask |=
|
||||
GDK_POINTER_MOTION_MASK |
|
||||
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
|
||||
GDK_SCROLL_MASK;
|
||||
mask & GDK_BUTTON_PRESS_MASK)
|
||||
mask |=
|
||||
GDK_TOUCH_MASK |
|
||||
GDK_POINTER_MOTION_MASK |
|
||||
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
|
||||
GDK_SCROLL_MASK;
|
||||
|
||||
return mask;
|
||||
}
|
||||
@ -8170,6 +8171,15 @@ is_motion_type (GdkEventType type)
|
||||
type == GDK_LEAVE_NOTIFY;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
is_touch_type (GdkEventType type)
|
||||
{
|
||||
return type == GDK_TOUCH_BEGIN ||
|
||||
type == GDK_TOUCH_UPDATE ||
|
||||
type == GDK_TOUCH_END ||
|
||||
type == GDK_TOUCH_CANCEL;
|
||||
}
|
||||
|
||||
static GdkWindow *
|
||||
find_common_ancestor (GdkWindow *win1,
|
||||
GdkWindow *win2)
|
||||
@ -9242,8 +9252,9 @@ proxy_pointer_event (GdkDisplay *display,
|
||||
|
||||
if (pointer_info->need_touch_press_enter &&
|
||||
gdk_device_get_source (pointer_info->last_slave) != GDK_SOURCE_TOUCHSCREEN &&
|
||||
gdk_device_get_source (pointer_info->last_slave) != GDK_SOURCE_TOUCHPAD)
|
||||
|
||||
gdk_device_get_source (pointer_info->last_slave) != GDK_SOURCE_TOUCHPAD) &&
|
||||
(source_event->type != GDK_TOUCH_UPDATE ||
|
||||
_gdk_event_get_pointer_emulated (source_event))
|
||||
{
|
||||
pointer_info->need_touch_press_enter = FALSE;
|
||||
need_synthetic_enter = TRUE;
|
||||
@ -9374,6 +9385,15 @@ proxy_pointer_event (GdkDisplay *display,
|
||||
&evmask,
|
||||
serial);
|
||||
|
||||
if ((evmask & GDK_TOUCH_MASK) == 0 &&
|
||||
source_event->type == GDK_TOUCH_UPDATE)
|
||||
{
|
||||
if (_gdk_event_get_pointer_emulated (source_event))
|
||||
source_event->type = GDK_MOTION_NOTIFY;
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (event_win &&
|
||||
gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_MASTER &&
|
||||
gdk_window_get_device_events (event_win, device) == 0)
|
||||
@ -9560,6 +9580,20 @@ proxy_button_event (GdkEvent *source_event,
|
||||
type, state,
|
||||
&evmask, serial);
|
||||
|
||||
if ((evmask & GDK_TOUCH_MASK) == 0 &&
|
||||
(type == GDK_TOUCH_BEGIN || type == GDK_TOUCH_END))
|
||||
{
|
||||
if (_gdk_event_get_pointer_emulated (source_event))
|
||||
{
|
||||
if (type == GDK_TOUCH_BEGIN)
|
||||
source_event->type = type = GDK_BUTTON_PRESS;
|
||||
else if (type == GDK_TOUCH_END)
|
||||
source_event->type = type = GDK_BUTTON_RELEASE;
|
||||
}
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (event_win == NULL || display->ignore_core_events)
|
||||
return TRUE;
|
||||
|
||||
@ -9567,7 +9601,9 @@ proxy_button_event (GdkEvent *source_event,
|
||||
gdk_window_get_device_events (event_win, device) == 0)
|
||||
return TRUE;
|
||||
|
||||
if (type == GDK_BUTTON_PRESS &&
|
||||
if ((type == GDK_BUTTON_PRESS ||
|
||||
(type == GDK_TOUCH_BEGIN &&
|
||||
_gdk_event_get_pointer_emulated (source_event))) &&
|
||||
pointer_info->need_touch_press_enter)
|
||||
{
|
||||
GdkCrossingMode mode;
|
||||
@ -9612,7 +9648,9 @@ proxy_button_event (GdkEvent *source_event,
|
||||
|
||||
if (type == GDK_BUTTON_PRESS)
|
||||
_gdk_event_button_generate (display, event);
|
||||
else if (type == GDK_BUTTON_RELEASE &&
|
||||
else if ((type == GDK_BUTTON_RELEASE ||
|
||||
(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_TOUCHSCREEN ||
|
||||
gdk_device_get_source (source_device) == GDK_SOURCE_TOUCHPAD))
|
||||
@ -9892,7 +9930,9 @@ _gdk_windowing_got_event (GdkDisplay *display,
|
||||
}
|
||||
}
|
||||
|
||||
if (pointer_info)
|
||||
if (pointer_info &&
|
||||
(!is_touch_type (event->type) ||
|
||||
_gdk_event_get_pointer_emulated (event)))
|
||||
{
|
||||
guint old_state, old_button;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user