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

From: Omar Sandoval <osandov_AT_osandov.com>
Date: Tue, 4 Apr 2017 14:49:53 -0700

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
_AT_@ -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
_AT_@ -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
Received on Tue Apr 04 2017 - 23:49:53 CEST

This archive was generated by hypermail 2.3.0 : Wed Apr 05 2017 - 00:00:32 CEST