Re: [hackers] [PATCH] Whitelist key event modifiers for shortcuts

2017-04-10 Thread Roberto E . Vargas Caballero
> I'm seeing a weird issue with my xserver where all key press events will
> be set with (state & Button1Mask), which ends up breaking all st
> keyboard shortcuts. xterm works correctly because it whitelists
> modifiers relevant to key press events. Do the same in st.


Uhmmm, it seems a bit strange.  Why does your xserver do that?.  I
think your patch isn't wrong, but I think what you describe shouldn't
happen, and I would like to know a bit about it before applyin the
patch.

Regards,




[hackers] [PATCH] Whitelist key event modifiers for shortcuts

2017-04-04 Thread Omar Sandoval
I'm seeing a weird issue with my xserver where all key press events will
be set with (state & Button1Mask), which ends up breaking all st
keyboard shortcuts. xterm works correctly because it whitelists
modifiers relevant to key press events. Do the same in st.
---
I haven't figured out why events are being reported like this, but
seeing as everything else but st works, I think we should handle it.

 st.c  | 3 ++-
 win.h | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/st.c b/st.c
index ae93ade..5184761 100644
--- a/st.c
+++ b/st.c
@@ -2619,7 +2619,8 @@ redraw(void)
 int
 match(uint mask, uint state)
 {
-   return mask == XK_ANY_MOD || mask == (state & ~ignoremod);
+   return (mask == XK_ANY_MOD ||
+   mask == (state & KeyModifiers & ~ignoremod));
 }
 
 void
diff --git a/win.h b/win.h
index 428111c..64974c2 100644
--- a/win.h
+++ b/win.h
@@ -5,6 +5,9 @@
 #define XK_NO_MOD 0
 #define XK_SWITCH_MOD (1<<13)
 
+#define KeyModifiers (ShiftMask | LockMask | ControlMask | Mod1Mask | \
+ Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask)
+
 typedef XftGlyphFontSpec GlyphFontSpec;
 
 void draw(void);
-- 
2.12.2