summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm>2020-11-09 10:54:28 +0000
committernicm <nicm>2020-11-09 10:54:28 +0000
commitf1193b48910aed15a2c73cdb5784a26f2ea0f64c (patch)
tree95b4bb054033509520a3927698c472402e4a050a
parent61e55fa50dc7119a8c88bb385e615a8e6c8d6a85 (diff)
If mouse bits change, clear them all and set again to avoid problems
with some bits implying others. GitHub issue 2458.
-rw-r--r--tty.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/tty.c b/tty.c
index bcbccca6..777b639b 100644
--- a/tty.c
+++ b/tty.c
@@ -694,28 +694,26 @@ tty_update_mode(struct tty *tty, int mode, struct screen *s)
}
if ((changed & ALL_MOUSE_MODES) &&
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");
- if ((changed & MODE_MOUSE_STANDARD) &&
- (~mode & MODE_MOUSE_STANDARD))
+ if (tty->mode & MODE_MOUSE_STANDARD)
tty_puts(tty, "\033[?1000l");
- if ((changed & MODE_MOUSE_BUTTON) &&
- (~mode & MODE_MOUSE_BUTTON))
+ if (tty->mode & MODE_MOUSE_BUTTON)
tty_puts(tty, "\033[?1002l");
- if ((changed & MODE_MOUSE_ALL) &&
- (~mode & MODE_MOUSE_ALL))
+ if (tty->mode & MODE_MOUSE_ALL)
tty_puts(tty, "\033[?1003l");
-
if (mode & ALL_MOUSE_MODES)
tty_puts(tty, "\033[?1006h");
- if ((changed & MODE_MOUSE_STANDARD) &&
- (mode & MODE_MOUSE_STANDARD))
+ if (mode & MODE_MOUSE_STANDARD)
tty_puts(tty, "\033[?1000h");
- if ((changed & MODE_MOUSE_BUTTON) &&
- (mode & MODE_MOUSE_BUTTON))
+ if (mode & MODE_MOUSE_BUTTON)
tty_puts(tty, "\033[?1002h");
- if ((changed & MODE_MOUSE_ALL) &&
- (mode & MODE_MOUSE_ALL))
+ if (mode & MODE_MOUSE_ALL)
tty_puts(tty, "\033[?1003h");
}
if (changed & MODE_BRACKETPASTE) {