[Xfce4-commits] <xfdesktop:master> Added a check for GDK_GRAB_INVALID_TIME in xfdesktop_popup_grab_available to mitigate slow menu popups on a right mouse click. Fixes bug 7172.

Eric Koegel noreply at xfce.org
Mon Mar 5 19:30:02 CET 2012


Updating branch refs/heads/master
         to 803ea66061417317df2b2968a81a4cfdfd052e8d (commit)
       from cf1ba8ecefacca369c4f83ece0b6d03b718fce06 (commit)

commit 803ea66061417317df2b2968a81a4cfdfd052e8d
Author: Eric Koegel <eric.koegel at gmail.com>
Date:   Mon Dec 5 14:44:59 2011 +0300

    Added a check for GDK_GRAB_INVALID_TIME in xfdesktop_popup_grab_available to mitigate slow menu popups on a right mouse click. Fixes bug 7172.

 common/xfdesktop-common.c |    5 ++++-
 src/xfce-desktop.c        |   40 ++++++++++++++++++++--------------------
 2 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/common/xfdesktop-common.c b/common/xfdesktop-common.c
index 9e4f22c..64aee8d 100644
--- a/common/xfdesktop-common.c
+++ b/common/xfdesktop-common.c
@@ -370,7 +370,10 @@ xfdesktop_popup_grab_available (GdkWindow *win, guint32 timestamp)
     while ((i++ < 2500) && (grab_failed = ((g1 != GDK_GRAB_SUCCESS)
                 || (g2 != GDK_GRAB_SUCCESS))))
     {
-        TRACE ("grab not available yet, waiting... (%i)", i);
+        TRACE ("grab not available yet, mouse reason: %d, keyboard reason: %d, waiting... (%i)", g1, g2, i);
+        if(g1 == GDK_GRAB_INVALID_TIME || g2 == GDK_GRAB_INVALID_TIME)
+            break;
+
         g_usleep (100);
         if (g1 != GDK_GRAB_SUCCESS)
         {
diff --git a/src/xfce-desktop.c b/src/xfce-desktop.c
index cd98ae7..bcd4bd8 100644
--- a/src/xfce-desktop.c
+++ b/src/xfce-desktop.c
@@ -1340,29 +1340,29 @@ xfce_desktop_do_menu_popup(XfceDesktop *desktop,
         screen = gtk_widget_get_screen(GTK_WIDGET(desktop));
     else
         screen = gdk_display_get_default_screen(gdk_display_get_default());
-    
-    menu = gtk_menu_new();
-    gtk_menu_set_screen(GTK_MENU(menu), screen);
-    g_signal_connect_swapped(G_OBJECT(menu), "deactivate",
-                             G_CALLBACK(g_idle_add),
-                             (gpointer)xfce_desktop_menu_destroy_idled);
-    
-    g_signal_emit(G_OBJECT(desktop), populate_signal, 0, menu);
-    
-    /* if nobody populated the menu, don't do anything */
-    menu_children = gtk_container_get_children(GTK_CONTAINER(menu));
-    if(!menu_children) {
-        gtk_widget_destroy(menu);
-        return;
-    }
-    
-    g_list_free(menu_children);
-    
-    gtk_menu_attach_to_widget(GTK_MENU(menu), GTK_WIDGET(desktop), NULL);
-    
+
     if(xfdesktop_popup_grab_available(gdk_screen_get_root_window(screen),
                                       activate_time))
     {
+        menu = gtk_menu_new();
+        gtk_menu_set_screen(GTK_MENU(menu), screen);
+        g_signal_connect_swapped(G_OBJECT(menu), "deactivate",
+                                 G_CALLBACK(g_idle_add),
+                                 (gpointer)xfce_desktop_menu_destroy_idled);
+
+        g_signal_emit(G_OBJECT(desktop), populate_signal, 0, menu);
+
+        /* if nobody populated the menu, don't do anything */
+        menu_children = gtk_container_get_children(GTK_CONTAINER(menu));
+        if(!menu_children) {
+            gtk_widget_destroy(menu);
+            return;
+        }
+
+        g_list_free(menu_children);
+
+        gtk_menu_attach_to_widget(GTK_MENU(menu), GTK_WIDGET(desktop), NULL);
+
         /* bug #3652: for some reason passing the correct button here breaks
          * on some systems but not others.  always pass 0 for now. */
         gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0,


More information about the Xfce4-commits mailing list