[gtk+] Pop up context menus at the right device



commit 41d422915576d55b41cf2af1ac16034bbf308a3a
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Nov 5 01:23:06 2011 -0400

    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 1806464..0acf72d 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -8882,6 +8882,7 @@ typedef struct
   GtkEntry *entry;
   gint button;
   guint time;
+  GdkDevice *device;
 } PopupInfo;
 
 static void
@@ -8989,15 +8990,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);
 	}
     }
@@ -9022,11 +9023,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 a2e5020..585c2a5 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -8157,6 +8157,7 @@ typedef struct
   GtkTextView *text_view;
   gint button;
   guint time;
+  GdkDevice *device;
 } PopupInfo;
 
 static gboolean
@@ -8310,9 +8311,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
 	{
@@ -8343,11 +8344,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),



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]