Skip to content

Commit

Permalink
[Workspaces] Close editor when PT runner exited. (#34477)
Browse files Browse the repository at this point in the history
* [Workspaces] Close editor when PT runner exited.

* removed trailing whitespace
  • Loading branch information
SeraphimaZykova authored Aug 29, 2024
1 parent 6408898 commit d42cd4b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
14 changes: 14 additions & 0 deletions src/modules/Workspaces/WorkspacesEditor/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@ private void OnStartup(object sender, StartupEventArgs e)
return;
}

var args = e?.Args;
int powerToysRunnerPid;
if (args?.Length > 0)
{
_ = int.TryParse(args[0], out powerToysRunnerPid);

Logger.LogInfo($"WorkspacesEditor started from the PowerToys Runner. Runner pid={powerToysRunnerPid}");
RunnerHelper.WaitForPowerToysRunner(powerToysRunnerPid, () =>
{
Logger.LogInfo("PowerToys Runner exited. Exiting WorkspacesEditor");
Dispatcher.Invoke(Shutdown);
});
}

ThemeManager = new ThemeManager(this);

if (_mainViewModel == null)
Expand Down
6 changes: 3 additions & 3 deletions src/modules/Workspaces/WorkspacesModuleInterface/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,15 +309,15 @@ class WorkspacesModuleInterface : public PowertoyModuleIface
{
Logger::trace(L"Starting Workspaces Editor");

/*unsigned long powertoys_pid = GetCurrentProcessId();
unsigned long powertoys_pid = GetCurrentProcessId();
std::wstring executable_args = L"";
executable_args.append(std::to_wstring(powertoys_pid));*/
executable_args.append(std::to_wstring(powertoys_pid));

SHELLEXECUTEINFOW sei{ sizeof(sei) };
sei.fMask = SEE_MASK_NOCLOSEPROCESS;
sei.lpFile = L"PowerToys.WorkspacesEditor.exe";
sei.nShow = SW_SHOWNORMAL;
//sei.lpParameters = executable_args.data();
sei.lpParameters = executable_args.data();
if (ShellExecuteExW(&sei))
{
Logger::trace("Successfully started the Workspaces Editor");
Expand Down

0 comments on commit d42cd4b

Please sign in to comment.