From 4ff3d5b7a6410272471f8216e87d1b87607f973e Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 22 Feb 2016 22:40:50 +0100 Subject: [PATCH] gdk: Avoid 2/3BUTTON event generation if the source device changes Remember the last source device we're generating multiple clicks for, just so we can bail out if the device changed. That will just reset the counting. https://bugzilla.gnome.org/show_bug.cgi?id=723659 --- gdk/gdkdisplayprivate.h | 1 + gdk/gdkevents.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/gdk/gdkdisplayprivate.h b/gdk/gdkdisplayprivate.h index 702d6cffe9..f4d2716fb7 100644 --- a/gdk/gdkdisplayprivate.h +++ b/gdk/gdkdisplayprivate.h @@ -88,6 +88,7 @@ typedef struct gint button_number[2]; /* last 2 buttons to be pressed */ gint button_x[2]; /* last 2 button click positions */ gint button_y[2]; + GdkDevice *last_slave; } GdkMultipleClickInfo; struct _GdkDisplay diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c index c6bb43e3ce..f6ab55fd54 100644 --- a/gdk/gdkevents.c +++ b/gdk/gdkevents.c @@ -2106,9 +2106,11 @@ _gdk_event_button_generate (GdkDisplay *display, GdkEvent *event) { GdkMultipleClickInfo *info; + GdkDevice *source_device; g_return_if_fail (event->type == GDK_BUTTON_PRESS); + source_device = gdk_event_get_source_device (event); info = g_hash_table_lookup (display->multiple_click_info, event->button.device); if (G_UNLIKELY (!info)) @@ -2123,6 +2125,7 @@ _gdk_event_button_generate (GdkDisplay *display, if ((event->button.time < (info->button_click_time[1] + 2 * display->double_click_time)) && (event->button.window == info->button_window[1]) && (event->button.button == info->button_number[1]) && + (source_device == info->last_slave) && (ABS (event->button.x - info->button_x[1]) <= display->double_click_distance) && (ABS (event->button.y - info->button_y[1]) <= display->double_click_distance)) { @@ -2136,10 +2139,12 @@ _gdk_event_button_generate (GdkDisplay *display, info->button_number[0] = -1; info->button_x[0] = info->button_x[1] = 0; info->button_y[0] = info->button_y[1] = 0; + info->last_slave = NULL; } else if ((event->button.time < (info->button_click_time[0] + display->double_click_time)) && (event->button.window == info->button_window[0]) && (event->button.button == info->button_number[0]) && + (source_device == info->last_slave) && (ABS (event->button.x - info->button_x[0]) <= display->double_click_distance) && (ABS (event->button.y - info->button_y[0]) <= display->double_click_distance)) { @@ -2155,6 +2160,7 @@ _gdk_event_button_generate (GdkDisplay *display, info->button_x[0] = event->button.x; info->button_y[1] = info->button_y[0]; info->button_y[0] = event->button.y; + info->last_slave = source_device; } else { @@ -2168,6 +2174,7 @@ _gdk_event_button_generate (GdkDisplay *display, info->button_x[0] = event->button.x; info->button_y[1] = 0; info->button_y[0] = event->button.y; + info->last_slave = source_device; } }