[hackers] [st] fix: correctly encode mouse buttons >= 8 in X10 and SGR mode || Hiltjo Posthuma

From: <git_AT_suckless.org>
Date: Fri, 19 Mar 2021 12:01:34 +0100 (CET)

commit 9e68fdbcdb06dfa3d23fe3a7a7f7b59e40e1ea2f
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
AuthorDate: Fri Mar 19 11:54:36 2021 +0100
Commit: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
CommitDate: Fri Mar 19 11:58:59 2021 +0100

    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

diff --git a/x.c b/x.c
index 120e495..8bf998e 100644
--- a/x.c
+++ b/x.c
_AT_@ -387,7 +387,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) {
Received on Fri Mar 19 2021 - 12:01:34 CET

This archive was generated by hypermail 2.3.0 : Fri Mar 19 2021 - 12:12:36 CET