From 89c88253f61ffb3112ef5935108eca2f5e7197df Mon Sep 17 00:00:00 2001 From: Anders Larsen Date: Tue, 1 Oct 2024 10:08:28 +0200 Subject: [PATCH] Fix Xterm216+ Alt-Fn on Windows On most keyboard modes the escape-sequence for Alt-Fn is the same as for Fn alone but with an additional ESC prepended. However, this additional ESC should not be sent for keyboard modes that sends a different escape-sequence when Alt is pressed, like e.g. Xterm216+, as this is not expected by the server-side application. Signed-off-by: Anders Larsen --- windows/window.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/windows/window.c b/windows/window.c index 8423a571..9108d4f7 100644 --- a/windows/window.c +++ b/windows/window.c @@ -4621,8 +4621,11 @@ static int TranslateKey(WinGuiSeat *wgs, UINT message, WPARAM wParam, p += format_function_key((char *)p, wgs->term, fkey_number, shift_state & 1, shift_state & 2, left_alt, &consumed_alt); - if (consumed_alt) - left_alt = false; /* supersedes the usual prefixing of Esc */ + if (consumed_alt) { + /* supersedes the usual prefixing of Esc */ + p -= 1; + memmove(output, output + 1, p - output); + } return p - output; SmallKeypadKey sk_key; @@ -4637,11 +4640,15 @@ static int TranslateKey(WinGuiSeat *wgs, UINT message, WPARAM wParam, if (shift_state & 2) break; + consumed_alt = false; p += format_small_keypad_key((char *)p, wgs->term, sk_key, shift_state & 1, shift_state & 2, left_alt, &consumed_alt); - if (consumed_alt) - left_alt = false; /* supersedes the usual prefixing of Esc */ + if (consumed_alt) { + /* supersedes the usual prefixing of Esc */ + p -= 1; + memmove(output, output + 1, p - output); + } return p - output; char xkey; @@ -4654,8 +4661,11 @@ static int TranslateKey(WinGuiSeat *wgs, UINT message, WPARAM wParam, consumed_alt = false; p += format_arrow_key((char *)p, wgs->term, xkey, shift_state & 1, shift_state & 2, left_alt, &consumed_alt); - if (consumed_alt) - left_alt = false; /* supersedes the usual prefixing of Esc */ + if (consumed_alt) { + /* supersedes the usual prefixing of Esc */ + p -= 1; + memmove(output, output + 1, p - output); + } return p - output; case VK_RETURN: