[gtk+] Deal with events from wrong display
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Deal with events from wrong display
- Date: Mon, 15 Jun 2015 23:50:16 +0000 (UTC)
commit e367c4baa0395c9cc7e7fafc70459c9e63b66322
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Jun 15 19:46:33 2015 -0400
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 ++++++--
gtk/gtkmenubutton.c | 3 ++-
2 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index 7219953..21a737e 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);
diff --git a/gtk/gtkmenubutton.c b/gtk/gtkmenubutton.c
index 17c822b..2126087 100644
--- a/gtk/gtkmenubutton.c
+++ b/gtk/gtkmenubutton.c
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]