From da6bcd5969779bfe0396bcf89a8025d4375d611e Mon Sep 17 00:00:00 2001 From: JJ Liebig Date: Fri, 18 Sep 2026 02:42:37 +0200 Subject: 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 --- src/terminal_modes.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/terminal_modes.rs') 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( 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" ); } } -- cgit v1.2.3