From e367c4baa0395c9cc7e7fafc70459c9e63b66322 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 15 Jun 2015 19:46:33 -0400 Subject: Deal with events from wrong display GtkInspector is opening a separate display connection, which makes it more likely that gtk_get_current_event() returns an event from the "wrong" display. --- gtk/gtkmenu.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'gtk/gtkmenu.c') diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c index 7219953acc..21a737ef14 100644 --- a/gtk/gtkmenu.c +++ b/gtk/gtkmenu.c @@ -1535,20 +1535,24 @@ gtk_menu_popup_for_device (GtkMenu *menu, gboolean grab_keyboard; GtkWidget *parent_toplevel; GdkDevice *keyboard, *pointer, *source_device = NULL; + GdkDisplay *display; g_return_if_fail (GTK_IS_MENU (menu)); g_return_if_fail (device == NULL || GDK_IS_DEVICE (device)); + display = gtk_widget_get_display (GTK_WIDGET (menu)); + if (device == NULL) device = gtk_get_current_event_device (); + if (device && gdk_device_get_display (device) != display) + device = NULL; + if (device == NULL) { - GdkDisplay *display; GdkDeviceManager *device_manager; GList *devices; - display = gtk_widget_get_display (GTK_WIDGET (menu)); device_manager = gdk_display_get_device_manager (display); devices = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_MASTER); -- cgit v1.2.1