aboutsummaryrefslogtreecommitdiff
path: root/src/terminal_modes.rs
diff options
context:
space:
mode:
authorJJ Liebig <jonathan.liebig@gmail.com>2026-09-18 02:42:37 +0200
committerGitHub <noreply@github.com>2026-09-18 02:42:37 +0200
commitda6bcd5969779bfe0396bcf89a8025d4375d611e (patch)
treeaece03633c003ba0fce01bc2564ad14e0fe9cac9 /src/terminal_modes.rs
parentb88e8116e9e1f7e2f6e8b211536311cd17feca9a (diff)
fix(windows): preserve mouse capture during refresh (#4319)
* fix(windows): preserve mouse capture during refresh refs #4284 * test(windows): fix default input gauntlet invocation * fix(windows): preserve pixel mouse transitions refs #4284
Diffstat (limited to 'src/terminal_modes.rs')
-rw-r--r--src/terminal_modes.rs21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/terminal_modes.rs b/src/terminal_modes.rs
index 11bf56fc..b3973209 100644
--- a/src/terminal_modes.rs
+++ b/src/terminal_modes.rs
@@ -21,15 +21,18 @@ pub(crate) fn set_windows_mouse_reporting<W: Write>(
enabled: bool,
sgr_pixels: bool,
) -> io::Result<()> {
- writer.write_all(if enabled {
- WINDOWS_MOUSE_REPORTING_ENABLE_SEQUENCE
+ if enabled {
+ // Keep a true-to-false pixel transition in the same buffered reassertion,
+ // before the final SGR enable, so refresh never exposes a disabled gap.
+ if !sgr_pixels {
+ writer.write_all(b"\x1b[?1016l")?;
+ }
+ writer.write_all(WINDOWS_MOUSE_REPORTING_ENABLE_SEQUENCE)?;
+ if sgr_pixels {
+ writer.write_all(b"\x1b[?1016h")?;
+ }
} else {
- WINDOWS_MOUSE_REPORTING_DISABLE_SEQUENCE
- })?;
- // The caller clears modes before native capture. Resetting 1016 here can
- // undo the SGR encoding that ConPTY has already enabled on the host.
- if enabled && sgr_pixels {
- writer.write_all(b"\x1b[?1016h")?;
+ writer.write_all(WINDOWS_MOUSE_REPORTING_DISABLE_SEQUENCE)?;
}
writer.flush()
}
@@ -195,7 +198,7 @@ mod tests {
assert_eq!(
output,
- b"\x1b[?1000h\x1b[?1002h\x1b[?1003h\x1b[?1006h\x1b[?1016h\x1b[?1000h\x1b[?1002h\x1b[?1003h\x1b[?1006h\x1b[?1016l\x1b[?1006l\x1b[?1003l\x1b[?1002l\x1b[?1000l"
+ b"\x1b[?1000h\x1b[?1002h\x1b[?1003h\x1b[?1006h\x1b[?1016h\x1b[?1016l\x1b[?1000h\x1b[?1002h\x1b[?1003h\x1b[?1006h\x1b[?1016l\x1b[?1006l\x1b[?1003l\x1b[?1002l\x1b[?1000l"
);
}
}