--- gtk/gtktextview.c.old	2011-11-04 13:39:55.000000000 +0100
+++ gtk/gtktextview.c	2011-11-04 13:41:27.000000000 +0100
@@ -8145,16 +8145,17 @@ popup_position_func (GtkMenu   *menu,
   *push_in = FALSE;
 }
 
 typedef struct
 {
   GtkTextView *text_view;
   gint button;
   guint time;
+  GdkDevice *device;
 } PopupInfo;
 
 static gboolean
 range_contains_editable_text (const GtkTextIter *start,
                               const GtkTextIter *end,
                               gboolean default_editability)
 {
   GtkTextIter iter = *start;
@@ -8296,19 +8297,19 @@ popup_targets_received (GtkClipboard
 							text_view);
 	}
 	  
       g_signal_emit (text_view,
 		     signals[POPULATE_POPUP],
 		     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
 	{
 	  gtk_menu_popup (GTK_MENU (priv->popup_menu), NULL, NULL,
 			  popup_position_func, text_view,
 			  0, gtk_get_current_event_time ());
 	  gtk_menu_shell_select_first (GTK_MENU_SHELL (priv->popup_menu), FALSE);
 	}
@@ -8329,21 +8330,23 @@ gtk_text_view_do_popup (GtkTextView    *
    * we get them, then we actually pop up the menu.
    */
   info->text_view = g_object_ref (text_view);
   
   if (event)
     {
       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),
 							    GDK_SELECTION_CLIPBOARD),
 				  gdk_atom_intern_static_string ("TARGETS"),
 				  popup_targets_received,
 				  info);
 }
