Skip to content

Commit 4921103

Browse files
committed
add multiinstance with WT_BASE_SETTINGS_PATH env
1 parent 0ba3782 commit 4921103

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/cascadia/CascadiaPackage/Package-Dev.appxmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
<Identity Name="WindowsTerminalDev"
2020
Publisher="CN=Dm17tryK"
21-
Version="1.24.53104.3" />
21+
Version="1.24.53104.4" />
2222

2323
<Properties>
2424
<DisplayName>ms-resource:AppStoreNameDev</DisplayName>

src/cascadia/WindowsTerminal/WindowEmperor.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ using namespace ::Microsoft::Console;
2424
using namespace std::chrono_literals;
2525
using VirtualKeyModifiers = winrt::Windows::System::VirtualKeyModifiers;
2626

27+
#define ENV_WT_BASE_SETTINGS_PATH L"WT_BASE_SETTINGS_PATH"
28+
2729
#ifdef _WIN64
2830
static constexpr ULONG_PTR TERMINAL_HANDOFF_MAGIC = 0x4c414e494d524554; // 'TERMINAL'
2931
#else
@@ -297,6 +299,18 @@ void WindowEmperor::HandleCommandlineArgs(int nCmdShow)
297299
#endif
298300
}
299301

302+
try
303+
{
304+
const auto settingsPath = wil::GetEnvironmentVariableW<std::wstring>(ENV_WT_BASE_SETTINGS_PATH);
305+
const auto settingsHash = til::hash(settingsPath);
306+
#ifdef _WIN64
307+
fmt::format_to(std::back_inserter(windowClassName), FMT_COMPILE(L" {:016x}"), settingsHash);
308+
#else
309+
fmt::format_to(std::back_inserter(windowClassName), FMT_COMPILE(L" {:08x}"), settingsHash);
310+
#endif
311+
}
312+
CATCH_LOG()
313+
300314
// Windows Terminal is a single-instance application. Either acquire ownership
301315
// over the mutex, or hand off the command line to the existing instance.
302316
const auto mutex = acquireMutexOrAttemptHandoff(windowClassName.c_str(), nCmdShow);

0 commit comments

Comments
 (0)