aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2021-03-19 11:54:36 +0100
committersinanmohd <pcmsinan@gmail.com>2023-01-12 08:19:29 +0530
commitb2617f7b7d70015dca3e7856299de6fae5232cc5 (patch)
treea50897be0b7288cbf9343b67ceb3e74653cc0e12
parent09b002d7d6a63f8dee7abc373fa36a074d236cab (diff)
fix: correctly encode mouse buttons >= 8 in X10 and SGR mode
These are typically mapped in X11 to the side-buttons (backward/forwards) on the mouse. A comparison of the button numbers in SGR mode (first field): st old: 0 1 2 64 65 66 67 68 69 70 st new (it is the same as xterm now): 0 1 2 64 65 66 67 128 129 130 A script to test and reproduce it, first argument is "h" (on) or "l" (off): #!/bin/sh printf '\x1b[?1000%s\x1b[?1006%s' "$1" "$1" for n in 1 2 3 4 5 6 7 8 9 10; do printf 'button %d\n' "$n" xdotool click "$n" printf '\n\n' done
-rw-r--r--x.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/x.c b/x.c
index 9b2faee..4b26aae 100644
--- a/x.c
+++ b/x.c
@@ -407,7 +407,9 @@ mousereport(XEvent *e)
button = 3;
} else {
button -= Button1;
- if (button >= 3)
+ if (button >= 7)
+ button += 128 - 7;
+ else if (button >= 3)
button += 64 - 3;
}
if (e->xbutton.type == ButtonPress) {