diff --git a/src/host/_stream.cpp b/src/host/_stream.cpp index 82dda40ef9b..85cadb1cfef 100644 --- a/src/host/_stream.cpp +++ b/src/host/_stream.cpp @@ -371,9 +371,10 @@ void WriteCharsVT(SCREEN_INFORMATION& screenInfo, const std::wstring_view& str) write(offset, injection.offset); offset = injection.offset; - static constexpr std::array mapping{ { + static constexpr std::array mapping{ { { "\x1b[?1004h\x1b[?9001h" }, // RIS: Focus Event Mode + Win32 Input Mode - { "\x1b[?1004h" } // DECSET_FOCUS: Focus Event Mode + { "\x1b[?1004h" }, // DECSET_FOCUS: Focus Event Mode + { "\x1b[?9001h" }, // Win32 Input Mode } }; static_assert(static_cast(InjectionType::Count) == mapping.size(), "you need to update the mapping array"); diff --git a/src/terminal/adapter/adaptDispatch.cpp b/src/terminal/adapter/adaptDispatch.cpp index 3aca2abfdf9..26f1a7c41a8 100644 --- a/src/terminal/adapter/adaptDispatch.cpp +++ b/src/terminal/adapter/adaptDispatch.cpp @@ -1999,7 +1999,10 @@ bool AdaptDispatch::_ModeParamsHelper(const DispatchTypes::ModeParams param, con case DispatchTypes::ModeParams::FOCUS_EVENT_MODE: _terminalInput.SetInputMode(TerminalInput::Mode::FocusEvent, enable); // ConPTY always wants to know about focus events, so let it know that it needs to re-enable this mode. - _api.GetStateMachine().InjectSequence(InjectionType::DECSET_FOCUS); + if (!enable) + { + _api.GetStateMachine().InjectSequence(InjectionType::DECSET_FOCUS); + } return true; case DispatchTypes::ModeParams::ALTERNATE_SCROLL: _terminalInput.SetInputMode(TerminalInput::Mode::AlternateScroll, enable); @@ -2020,6 +2023,10 @@ bool AdaptDispatch::_ModeParamsHelper(const DispatchTypes::ModeParams param, con // It also makes more sense to not bubble it up, because this mode is specifically for INPUT_RECORD interop // and thus entirely between a PTY's input records and its INPUT_RECORD-aware VT-aware console clients. // Returning true here will mark this as being handled and avoid this. + if (!enable) + { + _api.GetStateMachine().InjectSequence(InjectionType::W32IM); + } return true; default: // If no functions to call, overall dispatch was a failure. diff --git a/src/terminal/parser/stateMachine.hpp b/src/terminal/parser/stateMachine.hpp index 353bdb26f3e..a1c0fed8f67 100644 --- a/src/terminal/parser/stateMachine.hpp +++ b/src/terminal/parser/stateMachine.hpp @@ -42,8 +42,9 @@ namespace Microsoft::Console::VirtualTerminal // parser tells it the positions of any such relevant VT sequences. enum class InjectionType : size_t { - RIS, - DECSET_FOCUS, + RIS, // All of the below + DECSET_FOCUS, // CSI ? 1004 h + W32IM, // CSI ? 9001 h Count, };