Hello,

I've not had much time to look in to this, but have a look at the following
to see if it helps:

https://github.com/ThomasAdam/fvwm/tree/debian/bug/642151

Which you can checkout and build.  If you want a patch, see attached.

-- Thomas Adam

-- 
"Deep in my heart I wish I was wrong.  But deep in my heart I know I am
not." -- Morrissey ("Girl Least Likely To" -- off of Viva Hate.)
>From 6bd154f3d9556cf5657b52b09e99aba695befbba Mon Sep 17 00:00:00 2001
From: Thomas Adam <[email protected]>
Date: Sat, 1 Oct 2011 16:59:54 +0100
Subject: [PATCH] Update passive grabs tracking modifiers

In the case of GTK's link widget which doesn't handle passive grabs
following FVWM's window bindings (which assumes the underlying application
can handle a PointerReplay), update the grabs in this context by alwas
ungrabbing the button and grabbing it for modifiers other than
ALL_MODIFIERS.

Signed-off-by: Thomas Adam <[email protected]>
---
 fvwm/bindings.c |    7 +++++++
 fvwm/bindings.h |    1 +
 fvwm/events.c   |   27 +++++++++++++++++++++++++++
 3 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/fvwm/bindings.c b/fvwm/bindings.c
index 4cde680..6404e70 100644
--- a/fvwm/bindings.c
+++ b/fvwm/bindings.c
@@ -720,6 +720,13 @@ unsigned int GetUnusedModifiers(void)
 	return mods_unused;
 }
 
+/* Returns active modifiers. */
+unsigned int active_modifiers(void)
+{
+	return (~GetUnusedModifiers() & ALL_MODIFIERS);
+}
+
+
 /* ---------------------------- builtin commands --------------------------- */
 
 void CMD_Key(F_CMD_ARGS)
diff --git a/fvwm/bindings.h b/fvwm/bindings.h
index e3e6afa..86dd9a1 100644
--- a/fvwm/bindings.h
+++ b/fvwm/bindings.h
@@ -20,6 +20,7 @@
 void update_key_bindings(void);
 unsigned int MaskUsedModifiers(unsigned int in_modifiers);
 unsigned int GetUnusedModifiers(void);
+unsigned int active_modifiers(void);
 void print_bindings(void);
 
 #endif /* BINDINGS_H */
diff --git a/fvwm/events.c b/fvwm/events.c
index 3328c2e..46ec57f 100644
--- a/fvwm/events.c
+++ b/fvwm/events.c
@@ -66,6 +66,7 @@
 #include "libs/Colorset.h"
 #include "libs/charmap.h"
 #include "libs/wcontext.h"
+#include "libs/modifiers.h"
 #include "fvwm.h"
 #include "externs.h"
 #include "cursor.h"
@@ -158,6 +159,7 @@ static const FvwmWindow *xcrossing_last_grab_window = NULL;
 STROKE_CODE(static int send_motion);
 STROKE_CODE(static char sequence[STROKE_MAX_SEQUENCE + 1]);
 static event_group_t *base_event_group = NULL;
+static unsigned int event_modifiers = 0;
 
 /* ---------------------------- exported variables (globals) --------------- */
 
@@ -1702,7 +1704,17 @@ static void __handle_bpress_on_managed(const exec_context_t *exc)
 	/* clean up */
 	if (!f.do_swallow_click)
 	{
+		event_modifiers = (e->xbutton.state & active_modifiers());
+
 		/* pass the click to the application */
+
+		/* TA:  Ungrab the button based on the modifiers in use, so
+		 * that legitimate button presses aren't ignored.  GTK 3.x is
+		 * using passive grabs for some of its link widgets for
+		 * example.
+		 */
+		XUngrabButton(dpy, e->xbutton.button, event_modifiers, FW_W_PARENT(fw));
+
 		XAllowEvents(dpy, ReplayPointer, CurrentTime);
 		XFlush(dpy);
 	}
@@ -1741,6 +1753,21 @@ void HandleButtonPress(const evh_args_t *ea)
 	else if (ea->exc->w.fw != NULL)
 	{
 		__handle_bpress_on_managed(ea->exc);
+
+		if (event_modifiers > 0)
+		{
+			/* TA:  The passive grab was unbound because we sent
+			 * the click to the application.  We must restore it
+			 * *AFTER* handling the click from
+			 * __handle_bpress_on_managed()
+			 */
+			FvwmWindow* const fw = ea->exc->w.fw;
+			XEvent *e = ea->exc->x.etrigger;
+
+			XGrabButton(dpy, e->xbutton.button, event_modifiers, FW_W_PARENT(fw),
+					False, ButtonPressMask, GrabModeSync,
+					GrabModeAsync, None, None);
+		}
 	}
 	else
 	{
-- 
1.7.5.4

Reply via email to