Skip to content

Commit

Permalink
Pass foreground rights to the emperor
Browse files Browse the repository at this point in the history
  • Loading branch information
lhecker committed Dec 13, 2024
1 parent 19460f9 commit 1e0bd85
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/cascadia/WindowsTerminal/WindowEmperor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,14 @@ static wil::unique_mutex acquireMutexOrAttemptHandoff(const wchar_t* className,
.cbData = gsl::narrow<DWORD>(payload.size()),
.lpData = payload.data(),
};

// Allow the existing instance to gain foreground rights.
DWORD processId = 0;
if (GetWindowThreadProcessId(hwnd, &processId) && processId)
{
AllowSetForegroundWindow(processId);
}

if (SendMessageTimeoutW(hwnd, WM_COPYDATA, 0, reinterpret_cast<LPARAM>(&cds), SMTO_ABORTIFHUNG | SMTO_ERRORONEXIT, 5000, nullptr))
{
return {};
Expand Down

0 comments on commit 1e0bd85

Please sign in to comment.