[hackers] [st][PATCH] Add configuration option for Meta modifier

From: Kyle Rose <krose_AT_krose.org>
Date: Sat, 12 Jul 2025 15:34:31 -0400

- Allow the user to specify an alternate modifier for Meta. Typically, Linux
  has Meta and Alt both mapped to Mod1, so this option defaults to Mod1Mask.
---
 config.def.h | 7 +++++++
 x.c          | 4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/config.def.h b/config.def.h
index b18f42e..45146f1 100644
--- a/config.def.h
+++ b/config.def.h
_AT_@ -170,6 +170,13 @@ static unsigned int defaultattr = 11;
  */
 static uint forcemousemod = ShiftMask;
 
+/*
+ * The modifier to be interpreted as Meta (e.g., for purposes of sending
+ * "\033<key>"). Defaults to Mod1Mask, which is typically Alt in Linux X11
+ * modifier configurations.
+ */
+static uint metamod = Mod1Mask;
+
 /*
  * Internal mouse shortcuts.
  * Beware that overloading Button1 will disable the selection.
diff --git a/x.c b/x.c
index d73152b..da54d69 100644
--- a/x.c
+++ b/x.c
_AT_@ -415,7 +415,7 @@ mousereport(XEvent *e)
 
 	if (!IS_SET(MODE_MOUSEX10)) {
 		code += ((state & ShiftMask  ) ?  4 : 0)
-		      + ((state & Mod1Mask   ) ?  8 : 0) /* meta key: alt */
+		      + ((state & metamod    ) ?  8 : 0) /* meta key: alt */
 		      + ((state & ControlMask) ? 16 : 0);
 	}
 
_AT_@ -1876,7 +1876,7 @@ kpress(XEvent *ev)
 	/* 3. composed string from input method */
 	if (len == 0)
 		return;
-	if (len == 1 && e->state & Mod1Mask) {
+	if (len == 1 && e->state & metamod) {
 		if (IS_SET(MODE_8BIT)) {
 			if (*buf < 0177) {
 				c = *buf | 0x80;
-- 
2.47.2
Received on Sat Jul 12 2025 - 21:34:31 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 14 2025 - 17:48:38 CEST