Skip to content

Commit

Permalink
Deal with events from wrong display
Browse files Browse the repository at this point in the history
GtkInspector is opening a separate display connection, which makes
it more likely that gtk_get_current_event() returns an event from
the "wrong" display.
  • Loading branch information
Matthias Clasen committed Jun 15, 2015
1 parent 0026994 commit e367c4b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions gtk/gtkmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 2 additions & 1 deletion gtk/gtkmenubutton.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e367c4b

Please sign in to comment.