This is an automated email from the git hooks/post-receive script.

ochosi pushed a commit to branch master
in repository panel-plugins/xfce4-clipman-plugin.

commit 3abeb00331ccf43567921652d8c9717725f9ed1f
Author: Simon Steinbeiss <simon.steinbe...@elfenbeinturm.at>
Date:   Thu Sep 15 10:09:41 2016 +0200

    Revert "Use the xfce_gtk_menu_popup_until_mapped (bumps libxfce4ui to 4.13)"
    
    This reverts commit ce62e1fb5143cb27777ea88b3583ff03ada11a24.
---
 configure.ac.in          |  2 +-
 panel-plugin/Makefile.am |  1 +
 panel-plugin/plugin.c    | 95 ++++++++++++++++++++++++++++++++++++++----------
 3 files changed, 77 insertions(+), 21 deletions(-)

diff --git a/configure.ac.in b/configure.ac.in
index b73789e..32cb22a 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -64,7 +64,7 @@ XDT_CHECK_PACKAGE([GIO], [gio-2.0], [2.32.0])
 XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.32.0])
 XDT_CHECK_PACKAGE([GDKX], [gdk-x11-3.0], [3.14.0])
 XDT_CHECK_PACKAGE([GTK], [gtk+-3.0], [3.14.0])
-XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-2], [4.13.0])
+XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-2], [4.12.0])
 XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.12.0])
 XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-2.0], [4.12.0])
 XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [4.10.0])
diff --git a/panel-plugin/Makefile.am b/panel-plugin/Makefile.am
index 9a7e432..26259f2 100644
--- a/panel-plugin/Makefile.am
+++ b/panel-plugin/Makefile.am
@@ -222,3 +222,4 @@ DISTCLEANFILES =                                            
        \
 
 install-exec-hook:
        $(LN_S) -f $(exec_prefix)/bin/xfce4-popup-clipman 
$(DESTDIR)$(exec_prefix)/bin/xfce4-popup-clipman-actions
+
diff --git a/panel-plugin/plugin.c b/panel-plugin/plugin.c
index 8055490..a0050d6 100644
--- a/panel-plugin/plugin.c
+++ b/panel-plugin/plugin.c
@@ -26,7 +26,6 @@
 #include <gtk/gtk.h>
 #include <xfconf/xfconf.h>
 #include <libxfce4util/libxfce4util.h>
-#include <libxfce4ui/libxfce4ui.h>
 
 #ifdef PANEL_PLUGIN
 #include <libxfce4panel/libxfce4panel.h>
@@ -47,6 +46,8 @@ static gboolean         my_plugin_set_popup_selection   
(MyPlugin *plugin);
 static GdkFilterReturn  event_filter_popup_menu         (GdkXEvent *xevent,
                                                          GdkEvent *event,
                                                          MyPlugin *plugin);
+static gboolean         xfce_popup_grab_available       (GdkWindow *win,
+                                                         guint32 timestamp);
 
 
 
@@ -350,31 +351,32 @@ plugin_configure (MyPlugin *plugin)
 void
 plugin_popup_menu (MyPlugin *plugin)
 {
-  gboolean mapped = FALSE;
 #ifdef PANEL_PLUGIN
   gtk_menu_set_screen (GTK_MENU (plugin->menu), gtk_widget_get_screen 
(plugin->button));
 
-  mapped = xfce_gtk_menu_popup_until_mapped (GTK_MENU (plugin->menu), NULL, 
NULL,
-                                             plugin->menu_position_func, 
plugin,
-                                             0, gtk_get_current_event_time ());
-
-  if (mapped)
-    {
-      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (plugin->button), TRUE);
-      xfce_panel_plugin_register_menu (plugin->panel_plugin, GTK_MENU 
(plugin->menu));
-    }
-  else
-    g_critical ("Unable to display menu (probably a keyboard/mouse grab 
concurrency issue).");
+  if(!gtk_widget_has_grab(plugin->menu))
+  {
+    gtk_grab_add(plugin->menu);
+  }
 
+  gtk_menu_popup (GTK_MENU (plugin->menu), NULL, NULL,
+                  plugin->menu_position_func, plugin,
+                  0, gtk_get_current_event_time ());
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (plugin->button), TRUE);
+  xfce_panel_plugin_register_menu (plugin->panel_plugin, GTK_MENU 
(plugin->menu));
 #elif defined (STATUS_ICON)
 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
   gtk_menu_set_screen (GTK_MENU (plugin->menu), gtk_status_icon_get_screen 
(plugin->status_icon));
 G_GNUC_END_IGNORE_DEPRECATIONS
