Skip to content

Commit

Permalink
Merged PR 3896217: [Git2Git] Changes from vb_release_dep_dev1
Browse files Browse the repository at this point in the history
https://microsoft.visualstudio.com os OS official/vb_release_dep_dev1 e4969135c0b6cc004a192e707f538cb1cedb274b
  • Loading branch information
miniksa authored and DHowett committed Oct 17, 2019
1 parent cc46a61 commit 476c8c1
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/host/srvinit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,18 @@ PWSTR TranslateConsoleTitle(_In_ PCWSTR pwszConsoleTitle, const BOOL fUnexpand,
return STATUS_SUCCESS;
}

[[nodiscard]] bool ConsoleConnectionDeservesVisibleWindow(PCONSOLE_API_CONNECTINFO p)
{
Globals& g = ServiceLocator::LocateGlobals();
// processes that are created ...
// ... with CREATE_NO_WINDOW never get a window.
// ... on Desktop, with a visible window always get one (even a fake one)
// ... not on Desktop, with a visible window only get one if we are headful (not ConPTY).
// This prevents pseudoconsole-hosted applications from taking over the screen,
// even if they really beg us for a window.
return p->WindowVisible && (s_IsOnDesktop() || !g.IsHeadless());
}

[[nodiscard]] NTSTATUS ConsoleAllocateConsole(PCONSOLE_API_CONNECTINFO p)
{
// AllocConsole is outside our codebase, but we should be able to mostly track the call here.
Expand Down Expand Up @@ -546,7 +558,7 @@ PWSTR TranslateConsoleTitle(_In_ PCWSTR pwszConsoleTitle, const BOOL fUnexpand,
Status = NTSTATUS_FROM_HRESULT(wil::ResultFromCaughtException());
}

if (NT_SUCCESS(Status) && p->WindowVisible)
if (NT_SUCCESS(Status) && ConsoleConnectionDeservesVisibleWindow(p))
{
HANDLE Thread = nullptr;

Expand Down Expand Up @@ -576,9 +588,6 @@ PWSTR TranslateConsoleTitle(_In_ PCWSTR pwszConsoleTitle, const BOOL fUnexpand,

CloseHandle(Thread); // This doesn't stop the thread from running.

g.consoleInputInitializedEvent.release();
g.consoleInputSetupEvent.release();

if (!NT_SUCCESS(g.ntstatusConsoleInputInitStatus))
{
Status = g.ntstatusConsoleInputInitStatus;
Expand Down

0 comments on commit 476c8c1

Please sign in to comment.