mirror of
https://github.com/microsoft/terminal.git
synced 2025-12-12 00:07:24 -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_lADOAF3p4s4AxadtzgYvdmA Service-Version: 1.23
This commit is contained in:
parent
93335d045c
commit
221c04f0ac
@ -646,7 +646,8 @@ void WindowEmperor::_dispatchCommandlineCommon(winrt::array_view<const winrt::hs
|
|||||||
// This is an implementation-detail of _dispatchCommandline().
|
// This is an implementation-detail of _dispatchCommandline().
|
||||||
safe_void_coroutine WindowEmperor::_dispatchCommandlineCurrentDesktop(winrt::TerminalApp::CommandlineArgs args)
|
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)))
|
if (winrt::guid currentDesktop; VirtualDesktopUtils::GetCurrentVirtualDesktopId(reinterpret_cast<GUID*>(¤tDesktop)))
|
||||||
{
|
{
|
||||||
@ -658,19 +659,18 @@ safe_void_coroutine WindowEmperor::_dispatchCommandlineCurrentDesktop(winrt::Ter
|
|||||||
if (desktopId == currentDesktop && lastActivatedTime > max)
|
if (desktopId == currentDesktop && lastActivatedTime > max)
|
||||||
{
|
{
|
||||||
max = lastActivatedTime;
|
max = lastActivatedTime;
|
||||||
mostRecentWeak = w;
|
mostRecent = w;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetVirtualDesktopId(), as current implemented, should always return on the main thread.
|
||||||
|
_assertIsMainThread();
|
||||||
|
window = mostRecent.get();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
// GetVirtualDesktopId(), as current implemented, should always return on the main thread.
|
|
||||||
_assertIsMainThread();
|
|
||||||
|
|
||||||
const auto mostRecent = mostRecentWeak.lock();
|
|
||||||
auto window = mostRecent.get();
|
|
||||||
|
|
||||||
if (!window)
|
|
||||||
{
|
{
|
||||||
|
// 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();
|
window = _mostRecentWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user