If mouse bits change, clear them all and set again to avoid problems

with some bits implying others. GitHub issue 2458.
This commit is contained in:
nicm 2020-11-09 10:54:28 +00:00
parent 61e55fa50d
commit f1193b4891

26
tty.c
View File

@ -694,28 +694,26 @@ tty_update_mode(struct tty *tty, int mode, struct screen *s)
} }
if ((changed & ALL_MOUSE_MODES) && if ((changed & ALL_MOUSE_MODES) &&
tty_term_has(tty->term, TTYC_KMOUS)) { tty_term_has(tty->term, TTYC_KMOUS)) {
if ((mode & ALL_MOUSE_MODES) == 0) /*
* If the mouse modes have changed, clear any that are set and
* apply again. There are differences in how terminals track
* the various bits.
*/
if (tty->mode & MODE_MOUSE_SGR)
tty_puts(tty, "\033[?1006l"); tty_puts(tty, "\033[?1006l");
if ((changed & MODE_MOUSE_STANDARD) && if (tty->mode & MODE_MOUSE_STANDARD)
(~mode & MODE_MOUSE_STANDARD))
tty_puts(tty, "\033[?1000l"); tty_puts(tty, "\033[?1000l");
if ((changed & MODE_MOUSE_BUTTON) && if (tty->mode & MODE_MOUSE_BUTTON)
(~mode & MODE_MOUSE_BUTTON))
tty_puts(tty, "\033[?1002l"); tty_puts(tty, "\033[?1002l");
if ((changed & MODE_MOUSE_ALL) && if (tty->mode & MODE_MOUSE_ALL)
(~mode & MODE_MOUSE_ALL))
tty_puts(tty, "\033[?1003l"); tty_puts(tty, "\033[?1003l");
if (mode & ALL_MOUSE_MODES) if (mode & ALL_MOUSE_MODES)
tty_puts(tty, "\033[?1006h"); tty_puts(tty, "\033[?1006h");
if ((changed & MODE_MOUSE_STANDARD) && if (mode & MODE_MOUSE_STANDARD)
(mode & MODE_MOUSE_STANDARD))
tty_puts(tty, "\033[?1000h"); tty_puts(tty, "\033[?1000h");
if ((changed & MODE_MOUSE_BUTTON) && if (mode & MODE_MOUSE_BUTTON)
(mode & MODE_MOUSE_BUTTON))
tty_puts(tty, "\033[?1002h"); tty_puts(tty, "\033[?1002h");
if ((changed & MODE_MOUSE_ALL) && if (mode & MODE_MOUSE_ALL)
(mode & MODE_MOUSE_ALL))
tty_puts(tty, "\033[?1003h"); tty_puts(tty, "\033[?1003h");
} }
if (changed & MODE_BRACKETPASTE) { if (changed & MODE_BRACKETPASTE) {