[Xfce4-commits] [panel-plugins/xfce4-clipman-plugin] 03/03: Reimplement old gdk_keyboard_grab code to fix popup from keyboard shortcut
noreply at xfce.org
noreply at xfce.org
Fri Mar 24 12:35:42 CET 2017
This is an automated email from the git hooks/post-receive script.
mmassonnet pushed a commit to branch master
in repository panel-plugins/xfce4-clipman-plugin.
commit 3e74f160b4dde5d93825b464bcf579e060759da2
Author: Mike Massonnet <m8t at gandi.net>
Date: Fri Mar 24 12:07:29 2017 +0100
Reimplement old gdk_keyboard_grab code to fix popup from keyboard shortcut
---
panel-plugin/xfce4-popup-clipman.c | 48 +++++++++++++++++++++++++++++++++-----
1 file changed, 42 insertions(+), 6 deletions(-)
diff --git a/panel-plugin/xfce4-popup-clipman.c b/panel-plugin/xfce4-popup-clipman.c
index 3dc39b6..fef6478 100644
--- a/panel-plugin/xfce4-popup-clipman.c
+++ b/panel-plugin/xfce4-popup-clipman.c
@@ -25,6 +25,47 @@
#include <gtk/gtk.h>
+
+/* Initial code was taken from xfwm4/src/menu.c:grab_available().
+ * TODO replace deprecated GTK/GDK functions.
+ */
+static gboolean
+grab_keyboard ()
+{
+ guint32 timestamp = GDK_CURRENT_TIME;
+ GdkScreen *screen = gdk_screen_get_default ();
+ GdkWindow *win = gdk_screen_get_root_window (screen);
+ GdkEventMask mask =
+ GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
+ GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |
+ GDK_POINTER_MOTION_MASK;
+ GdkGrabStatus grab_status;
+ gboolean grab_failed = FALSE;
+ gint i = 0;
+
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+ grab_status = gdk_keyboard_grab (win, TRUE, timestamp);
+G_GNUC_END_IGNORE_DEPRECATIONS
+
+ while ((i++ < 2500) && (grab_status != GDK_GRAB_SUCCESS))
+ {
+ g_usleep (1000);
+ if (grab_status != GDK_GRAB_SUCCESS)
+ {
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+ grab_status = gdk_keyboard_grab (win, TRUE, timestamp);
+G_GNUC_END_IGNORE_DEPRECATIONS
+ }
+ }
+
+ if (grab_status == GDK_GRAB_SUCCESS)
+ {
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+ gdk_keyboard_ungrab (timestamp);
+G_GNUC_END_IGNORE_DEPRECATIONS
+ }
+}
+
gint
main (gint argc, gchar *argv[])
{
@@ -44,14 +85,9 @@ main (gint argc, gchar *argv[])
if (g_application_get_is_remote (G_APPLICATION (app)))
{
- /* FIXME g_usleep is a workaround when using the popup command through a
- * keyboard shortcut, in fact the code needs to call gdk_seat_grb/ungrab
- * for the gtkmenu to show up.
- */
- g_usleep(500000);
+ grab_keyboard ();
g_application_activate (G_APPLICATION (app));
g_object_unref (app);
- return 0;
}
else
{
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list