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.
This commit is contained in:
Matthias Clasen 2015-06-15 19:46:33 -04:00
parent 002699402d
commit e367c4baa0
2 changed files with 8 additions and 3 deletions

View File

@ -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);

View File

@ -398,7 +398,8 @@ popup_menu (GtkMenuButton *menu_button,
break;
}
if (event)
if (event != NULL &&
gdk_event_get_screen (event) == gtk_widget_get_screen (GTK_WIDGET (menu_button)))
{
device = gdk_event_get_device (event);
gdk_event_get_button (event, &button);