terminal: fix encoding of mouse buttons 6 and 7 in mouse events

These two buttons were encoded using the *exact* same numbers as
button 4 and 5 (scroll wheel up/down), making it impossible to
distinguish them.

The relevant section from XTerm’s control sequences documentation is:

    Some wheel mice can send additional button events, e.g., by tilting the
    scroll wheel left and right.

    Additional buttons are encoded like the wheel mice,

    o  by adding 64 (for buttons 6 and 7), or

    o  by adding 128 (for buttons 8 through 11).
This commit is contained in:
Daniel Eklöf 2021-01-22 17:03:43 +01:00
parent e642373658
commit 000ddd900a
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 2 additions and 5 deletions

View file

@ -82,6 +82,7 @@
* Sixel “current geometry” query response not being bounded by the
current window dimensions (fixes `lsix` output)
* Crash on keyboard input when repeat rate was zero (i.e. no repeat).
* Wrong button encoding of mouse buttons 6 and 7 in mouse events.
### Security

View file

@ -2366,14 +2366,10 @@ encode_xbutton(int xbutton)
case 1: case 2: case 3:
return xbutton - 1;
case 4: case 5:
case 4: case 5: case 6: case 7:
/* Like button 1 and 2, but with 64 added */
return xbutton - 4 + 64;
case 6: case 7:
/* Same as 4 and 5. Note: the offset should be something else? */
return xbutton - 6 + 64;
case 8: case 9: case 10: case 11:
/* Similar to 4 and 5, but adding 128 instead of 64 */
return xbutton - 8 + 128;