-  mapped = xfce_gtk_menu_popup_until_mapped (GTK_MENU (plugin->menu), NULL, 
NULL,
-                                             plugin->menu_position_func, 
plugin->status_icon,
-                                             0, gtk_get_current_event_time ());
-  if (!mapped)
-    g_critical ("Unable to display menu (probably a keyboard/mouse grab 
concurrency issue).");
+
+  if(!gtk_widget_has_grab(plugin->menu))
+  {
+    gtk_grab_add(plugin->menu);
+  }
+
+  gtk_menu_popup (GTK_MENU (plugin->menu), NULL, NULL,
+                  plugin->menu_position_func, plugin->status_icon,
+                  0, gtk_get_current_event_time ());
 #endif
 }
 
@@ -435,6 +437,8 @@ event_filter_popup_menu (GdkXEvent *xevent, GdkEvent 
*event, MyPlugin *plugin)
     if (evt->message_type != message_type)
       return GDK_FILTER_CONTINUE;
 
+    /* Copy workaround from xfdesktop to handle the awkward case where binding
+     * a keyboard shortcut to the popup command doesn't always work out... */
 #ifdef PANEL_PLUGIN
     screen = gtk_widget_get_screen (GTK_WIDGET (plugin->button));
 #elif defined (STATUS_ICON)
@@ -444,6 +448,12 @@ G_GNUC_END_IGNORE_DEPRECATIONS
 #endif
     root = gdk_screen_get_root_window (screen);
 
+    if (!xfce_popup_grab_available (root, GDK_CURRENT_TIME))
+      {
+        g_critical ("Unable to get keyboard/mouse grab.");
+        return FALSE;
+      }
+
   if (G_LIKELY (evt->format == 8) && (*(evt->data.b) != '\0'))
     {
 
@@ -453,8 +463,8 @@ G_GNUC_END_IGNORE_DEPRECATIONS
 
           if (xfconf_channel_get_bool (plugin->channel, 
"/tweaks/popup-at-pointer", FALSE))
             {
-              xfce_gtk_menu_popup_until_mapped (GTK_MENU (plugin->menu), NULL, 
NULL, NULL, NULL,
-                                                0, gtk_get_current_event_time 
());
+              gtk_menu_popup (GTK_MENU (plugin->menu), NULL, NULL, NULL, NULL,
+                              0, gtk_get_current_event_time ());
             }
           else
             {
@@ -480,3 +490,48 @@ make_window_visible (GdkSeat *seat,
   gdk_window_show (window);
 }
 #endif
+
+/* 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
+xfce_popup_grab_available (GdkWindow *win, guint32 timestamp)
+{
+    GdkDisplay* display = gdk_window_get_display(win);
+#if GTK_CHECK_VERSION (3, 20, 0)
+    GdkSeat *seat = gdk_display_get_default_seat (display);
+#endif
+    GdkGrabStatus g = GDK_GRAB_ALREADY_GRABBED;
+    gboolean grab_failed = TRUE;
+    gint i = 0;
+
+    TRACE ("entering grab_available");
+
+    /* With a keyboard grab elsewhere, we have to wait on that to clear.
+     * So try up to 2500 times and only keep trying when the failure is
+     * already grabbed, any other failure mode will never succeed.
+     */
+    while ((i++ < 2500) && grab_failed && g == GDK_GRAB_ALREADY_GRABBED)
+    {
+#if GTK_CHECK_VERSION (3, 20, 0)
+      g = gdk_seat_grab(seat, win, GDK_SEAT_CAPABILITY_KEYBOARD, TRUE, NULL, 
NULL, make_window_visible, NULL);
+      if (g == GDK_GRAB_SUCCESS)
+      {
+          gdk_seat_ungrab (seat);
+          grab_failed = FALSE;
+      }
+#else
+      G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+      g = gdk_keyboard_grab (win, TRUE, timestamp);
+      if (g == GDK_GRAB_SUCCESS)
+      {
+          gdk_keyboard_ungrab(timestamp);
+          grab_failed = FALSE;
+      }
+      G_GNUC_END_IGNORE_DEPRECATIONS
+#endif
+    }
+
+    return (!grab_failed);
+}

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
Xfce4-commits mailing list
Xfce4-commits@xfce.org
https://mail.xfce.org/mailman/listinfo/xfce4-commits

Reply via email to