Index: src/windowlist.c =================================================================== --- src/windowlist.c (revision 18318) +++ src/windowlist.c (working copy) @@ -310,16 +310,23 @@ void popup_windowlist(GdkScreen *gscreen, gint button, guint32 time) { - GtkWidget *windowlist; + GdkWindow *root; if(!show_windowlist) return; - windowlist = windowlist_create(gscreen); - gtk_menu_set_screen(GTK_MENU(windowlist), gscreen); - g_signal_connect_swapped(G_OBJECT(windowlist), "deactivate", - G_CALLBACK(g_idle_add), (gpointer)windowlist_deactivate_idled); - gtk_menu_popup(GTK_MENU(windowlist), NULL, NULL, NULL, NULL, button, time); + root = gdk_screen_get_root_window(gscreen); + if (xfdesktop_popup_grab_available(root, time)) { + GtkWidget *windowlist; + + windowlist = windowlist_create(gscreen); + gtk_menu_set_screen(GTK_MENU(windowlist), gscreen); + g_signal_connect_swapped(G_OBJECT(windowlist), "deactivate", + G_CALLBACK(g_idle_add), (gpointer)windowlist_deactivate_idled); + gtk_menu_popup(GTK_MENU(windowlist), NULL, NULL, NULL, NULL, button, time); + } + else + g_critical("Unable to get keyboard/mouse grab. Unable to popup windowlist"); } void Index: src/menu.c =================================================================== --- src/menu.c (revision 18318) +++ src/menu.c (working copy) @@ -70,56 +70,6 @@ } #endif -#if USE_DESKTOP_MENU -/* Code taken from xfwm4/src/menu.c:grab_available(). This should fix the case - * where binding 'xfdesktop -menu' to a keyboard shortcut sometimes works and - * sometimes doesn't. Credit for this one goes to Olivier. - */ -static gboolean -menu_grab_available (GdkWindow *win, guint32 timestamp) -{ - GdkEventMask mask = - GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | - GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | - GDK_POINTER_MOTION_MASK; - GdkGrabStatus g1; - GdkGrabStatus g2; - gboolean grab_failed = FALSE; - gint i = 0; - - TRACE ("entering grab_available"); - - g1 = gdk_pointer_grab (win, TRUE, mask, NULL, NULL, timestamp); - g2 = gdk_keyboard_grab (win, TRUE, timestamp); - - while ((i++ < 100) && (grab_failed = ((g1 != GDK_GRAB_SUCCESS) - || (g2 != GDK_GRAB_SUCCESS)))) - { - TRACE ("grab not available yet, waiting... (%i)", i); - g_usleep (100); - if (g1 != GDK_GRAB_SUCCESS) - { - g1 = gdk_pointer_grab (win, TRUE, mask, NULL, NULL, timestamp); - } - if (g2 != GDK_GRAB_SUCCESS) - { - g2 = gdk_keyboard_grab (win, TRUE, timestamp); - } - } - - if (g1 == GDK_GRAB_SUCCESS) - { - gdk_pointer_ungrab (timestamp); - } - if (g2 == GDK_GRAB_SUCCESS) - { - gdk_keyboard_ungrab (timestamp); - } - - return (!grab_failed); -} -#endif - void popup_desktop_menu(GdkScreen *gscreen, gint button, guint32 time) { @@ -137,7 +87,7 @@ gtk_menu_set_screen(GTK_MENU(menu_widget), gscreen); root = gdk_screen_get_root_window(gscreen); - if(!menu_grab_available(root, time)) + if(!xfdesktop_popup_grab_available(root, time)) g_critical("Unable to get keyboard/mouse grab. Unable to popup desktop menu"); else { gtk_menu_popup(GTK_MENU(menu_widget), NULL, NULL, NULL, NULL, Index: common/xfdesktop-common.h =================================================================== --- common/xfdesktop-common.h (revision 18318) +++ common/xfdesktop-common.h (working copy) @@ -26,6 +26,7 @@ #define _XFDESKTOP_COMMON_H_ #include +#include #include @@ -64,6 +65,7 @@ gchar *xfce_desktop_get_menufile(); gboolean xfdesktop_check_is_running(Window *xid); void xfdesktop_send_client_message(Window xid, const gchar *msg); +gboolean xfdesktop_popup_grab_available(GdkWindow *win, guint32 timestamp); G_END_DECLS Index: common/xfdesktop-common.c =================================================================== --- common/xfdesktop-common.c (revision 18318) +++ common/xfdesktop-common.c (working copy) @@ -237,3 +237,52 @@ gtk_widget_destroy(win); } + +/* Code taken from xfwm4/src/menu.c:grab_available(). This should fix the case + * where binding 'xfdesktop -menu' to a keyboard shortcut sometimes works and + * sometimes doesn't. Credit for this one goes to Olivier. + */ +gboolean +xfdesktop_popup_grab_available (GdkWindow *win, guint32 timestamp) +{ + GdkEventMask mask = + GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | + GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | + GDK_POINTER_MOTION_MASK; + GdkGrabStatus g1; + GdkGrabStatus g2; + gboolean grab_failed = FALSE; + gint i = 0; + + TRACE ("entering grab_available"); + + g1 = gdk_pointer_grab (win, TRUE, mask, NULL, NULL, timestamp); + g2 = gdk_keyboard_grab (win, TRUE, timestamp); + + while ((i++ < 100) && (grab_failed = ((g1 != GDK_GRAB_SUCCESS) + || (g2 != GDK_GRAB_SUCCESS)))) + { + TRACE ("grab not available yet, waiting... (%i)", i); + g_usleep (100); + if (g1 != GDK_GRAB_SUCCESS) + { + g1 = gdk_pointer_grab (win, TRUE, mask, NULL, NULL, timestamp); + } + if (g2 != GDK_GRAB_SUCCESS) + { + g2 = gdk_keyboard_grab (win, TRUE, timestamp); + } + } + + if (g1 == GDK_GRAB_SUCCESS) + { + gdk_pointer_ungrab (timestamp); + } + if (g2 == GDK_GRAB_SUCCESS) + { + gdk_keyboard_ungrab (timestamp); + } + + return (!grab_failed); +} +