From fcd5e44e159daf661254605461be45f7f05579d6 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 5 Nov 2011 01:23:06 -0400 Subject: [PATCH] Pop up context menus at the right device When multiple pointers are in play, we need to be careful not to loose track of the device between receiving a button press and popping up a menu. https://bugzilla.gnome.org/show_bug.cgi?id=663396 --- gtk/gtkentry.c | 11 +++++++---- gtk/gtktextview.c | 9 ++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index f9ad68ab3c..467ad315bb 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -8880,6 +8880,7 @@ typedef struct GtkEntry *entry; gint button; guint time; + GdkDevice *device; } PopupInfo; static void @@ -8987,15 +8988,15 @@ popup_targets_received (GtkClipboard *clipboard, info_entry_priv->popup_menu); - if (info->button) - gtk_menu_popup (GTK_MENU (info_entry_priv->popup_menu), NULL, NULL, - NULL, NULL, + if (info->device) + gtk_menu_popup_for_device (GTK_MENU (info_entry_priv->popup_menu), + info->device, NULL, NULL, NULL, NULL, NULL, info->button, info->time); else { gtk_menu_popup (GTK_MENU (info_entry_priv->popup_menu), NULL, NULL, popup_position_func, entry, - info->button, info->time); + 0, gtk_get_current_event_time ()); gtk_menu_shell_select_first (GTK_MENU_SHELL (info_entry_priv->popup_menu), FALSE); } } @@ -9020,11 +9021,13 @@ gtk_entry_do_popup (GtkEntry *entry, { info->button = event->button; info->time = event->time; + info->device = event->device; } else { info->button = 0; info->time = gtk_get_current_event_time (); + info->device = NULL; } gtk_clipboard_request_contents (gtk_widget_get_clipboard (GTK_WIDGET (entry), GDK_SELECTION_CLIPBOARD), diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index 9b073345c4..3910e0d1a1 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -8153,6 +8153,7 @@ typedef struct GtkTextView *text_view; gint button; guint time; + GdkDevice *device; } PopupInfo; static gboolean @@ -8306,9 +8307,9 @@ popup_targets_received (GtkClipboard *clipboard, 0, priv->popup_menu); - if (info->button) - gtk_menu_popup (GTK_MENU (priv->popup_menu), NULL, NULL, - NULL, NULL, + if (info->device) + gtk_menu_popup_for_device (GTK_MENU (priv->popup_menu), + info->device, NULL, NULL, NULL, NULL, NULL, info->button, info->time); else { @@ -8339,11 +8340,13 @@ gtk_text_view_do_popup (GtkTextView *text_view, { info->button = event->button; info->time = event->time; + info->device = event->device; } else { info->button = 0; info->time = gtk_get_current_event_time (); + info->device = NULL; } gtk_clipboard_request_contents (gtk_widget_get_clipboard (GTK_WIDGET (text_view),