mirror of
https://github.com/microsoft/terminal.git
synced 2025-12-10 00:48:23 -06:00
Allow creating new windows on another virtual desktop (#19458)
Whoops. Closes #18652 <DHowett> I chatted with Leonard to figure out why I kept misunderstanding this PR. The key is that **this function should not always return an existing window.** It's supposed to find an existing window on the current virtual desktop, not literally any window anywhere. (cherry picked from commit 5ae95d7df0ee3050ad36b98cd8f3f8d55005f0d2) Service-Card-Id: PVTI_lADOAF3p4s4BBcTlzgf7tqY Service-Version: 1.24
This commit is contained in:
parent
d25b84d4c1
commit
b38489b67b
@ -648,7 +648,8 @@ void WindowEmperor::_dispatchCommandlineCommon(winrt::array_view<const winrt::hs
|
||||
// This is an implementation-detail of _dispatchCommandline().
|
||||
safe_void_coroutine WindowEmperor::_dispatchCommandlineCurrentDesktop(winrt::TerminalApp::CommandlineArgs args)
|
||||
{
|
||||
std::weak_ptr<AppHost> mostRecentWeak;
|
||||
std::shared_ptr<AppHost> mostRecent;
|
||||
AppHost* window = nullptr;
|
||||
|
||||
if (winrt::guid currentDesktop; VirtualDesktopUtils::GetCurrentVirtualDesktopId(reinterpret_cast<GUID*>(¤tDesktop)))
|
||||
{
|
||||
@ -660,19 +661,18 @@ safe_void_coroutine WindowEmperor::_dispatchCommandlineCurrentDesktop(winrt::Ter
|
||||
if (desktopId == currentDesktop && lastActivatedTime > max)
|
||||
{
|
||||
max = lastActivatedTime;
|
||||
mostRecentWeak = w;
|
||||
mostRecent = w;
|
||||
}
|
||||
}
|
||||
|
||||
// GetVirtualDesktopId(), as current implemented, should always return on the main thread.
|
||||
_assertIsMainThread();
|
||||
window = mostRecent.get();
|
||||
}
|
||||
|
||||
// GetVirtualDesktopId(), as current implemented, should always return on the main thread.
|
||||
_assertIsMainThread();
|
||||
|
||||
const auto mostRecent = mostRecentWeak.lock();
|
||||
auto window = mostRecent.get();
|
||||
|
||||
if (!window)
|
||||
else
|
||||
{
|
||||
// If virtual desktops have never been used, and in turn Explorer never set them up,
|
||||
// GetCurrentVirtualDesktopId will return false. In this case just use the current (only) desktop.
|
||||
window = _mostRecentWindow();
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user