Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConPTY: Inject W32IM sequences #17757

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/host/_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,10 @@ void WriteCharsVT(SCREEN_INFORMATION& screenInfo, const std::wstring_view& str)
write(offset, injection.offset);
offset = injection.offset;

static constexpr std::array<std::string_view, 2> mapping{ {
static constexpr std::array<std::string_view, 3> 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<size_t>(InjectionType::Count) == mapping.size(), "you need to update the mapping array");

Expand Down
9 changes: 8 additions & 1 deletion src/terminal/adapter/adaptDispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions src/terminal/parser/stateMachine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
Loading