Merged PR 5938254: Migrate OSS up to dba66da18

Related work items: MSFT-32512353
This commit is contained in:
Dustin Howett 2021-04-15 16:59:04 +00:00
commit d7f690d7fc
26 changed files with 259 additions and 22 deletions

View file

@ -5,7 +5,7 @@
<XesUseOneStoreVersioning>true</XesUseOneStoreVersioning>
<XesBaseYearForStoreVersion>2021</XesBaseYearForStoreVersion>
<VersionMajor>1</VersionMajor>
<VersionMinor>8</VersionMinor>
<VersionMinor>9</VersionMinor>
<VersionInfoProductName>Windows Terminal</VersionInfoProductName>
</PropertyGroup>
</Project>

View file

@ -4,9 +4,9 @@
"title": "Microsoft's Windows Terminal Settings Profile Schema",
"definitions": {
"KeyChordSegment": {
"pattern": "^(?<modifier>(ctrl|alt|shift)(?:\\+(ctrl|alt|shift)(?<!\\2))?(?:\\+(ctrl|alt|shift)(?<!\\2|\\3))?\\+)?(?<key>[^\\s+]|app|menu|backspace|tab|enter|esc|escape|space|pgup|pageup|pgdn|pagedown|end|home|left|up|right|down|insert|delete|(?<!shift.+)(?:numpad_?[0-9]|numpad_(?:period|decimal))|numpad_(?:multiply|plus|add|minus|subtract|divide)|f[1-9]|f1[0-9]|f2[0-4]|plus)$",
"pattern": "^(?<modifier>(?<mod1>ctrl|alt|shift|win)(?:\\+(?<mod2>ctrl|alt|shift|win)(?<!\\k<mod1>))?(?:\\+(?<mod3>ctrl|alt|shift|win)(?<!\\k<mod1>|\\k<mod2>))?(?:\\+(?<mod4>ctrl|alt|shift|win)(?<!\\k<mod1>|\\k<mod2>|\\k<mod3>))?\\+)?(?<key>[^\\s+]|app|menu|backspace|tab|enter|esc|escape|space|pgup|pageup|pgdn|pagedown|end|home|left|up|right|down|insert|delete|(?<!shift.+)(?:numpad_?[0-9]|numpad_(?:period|decimal))|numpad_(?:multiply|plus|add|minus|subtract|divide)|f[1-9]|f1[0-9]|f2[0-4]|plus)$",
"type": "string",
"description": "The string should fit the format \"[ctrl+][alt+][shift+]<keyName>\", where each modifier is optional, separated by + symbols, and keyName is either one of the names listed in the table below, or any single key character. The string should be written in full lowercase.\napp, menu\tMENU key\nbackspace\tBACKSPACE key\ntab\tTAB key\nenter\tENTER key\nesc, escape\tESC key\nspace\tSPACEBAR\npgup, pageup\tPAGE UP key\npgdn, pagedown\tPAGE DOWN key\nend\tEND key\nhome\tHOME key\nleft\tLEFT ARROW key\nup\tUP ARROW key\nright\tRIGHT ARROW key\ndown\tDOWN ARROW key\ninsert\tINS key\ndelete\tDEL key\nnumpad_0-numpad_9, numpad0-numpad9\tNumeric keypad keys 0 to 9. Can't be combined with the shift modifier.\nnumpad_multiply\tNumeric keypad MULTIPLY key (*)\nnumpad_plus, numpad_add\tNumeric keypad ADD key (+)\nnumpad_minus, numpad_subtract\tNumeric keypad SUBTRACT key (-)\nnumpad_period, numpad_decimal\tNumeric keypad DECIMAL key (.). Can't be combined with the shift modifier.\nnumpad_divide\tNumeric keypad DIVIDE key (/)\nf1-f24\tF1 to F24 function keys\nplus\tADD key (+)"
"description": "The string should fit the format \"[ctrl+][alt+][shift+][win+]<keyName>\", where each modifier is optional, separated by + symbols, and keyName is either one of the names listed in the table below, or any single key character. The string should be written in full lowercase.\napp, menu\tMENU key\nbackspace\tBACKSPACE key\ntab\tTAB key\nenter\tENTER key\nesc, escape\tESC key\nspace\tSPACEBAR\npgup, pageup\tPAGE UP key\npgdn, pagedown\tPAGE DOWN key\nend\tEND key\nhome\tHOME key\nleft\tLEFT ARROW key\nup\tUP ARROW key\nright\tRIGHT ARROW key\ndown\tDOWN ARROW key\ninsert\tINS key\ndelete\tDEL key\nnumpad_0-numpad_9, numpad0-numpad9\tNumeric keypad keys 0 to 9. Can't be combined with the shift modifier.\nnumpad_multiply\tNumeric keypad MULTIPLY key (*)\nnumpad_plus, numpad_add\tNumeric keypad ADD key (+)\nnumpad_minus, numpad_subtract\tNumeric keypad SUBTRACT key (-)\nnumpad_period, numpad_decimal\tNumeric keypad DECIMAL key (.). Can't be combined with the shift modifier.\nnumpad_divide\tNumeric keypad DIVIDE key (/)\nf1-f24\tF1 to F24 function keys\nplus\tADD key (+)"
},
"Color": {
"default": "#",

View file

@ -27,7 +27,7 @@ Below is the schedule for when milestones will be included in release builds of
| 2020-11-30 | [1.5] in Windows Terminal Preview<br>[1.4] in Windows Terminal | [Windows Terminal Preview 1.5 Release](https://devblogs.microsoft.com/commandline/windows-terminal-preview-1-5-release/) |
| 2021-01-31 | [1.6] in Windows Terminal Preview<br>[1.5] in Windows Terminal | [Windows Terminal Preview 1.6 Release](https://devblogs.microsoft.com/commandline/windows-terminal-preview-1-6-release/) |
| 2021-03-01 | [1.7] in Windows Terminal Preview<br>[1.6] in Windows Terminal | [Windows Terminal Preview 1.7 Release](https://devblogs.microsoft.com/commandline/windows-terminal-preview-1-7-release/) |
| 2021-04-30 | [1.8] in Windows Terminal Preview<br>[1.7] in Windows Terminal | |
| 2021-04-14 | [1.8] in Windows Terminal Preview<br>[1.7] in Windows Terminal | [Windows Terminal Preview 1.8 Release](https://devblogs.microsoft.com/commandline/windows-terminal-preview-1-8-release/) |
| 2021-05-31 | [1.9] in Windows Terminal Preview<br>[1.8] in Windows Terminal | |
| 2021-07-31 | 1.10 in Windows Terminal Preview<br>[1.9] in Windows Terminal | |
| 2021-08-30 | 1.11 in Windows Terminal Preview<br>1.10 in Windows Terminal | |

View file

@ -954,6 +954,10 @@ namespace TerminalAppLocalTests
void TabTests::TestWindowRenameSuccessful()
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_METHOD_PROPERTY(L"IsolationLevel", L"Method")
END_TEST_METHOD_PROPERTIES()
auto page = _commonSetup();
page->RenameWindowRequested([&page](auto&&, const winrt::TerminalApp::RenameWindowRequestedArgs args) {
// In the real terminal, this would bounce up to the monarch and
@ -980,6 +984,10 @@ namespace TerminalAppLocalTests
}
void TabTests::TestWindowRenameFailure()
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_METHOD_PROPERTY(L"IsolationLevel", L"Method")
END_TEST_METHOD_PROPERTIES()
auto page = _commonSetup();
page->RenameWindowRequested([&page](auto&&, auto&&) {
// In the real terminal, this would bounce up to the monarch and

View file

@ -719,9 +719,9 @@ namespace winrt::TerminalApp::implementation
const auto newName = realArgs.Name();
const auto request = winrt::make_self<implementation::RenameWindowRequestedArgs>(newName);
_RenameWindowRequestedHandlers(*this, *request);
args.Handled(true);
}
}
args.Handled(false);
}
void TerminalPage::_HandleOpenWindowRenamer(const IInspectable& /*sender*/,

View file

@ -1360,6 +1360,11 @@ namespace winrt::TerminalApp::implementation
buffer += L"Alt+";
}
if (WI_IsFlagSet(modifiers, KeyModifiers::Windows))
{
buffer += L"Win+";
}
return buffer;
}
@ -2708,8 +2713,12 @@ namespace winrt::TerminalApp::implementation
void TerminalPage::_RequestWindowRename(const winrt::hstring& newName)
{
auto request = winrt::make<implementation::RenameWindowRequestedArgs>(newName);
// The WindowRenamer is _not_ a Toast - we want it to stay open until the user dismisses it.
WindowRenamer().IsOpen(false);
// The WindowRenamer is _not_ a Toast - we want it to stay open until
// the user dismisses it.
if (WindowRenamer())
{
WindowRenamer().IsOpen(false);
}
_RenameWindowRequestedHandlers(*this, request);
// We can't just use request.Successful here, because the handler might
// (will) be handling this asynchronously, so when control returns to

View file

@ -132,6 +132,8 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
THROW_LAST_ERROR_IF_NULL(_hOutputThread);
LOG_IF_FAILED(SetThreadDescription(_hOutputThread.get(), L"AzureConnection Output Thread"));
_transitionToState(ConnectionState::Connecting);
}

View file

@ -278,6 +278,8 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
THROW_LAST_ERROR_IF_NULL(_hOutputThread);
LOG_IF_FAILED(SetThreadDescription(_hOutputThread.get(), L"ConptyConnection Output Thread"));
_clientExitWait.reset(CreateThreadpoolWait(
[](PTP_CALLBACK_INSTANCE /*callbackInstance*/, PVOID context, PTP_WAIT /*wait*/, TP_WAIT_RESULT /*waitResult*/) noexcept {
ConptyConnection* const pInstance = static_cast<ConptyConnection*>(context);

View file

@ -22,6 +22,15 @@ namespace winrt::Microsoft::Terminal::Control::implementation
{
}
KeyChord::KeyChord(bool ctrl, bool alt, bool shift, bool win, int32_t vkey) noexcept :
_modifiers{ (ctrl ? Control::KeyModifiers::Ctrl : Control::KeyModifiers::None) |
(alt ? Control::KeyModifiers::Alt : Control::KeyModifiers::None) |
(shift ? Control::KeyModifiers::Shift : Control::KeyModifiers::None) |
(win ? Control::KeyModifiers::Windows : Control::KeyModifiers::None) },
_vkey{ vkey }
{
}
KeyChord::KeyChord(Control::KeyModifiers const& modifiers, int32_t vkey) noexcept :
_modifiers{ modifiers },
_vkey{ vkey }

View file

@ -12,6 +12,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
KeyChord() noexcept;
KeyChord(Control::KeyModifiers const& modifiers, int32_t vkey) noexcept;
KeyChord(bool ctrl, bool alt, bool shift, int32_t vkey) noexcept;
KeyChord(bool ctrl, bool alt, bool shift, bool win, int32_t vkey) noexcept;
Control::KeyModifiers Modifiers() noexcept;
void Modifiers(Control::KeyModifiers const& value) noexcept;

View file

@ -9,7 +9,8 @@ namespace Microsoft.Terminal.Control
None = 0x0000,
Alt = 0x0001,
Ctrl = 0x0002,
Shift = 0x0004
Shift = 0x0004,
Windows = 0x0008
};
[default_interface]
@ -18,6 +19,7 @@ namespace Microsoft.Terminal.Control
KeyChord();
KeyChord(KeyModifiers modifiers, Int32 vkey);
KeyChord(Boolean ctrl, Boolean alt, Boolean shift, Int32 vkey);
KeyChord(Boolean ctrl, Boolean alt, Boolean shift, Boolean win, Int32 vkey);
KeyModifiers Modifiers;
Int32 Vkey;

View file

@ -39,6 +39,9 @@ constexpr const auto TsfRedrawInterval = std::chrono::milliseconds(100);
// The minimum delay between updating the locations of regex patterns
constexpr const auto UpdatePatternLocationsInterval = std::chrono::milliseconds(500);
// The minimum delay between emitting warning bells
constexpr const auto TerminalWarningBellInterval = std::chrono::milliseconds(1000);
DEFINE_ENUM_FLAG_OPERATORS(winrt::Microsoft::Terminal::Control::CopyFormat);
namespace winrt::Microsoft::Terminal::Control::implementation
@ -91,7 +94,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// GH#8969: pre-seed working directory to prevent potential races
_terminal->SetWorkingDirectory(_settings.StartingDirectory());
auto pfnWarningBell = std::bind(&TermControl::_TerminalWarningBell, this);
auto pfnWarningBell = [this]() {
_playWarningBell->Run();
};
_terminal->SetWarningBellCallback(pfnWarningBell);
auto pfnTitleChanged = std::bind(&TermControl::_TerminalTitleChanged, this, std::placeholders::_1);
@ -167,6 +172,16 @@ namespace winrt::Microsoft::Terminal::Control::implementation
UpdatePatternLocationsInterval,
Dispatcher());
_playWarningBell = std::make_shared<ThrottledFunc<>>(
[weakThis = get_weak()]() {
if (auto control{ weakThis.get() })
{
control->_TerminalWarningBell();
}
},
TerminalWarningBellInterval,
Dispatcher());
_updateScrollBar = std::make_shared<ThrottledFunc<ScrollBarUpdate>>(
[weakThis = get_weak()](const auto& update) {
if (auto control{ weakThis.get() })
@ -481,11 +496,14 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// Update the terminal core with its new Core settings
_terminal->UpdateAppearance(newAppearance);
// Update DxEngine settings under the lock
_renderEngine->SetSelectionBackground(til::color{ newAppearance.SelectionBackground() });
_renderEngine->SetRetroTerminalEffect(newAppearance.RetroTerminalEffect());
_renderEngine->SetPixelShaderPath(newAppearance.PixelShaderPath());
_renderer->TriggerRedrawAll();
if (_renderEngine)
{
// Update DxEngine settings under the lock
_renderEngine->SetSelectionBackground(til::color{ newAppearance.SelectionBackground() });
_renderEngine->SetRetroTerminalEffect(newAppearance.RetroTerminalEffect());
_renderEngine->SetPixelShaderPath(newAppearance.PixelShaderPath());
_renderer->TriggerRedrawAll();
}
}
// Method Description:
@ -1110,6 +1128,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
modifiers.IsCtrlPressed(),
modifiers.IsAltPressed(),
modifiers.IsShiftPressed(),
modifiers.IsWinPressed(),
vkey,
});
if (!success)
@ -2992,12 +3011,14 @@ namespace winrt::Microsoft::Terminal::Control::implementation
ControlKeyStates flags;
};
constexpr std::array<KeyModifier, 5> modifiers{ {
constexpr std::array<KeyModifier, 7> modifiers{ {
{ VirtualKey::RightMenu, ControlKeyStates::RightAltPressed },
{ VirtualKey::LeftMenu, ControlKeyStates::LeftAltPressed },
{ VirtualKey::RightControl, ControlKeyStates::RightCtrlPressed },
{ VirtualKey::LeftControl, ControlKeyStates::LeftCtrlPressed },
{ VirtualKey::Shift, ControlKeyStates::ShiftPressed },
{ VirtualKey::RightWindows, ControlKeyStates::RightWinPressed },
{ VirtualKey::LeftWindows, ControlKeyStates::LeftWinPressed },
} };
ControlKeyStates flags;

View file

@ -145,6 +145,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
std::shared_ptr<ThrottledFunc<>> _updatePatternLocations;
std::shared_ptr<ThrottledFunc<>> _playWarningBell;
struct ScrollBarUpdate
{
std::optional<double> newValue;

View file

@ -3,6 +3,14 @@
#pragma once
// All the modifiers in this file EXCEPT the win key come from
// https://docs.microsoft.com/en-us/windows/console/key-event-record-str
//
// Since we also want to be able to encode win-key info in this structure, we'll
// add those values manually here
constexpr DWORD RIGHT_WIN_PRESSED = 0x0200;
constexpr DWORD LEFT_WIN_PRESSED = 0x0400;
namespace Microsoft::Terminal::Core
{
class ControlKeyStates;
@ -31,6 +39,8 @@ public:
static constexpr StaticValue ScrolllockOn{ SCROLLLOCK_ON };
static constexpr StaticValue CapslockOn{ CAPSLOCK_ON };
static constexpr StaticValue EnhancedKey{ ENHANCED_KEY };
static constexpr StaticValue RightWinPressed{ RIGHT_WIN_PRESSED };
static constexpr StaticValue LeftWinPressed{ LEFT_WIN_PRESSED };
constexpr ControlKeyStates() noexcept :
_value(0) {}
@ -58,13 +68,17 @@ public:
SHIFT_PRESSED :
0;
// Since we can't differentiate between the left & right versions of Ctrl & Alt in a VirtualKeyModifiers
// Since we can't differentiate between the left & right versions of
// Ctrl, Alt and Win in a VirtualKeyModifiers
_value |= WI_IsFlagSet(m, static_cast<uint32_t>(winrt::Windows::System::VirtualKeyModifiers::Menu)) ?
LEFT_ALT_PRESSED :
0;
_value |= WI_IsFlagSet(m, static_cast<uint32_t>(winrt::Windows::System::VirtualKeyModifiers::Control)) ?
LEFT_CTRL_PRESSED :
0;
_value |= WI_IsFlagSet(m, static_cast<uint32_t>(winrt::Windows::System::VirtualKeyModifiers::Windows)) ?
LEFT_WIN_PRESSED :
0;
}
#endif
@ -88,6 +102,11 @@ public:
return IsAnyFlagSet(RightCtrlPressed | LeftCtrlPressed);
}
constexpr bool IsWinPressed() const noexcept
{
return IsAnyFlagSet(RightWinPressed | LeftWinPressed);
}
constexpr bool IsAltGrPressed() const noexcept
{
return AreAllFlagsSet(RightAltPressed | LeftCtrlPressed);

View file

@ -221,13 +221,26 @@ winrt::Microsoft::Terminal::Settings::Model::Profile CascadiaSettings::ProfileDe
// - a reference to the new profile
winrt::Microsoft::Terminal::Settings::Model::Profile CascadiaSettings::CreateNewProfile()
{
if (_allProfiles.Size() == std::numeric_limits<uint32_t>::max())
{
// Shouldn't really happen
return nullptr;
}
winrt::hstring newName{};
for (uint32_t candidateIndex = 0; candidateIndex < _allProfiles.Size() + 1; candidateIndex++)
{
// There is a theoretical unsigned integer wraparound, which is OK
newName = fmt::format(L"Profile {}", _allProfiles.Size() + 1 + candidateIndex);
if (std::none_of(begin(_allProfiles), end(_allProfiles), [&](auto&& profile) { return profile.Name() == newName; }))
{
break;
}
}
auto newProfile{ _userDefaultProfileSettings->CreateChild() };
_allProfiles.Append(*newProfile);
// Give the new profile a distinct name so a guid is properly generated
const winrt::hstring newName{ fmt::format(L"Profile {}", _allProfiles.Size()) };
newProfile->Name(newName);
_allProfiles.Append(*newProfile);
return *newProfile;
}

View file

@ -11,8 +11,9 @@ using namespace winrt::Microsoft::Terminal::Settings::Model::implementation;
static constexpr std::wstring_view CTRL_KEY{ L"ctrl" };
static constexpr std::wstring_view SHIFT_KEY{ L"shift" };
static constexpr std::wstring_view ALT_KEY{ L"alt" };
static constexpr std::wstring_view WIN_KEY{ L"win" };
static constexpr int MAX_CHORD_PARTS = 4;
static constexpr int MAX_CHORD_PARTS = 5; // win+ctrl+alt+shift+key
// clang-format off
static const std::unordered_map<std::wstring_view, int32_t> vkeyNamePairs {
@ -143,6 +144,10 @@ KeyChord KeyChordSerialization::FromString(const winrt::hstring& hstr)
{
modifiers |= KeyModifiers::Shift;
}
else if (lowercase == WIN_KEY)
{
modifiers |= KeyModifiers::Windows;
}
else
{
bool foundKey = false;
@ -224,6 +229,11 @@ winrt::hstring KeyChordSerialization::ToString(const KeyChord& chord)
std::wstring buffer{ L"" };
// Add modifiers
if (WI_IsFlagSet(modifiers, KeyModifiers::Windows))
{
buffer += WIN_KEY;
buffer += L"+";
}
if (WI_IsFlagSet(modifiers, KeyModifiers::Ctrl))
{
buffer += CTRL_KEY;

View file

@ -134,6 +134,10 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
// note: Menu is the Alt VK_MENU
keyModifiers |= Windows::System::VirtualKeyModifiers::Menu;
}
if (WI_IsFlagSet(modifiers, KeyModifiers::Windows))
{
keyModifiers |= Windows::System::VirtualKeyModifiers::Windows;
}
return keyModifiers;
}

View file

@ -14,6 +14,7 @@ const std::wstring_view ConsoleArguments::SIGNAL_HANDLE_ARG = L"--signal";
const std::wstring_view ConsoleArguments::HANDLE_PREFIX = L"0x";
const std::wstring_view ConsoleArguments::CLIENT_COMMANDLINE_ARG = L"--";
const std::wstring_view ConsoleArguments::FORCE_V1_ARG = L"-ForceV1";
const std::wstring_view ConsoleArguments::FORCE_NO_HANDOFF_ARG = L"-ForceNoHandoff";
const std::wstring_view ConsoleArguments::FILEPATH_LEADER_PREFIX = L"\\??\\";
const std::wstring_view ConsoleArguments::WIDTH_ARG = L"--width";
const std::wstring_view ConsoleArguments::HEIGHT_ARG = L"--height";
@ -115,6 +116,7 @@ ConsoleArguments::ConsoleArguments(const std::wstring& commandline,
_serverHandle = 0;
_signalHandle = 0;
_forceV1 = false;
_forceNoHandoff = false;
_width = 0;
_height = 0;
_inheritCursor = false;
@ -144,6 +146,7 @@ ConsoleArguments& ConsoleArguments::operator=(const ConsoleArguments& other)
_inheritCursor = other._inheritCursor;
_receivedEarlySizeChange = other._receivedEarlySizeChange;
_runAsComServer = other._runAsComServer;
_forceNoHandoff = other._forceNoHandoff;
}
return *this;
@ -449,6 +452,13 @@ void ConsoleArguments::s_ConsumeArg(_Inout_ std::vector<std::wstring>& args, _In
s_ConsumeArg(args, i);
hr = S_OK;
}
else if (arg == FORCE_NO_HANDOFF_ARG)
{
// Prevent default application handoff to a different console/terminal
_forceNoHandoff = true;
s_ConsumeArg(args, i);
hr = S_OK;
}
else if (arg == COM_SERVER_ARG)
{
_runAsComServer = true;
@ -630,6 +640,11 @@ bool ConsoleArguments::GetForceV1() const
return _forceV1;
}
bool ConsoleArguments::GetForceNoHandoff() const
{
return _forceNoHandoff;
}
short ConsoleArguments::GetWidth() const
{
return _width;

View file

@ -48,6 +48,7 @@ public:
std::wstring GetClientCommandline() const;
std::wstring GetVtMode() const;
bool GetForceV1() const;
bool GetForceNoHandoff() const;
short GetWidth() const;
short GetHeight() const;
@ -68,6 +69,7 @@ public:
static const std::wstring_view HANDLE_PREFIX;
static const std::wstring_view CLIENT_COMMANDLINE_ARG;
static const std::wstring_view FORCE_V1_ARG;
static const std::wstring_view FORCE_NO_HANDOFF_ARG;
static const std::wstring_view FILEPATH_LEADER_PREFIX;
static const std::wstring_view WIDTH_ARG;
static const std::wstring_view HEIGHT_ARG;
@ -89,6 +91,7 @@ private:
const short width,
const short height,
const bool forceV1,
const bool forceNoHandoff,
const bool headless,
const bool createServerHandle,
const DWORD serverHandle,
@ -103,6 +106,7 @@ private:
_width(width),
_height(height),
_forceV1(forceV1),
_forceNoHandoff(forceNoHandoff),
_headless(headless),
_createServerHandle(createServerHandle),
_serverHandle(serverHandle),
@ -127,6 +131,7 @@ private:
std::wstring _vtMode;
bool _forceNoHandoff;
bool _forceV1;
bool _headless;

View file

@ -182,6 +182,7 @@ bool PtySignalInputThread::_GetData(_Out_writes_bytes_(cbBuffer) void* const pBu
RETURN_LAST_ERROR_IF_NULL(hThread);
_hThread.reset(hThread);
_dwThreadId = dwThreadId;
LOG_IF_FAILED(SetThreadDescription(hThread, L"ConPTY Signal Handler Thread"));
return S_OK;
}

View file

@ -176,6 +176,7 @@ DWORD VtInputThread::_InputThread()
RETURN_LAST_ERROR_IF_NULL(hThread);
_hThread.reset(hThread);
_dwThreadId = dwThreadId;
LOG_IF_FAILED(SetThreadDescription(hThread, L"ConPTY Input Handler Thread"));
return S_OK;
}

View file

@ -325,6 +325,7 @@ HRESULT ConsoleCreateIoThread(_In_ HANDLE Server,
HANDLE const hThread = CreateThread(nullptr, 0, ConsoleIoThread, connectMessage, 0, nullptr);
RETURN_HR_IF(E_HANDLE, hThread == nullptr);
LOG_IF_FAILED(SetThreadDescription(hThread, L"Console Driver Message IO Thread"));
LOG_IF_WIN32_BOOL_FALSE(CloseHandle(hThread)); // The thread will run on its own and close itself. Free the associated handle.
// See MSFT:19918626

View file

@ -77,6 +77,7 @@ void ConsoleArgumentsTests::ArgSplittingTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
true, // headless
true, // createServerHandle
0, // serverHandle
@ -98,6 +99,7 @@ void ConsoleArgumentsTests::ArgSplittingTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0, // serverHandle
@ -119,6 +121,7 @@ void ConsoleArgumentsTests::ArgSplittingTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
true, // headless
true, // createServerHandle
0, // serverHandle
@ -140,6 +143,7 @@ void ConsoleArgumentsTests::ArgSplittingTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
true, // headless
false, // createServerHandle
0x4, // serverHandle
@ -161,6 +165,7 @@ void ConsoleArgumentsTests::ArgSplittingTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
true, // headless
true, // createServerHandle
0, // serverHandle
@ -182,6 +187,7 @@ void ConsoleArgumentsTests::ArgSplittingTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0, // serverHandle
@ -203,6 +209,7 @@ void ConsoleArgumentsTests::ArgSplittingTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0, // serverHandle
@ -224,6 +231,7 @@ void ConsoleArgumentsTests::ArgSplittingTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0, // serverHandle
@ -245,6 +253,7 @@ void ConsoleArgumentsTests::ArgSplittingTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0, // serverHandle
@ -271,6 +280,7 @@ void ConsoleArgumentsTests::ClientCommandlineTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0, // serverHandle
@ -292,6 +302,7 @@ void ConsoleArgumentsTests::ClientCommandlineTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0, // serverHandle
@ -313,6 +324,7 @@ void ConsoleArgumentsTests::ClientCommandlineTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0, // serverHandle
@ -334,6 +346,7 @@ void ConsoleArgumentsTests::ClientCommandlineTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0, // serverHandle
@ -355,6 +368,7 @@ void ConsoleArgumentsTests::ClientCommandlineTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0, // serverHandle
@ -376,6 +390,7 @@ void ConsoleArgumentsTests::ClientCommandlineTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0, // serverHandle
@ -397,6 +412,7 @@ void ConsoleArgumentsTests::ClientCommandlineTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0, // serverHandle
@ -418,6 +434,7 @@ void ConsoleArgumentsTests::ClientCommandlineTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
true, // headless
true, // createServerHandle
0, // serverHandle
@ -439,6 +456,7 @@ void ConsoleArgumentsTests::ClientCommandlineTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0, // serverHandle
@ -460,6 +478,7 @@ void ConsoleArgumentsTests::ClientCommandlineTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0, // serverHandle
@ -486,6 +505,7 @@ void ConsoleArgumentsTests::LegacyFormatsTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
false, // createServerHandle
4ul, // serverHandle
@ -507,6 +527,7 @@ void ConsoleArgumentsTests::LegacyFormatsTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
false, // createServerHandle
4ul, // serverHandle
@ -528,6 +549,7 @@ void ConsoleArgumentsTests::LegacyFormatsTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
false, // createServerHandle
4ul, // serverHandle
@ -549,6 +571,7 @@ void ConsoleArgumentsTests::LegacyFormatsTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
false, // createServerHandle
4ul, // serverHandle
@ -570,6 +593,7 @@ void ConsoleArgumentsTests::LegacyFormatsTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
false, // createServerHandle
4ul, // serverHandle
@ -591,6 +615,7 @@ void ConsoleArgumentsTests::LegacyFormatsTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
false, // createServerHandle
4ul, // serverHandle
@ -612,6 +637,7 @@ void ConsoleArgumentsTests::LegacyFormatsTests()
0, // width
0, // height
true, // forceV1
false, // forceNoHandoff
false, // headless
false, // createServerHandle
4ul, // serverHandle
@ -633,6 +659,51 @@ void ConsoleArgumentsTests::LegacyFormatsTests()
0, // width
0, // height
true, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0, // serverHandle
0, // signalHandle
false, // inheritCursor
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe 0x4 -ForceNoHandoff";
ArgTestsRunner(L"#9 #7 Check that ConDrv handle + -ForceNoHandoff succeeds",
commandline,
INVALID_HANDLE_VALUE,
INVALID_HANDLE_VALUE,
ConsoleArguments(commandline,
L"", // clientCommandLine
INVALID_HANDLE_VALUE,
INVALID_HANDLE_VALUE,
L"", // vtMode
0, // width
0, // height
false, // forceV1
true, // forceNoHandoff
false, // headless
false, // createServerHandle
4ul, // serverHandle
0, // signalHandle
false, // inheritCursor
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe -ForceNoHandoff";
ArgTestsRunner(L"#10 Check that -ForceNoHandoff parses on its own",
commandline,
INVALID_HANDLE_VALUE,
INVALID_HANDLE_VALUE,
ConsoleArguments(commandline,
L"", // clientCommandLine
INVALID_HANDLE_VALUE,
INVALID_HANDLE_VALUE,
L"", // vtMode
0, // width
0, // height
false, // forceV1
true, // forceNoHandoff
false, // headless
true, // createServerHandle
0, // serverHandle
@ -683,6 +754,7 @@ void ConsoleArgumentsTests::CombineVtPipeHandleTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0ul, // serverHandle
@ -704,6 +776,7 @@ void ConsoleArgumentsTests::CombineVtPipeHandleTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0ul, // serverHandle
@ -740,6 +813,7 @@ void ConsoleArgumentsTests::InitialSizeTests()
120, // width
30, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0ul, // serverHandle
@ -761,6 +835,7 @@ void ConsoleArgumentsTests::InitialSizeTests()
120, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0ul, // serverHandle
@ -782,6 +857,7 @@ void ConsoleArgumentsTests::InitialSizeTests()
0, // width
30, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0ul, // serverHandle
@ -803,6 +879,7 @@ void ConsoleArgumentsTests::InitialSizeTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0ul, // serverHandle
@ -824,6 +901,7 @@ void ConsoleArgumentsTests::InitialSizeTests()
-1, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0ul, // serverHandle
@ -845,6 +923,7 @@ void ConsoleArgumentsTests::InitialSizeTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0ul, // serverHandle
@ -866,6 +945,7 @@ void ConsoleArgumentsTests::InitialSizeTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0ul, // serverHandle
@ -887,6 +967,7 @@ void ConsoleArgumentsTests::InitialSizeTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0ul, // serverHandle
@ -913,6 +994,7 @@ void ConsoleArgumentsTests::HeadlessArgTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
true, // headless
true, // createServerHandle
0, // serverHandle
@ -934,6 +1016,7 @@ void ConsoleArgumentsTests::HeadlessArgTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
true, // headless
false, // createServerHandle
4ul, // serverHandle
@ -955,6 +1038,7 @@ void ConsoleArgumentsTests::HeadlessArgTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
true, // headless
true, // createServerHandle
0, // serverHandle
@ -976,6 +1060,7 @@ void ConsoleArgumentsTests::HeadlessArgTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0, // serverHandle
@ -1006,6 +1091,7 @@ void ConsoleArgumentsTests::SignalHandleTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
false, // createServerHandle
4ul, // serverHandle
@ -1027,6 +1113,7 @@ void ConsoleArgumentsTests::SignalHandleTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
false, // createServerHandle
4ul, // serverHandle
@ -1048,6 +1135,7 @@ void ConsoleArgumentsTests::SignalHandleTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0ul, // serverHandle
@ -1078,6 +1166,7 @@ void ConsoleArgumentsTests::FeatureArgTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0, // serverHandle
@ -1098,6 +1187,7 @@ void ConsoleArgumentsTests::FeatureArgTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0, // serverHandle
@ -1119,6 +1209,7 @@ void ConsoleArgumentsTests::FeatureArgTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0, // serverHandle
@ -1140,6 +1231,7 @@ void ConsoleArgumentsTests::FeatureArgTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0, // serverHandle
@ -1161,6 +1253,7 @@ void ConsoleArgumentsTests::FeatureArgTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0, // serverHandle
@ -1182,6 +1275,7 @@ void ConsoleArgumentsTests::FeatureArgTests()
0, // width
0, // height
false, // forceV1
false, // forceNoHandoff
false, // headless
true, // createServerHandle
0, // serverHandle

View file

@ -27,6 +27,7 @@ HANDLE ConsoleInputThread::Start()
{
_hThread = hThread;
_dwThreadId = dwThreadId;
LOG_IF_FAILED(SetThreadDescription(hThread, L"Win32 Window Message Input Thread"));
}
return hThread;

View file

@ -136,6 +136,7 @@ RenderThread::~RenderThread()
else
{
_hThread = hThread;
LOG_IF_FAILED(SetThreadDescription(hThread, L"Rendering Output Thread"));
}
}

View file

@ -159,6 +159,22 @@ static bool _shouldAttemptHandoff(const Globals& globals,
#else
// This console was started with a command line argument to
// specifically block handoff to another console. We presume
// this was for good reason (compatibility) and give up here.
if (globals.launchArgs.GetForceNoHandoff())
{
return false;
}
// Someone double clicked this console or explicitly tried
// to use it to launch a child process. Host it within this one
// and do not hand off.
if (globals.launchArgs.ShouldCreateServerHandle())
{
return false;
}
// This console is already initialized. Do not
// attempt handoff to another one.
// Note you can have a non-attach secondary connect for a child process