From 43e59258e4a9f9a88323dbde41c977843135d6fa Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 27 Nov 2017 12:34:08 -0500 Subject: [PATCH] Fix up _gtk_widget_list_devices When I rewrote that function to not use GdkDeviceManager, I overlooked that the window filtering needs to apply to the master pointer as well, as other code assumes that _gtk_widget_get_device_window will return non-NULL on the devices in the list. Fix this. --- gtk/gtkwidget.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 33eefb74c0..8a97c197b8 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -10274,6 +10274,9 @@ is_my_window (GtkWidget *widget, { gpointer user_data; + if (!window) + return FALSE; + gdk_window_get_user_data (window, &user_data); return (user_data == widget); } @@ -10320,6 +10323,7 @@ _gtk_widget_list_devices (GtkWidget *widget) GList *result = NULL; GList *devices; GList *l; + GdkDevice *device; g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); @@ -10327,14 +10331,15 @@ _gtk_widget_list_devices (GtkWidget *widget) return NULL; seat = gdk_display_get_default_seat (gtk_widget_get_display (widget)); - result = g_list_prepend (result, gdk_seat_get_pointer (seat)); + device = gdk_seat_get_pointer (seat); + if (is_my_window (widget, gdk_device_get_last_event_window (device))) + result = g_list_prepend (result, device); devices = gdk_seat_get_slaves (seat, GDK_SEAT_CAPABILITY_ALL_POINTING); for (l = devices; l; l = l->next) { - GdkDevice *device = l->data; - GdkWindow *window = gdk_device_get_last_event_window (device); - if (window && is_my_window (widget, window)) + device = l->data; + if (is_my_window (widget, gdk_device_get_last_event_window (device))) result = g_list_prepend (result, device); } g_list_free (devices);