[Xfce4-commits] [panel-plugins/xfce4-clipman-plugin] 01/01: Use the xfce_gtk_menu_popup_until_mapped (bumps libxfce4ui to 4.13)
noreply at xfce.org
noreply at xfce.org
Mon Jun 13 19:49:38 CEST 2016
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 ce62e1fb5143cb27777ea88b3583ff03ada11a24
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date: Mon Jun 13 19:47:59 2016 +0200
Use the xfce_gtk_menu_popup_until_mapped (bumps libxfce4ui to 4.13)
---
configure.ac.in | 2 +-
panel-plugin/Makefile.am | 1 -
panel-plugin/plugin.c | 95 ++++++++++--------------------------------------
3 files changed, 21 insertions(+), 77 deletions(-)
diff --git a/configure.ac.in b/configure.ac.in
index 32cb22a..b73789e 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.12.0])
+XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-2], [4.13.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 26259f2..9a7e432 100644
--- a/panel-plugin/Makefile.am
+++ b/panel-plugin/Makefile.am
@@ -222,4 +222,3 @@ 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 a0050d6..8055490 100644
--- a/panel-plugin/plugin.c
+++ b/panel-plugin/plugin.c
@@ -26,6 +26,7 @@
#include <gtk/gtk.h>
#include <xfconf/xfconf.h>
#include <libxfce4util/libxfce4util.h>
+#include <libxfce4ui/libxfce4ui.h>
#ifdef PANEL_PLUGIN
#include <libxfce4panel/libxfce4panel.h>
@@ -46,8 +47,6 @@ 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);
@@ -351,32 +350,31 @@ 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));
- if(!gtk_widget_has_grab(plugin->menu))
- {
- gtk_grab_add(plugin->menu);
- }
+ 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).");
- 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
-
- 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 ());
+ 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).");
#endif
}
@@ -437,8 +435,6 @@ 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)
@@ -448,12 +444,6 @@ 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'))
{
@@ -463,8 +453,8 @@ G_GNUC_END_IGNORE_DEPRECATIONS
if (xfconf_channel_get_bool (plugin->channel, "/tweaks/popup-at-pointer", FALSE))
{
- gtk_menu_popup (GTK_MENU (plugin->menu), NULL, NULL, NULL, NULL,
- 0, gtk_get_current_event_time ());
+ xfce_gtk_menu_popup_until_mapped (GTK_MENU (plugin->menu), NULL, NULL, NULL, NULL,
+ 0, gtk_get_current_event_time ());
}
else
{
@@ -490,48 +480,3 @@ 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.
More information about the Xfce4-commits
mailing list