This patch replaces the previous one I sent.
The following changes are made in this patch:
- Fix tracking of pressed buttons. Previously, pressing two buttons and
then releasing one would make st think no buttons are pressed, which
in particular broke MODE_MOUSEMOTION.
- Always send the lowest-numbered pressed button on motion events; when
no button is pressed for a motion event in MODE_MOUSEMANY, then send
a release. This matches the behaviour of xterm. (Previously, st sent
the most recently pressed button in the motion report.)
- Remove UB (?) access to potentially inactive struct member
e->xbutton.button of XEvent union.
- Fix (unlikely) possibility of overflow for large button numbers.
The one discrepancy I found between st and xterm is that xterm sometimes
encodes buttons with large numbers (>5) strangely. E.g., xterm reports
presses of buttons 8 and 9 as releases, whereas st properly (?) encodes
them as presses.
Ref.
- https://git.suckless.org/st/commit/ea7cd7b62fdfa6a1fbd882d1565d557577f2cf32.html
from the XmbTextListToTextProperty(3) man page:
"If insufficient memory is available for the new value string, the functions
return XNoMemory. If the current locale is not supported, the functions return
XLocaleNotSupported. In both of these error cases, the functions do not set
text_prop_return."
Reported by Steffen Nurpmeso <steffen@sdaoden.eu>, thanks!
Ref. https://git.suckless.org/st/commit/2f6e597ed871cff91c627850d03152cae5f45779.html
The bits of uint signal in an XKeyEvent which concern the key group (keyboard
layout) are bits 13 and 14, as documented here:
https://www.x.org/releases/X11R7.7/doc/libX11/XKB/xkblib.html#Groups_and_Shift_Levels
In the older version, only bit 13 was marked as part of XK_SWITCH_MOD, this
causes issues for users who have more than two keymaps. The 14th bit is not
in ignoremod, key sequences are not caught by match(), if they switch to a third
or fourth keyboard.
If the mouse cursor is changed to a bar or an underline then st will use that
when the terminal is first opened. When an application that changes the cursor
via escape sequences is executed, e.g. vim which uses a block cursor by default,
then that cursor will remain after exiting the program.
This change sets the cursor back to default when exiting alt 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
https://git.suckless.org/st/commit/9e68fdbcdb06dfa3d23fe3a7a7f7b59e40e1ea2f.html