mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 19:27:56 +01:00
[FZE] Send close signal to Editor when the main app closes (#12510)
This commit is contained in:
1
.github/actions/spell-check/expect.txt
vendored
1
.github/actions/spell-check/expect.txt
vendored
@@ -664,6 +664,7 @@ Functiondiscoverykeys
|
|||||||
fwlink
|
fwlink
|
||||||
fwrite
|
fwrite
|
||||||
fxcop
|
fxcop
|
||||||
|
FZE
|
||||||
gabime
|
gabime
|
||||||
GAC
|
GAC
|
||||||
gacutil
|
gacutil
|
||||||
|
|||||||
@@ -179,6 +179,10 @@ public
|
|||||||
return gcnew String(CommonSharedConstants::RUN_EXIT_EVENT);
|
return gcnew String(CommonSharedConstants::RUN_EXIT_EVENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static String ^ FZEExitEvent() {
|
||||||
|
return gcnew String(CommonSharedConstants::FZE_EXIT_EVENT);
|
||||||
|
}
|
||||||
|
|
||||||
static String ^ ColorPickerSendSettingsTelemetryEvent() {
|
static String ^ ColorPickerSendSettingsTelemetryEvent() {
|
||||||
return gcnew String(CommonSharedConstants::COLOR_PICKER_SEND_SETTINGS_TELEMETRY_EVENT);
|
return gcnew String(CommonSharedConstants::COLOR_PICKER_SEND_SETTINGS_TELEMETRY_EVENT);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ namespace CommonSharedConstants
|
|||||||
const wchar_t RUN_SEND_SETTINGS_TELEMETRY_EVENT[] = L"Local\\PowerToysRunInvokeEvent-638ec522-0018-4b96-837d-6bd88e06f0d6";
|
const wchar_t RUN_SEND_SETTINGS_TELEMETRY_EVENT[] = L"Local\\PowerToysRunInvokeEvent-638ec522-0018-4b96-837d-6bd88e06f0d6";
|
||||||
|
|
||||||
const wchar_t RUN_EXIT_EVENT[] = L"Local\\PowerToysRunExitEvent-3e38e49d-a762-4ef1-88f2-fd4bc7481516";
|
const wchar_t RUN_EXIT_EVENT[] = L"Local\\PowerToysRunExitEvent-3e38e49d-a762-4ef1-88f2-fd4bc7481516";
|
||||||
|
|
||||||
|
const wchar_t FZE_EXIT_EVENT[] = L"Local\\PowerToys-FZE-ExitEvent-ca8c73de-a52c-4274-b691-46e9592d3b43";
|
||||||
|
|
||||||
const wchar_t COLOR_PICKER_SEND_SETTINGS_TELEMETRY_EVENT[] = L"Local\\ColorPickerSettingsTelemetryEvent-6c7071d8-4014-46ec-b687-913bd8a422f1";
|
const wchar_t COLOR_PICKER_SEND_SETTINGS_TELEMETRY_EVENT[] = L"Local\\ColorPickerSettingsTelemetryEvent-6c7071d8-4014-46ec-b687-913bd8a422f1";
|
||||||
|
|
||||||
|
|||||||
@@ -163,12 +163,31 @@ private:
|
|||||||
m_hProcess = sei.hProcess;
|
m_hProcess = sei.hProcess;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SendFZECloseEvent()
|
||||||
|
{
|
||||||
|
auto exitEvent = CreateEventW(nullptr, false, false, CommonSharedConstants::FZE_EXIT_EVENT);
|
||||||
|
if (!exitEvent)
|
||||||
|
{
|
||||||
|
Logger::warn(L"Failed to create exitEvent. {}", get_last_error_or_default(GetLastError()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger::trace(L"Signaled exitEvent");
|
||||||
|
if (!SetEvent(exitEvent))
|
||||||
|
{
|
||||||
|
Logger::warn(L"Failed to signal exitEvent. {}", get_last_error_or_default(GetLastError()));
|
||||||
|
}
|
||||||
|
|
||||||
|
ResetEvent(exitEvent);
|
||||||
|
CloseHandle(exitEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Disable(bool const traceEvent)
|
void Disable(bool const traceEvent)
|
||||||
{
|
{
|
||||||
m_enabled = false;
|
m_enabled = false;
|
||||||
// Log telemetry
|
// Log telemetry
|
||||||
|
|
||||||
if (traceEvent)
|
if (traceEvent)
|
||||||
{
|
{
|
||||||
Trace::FancyZones::EnableFancyZones(false);
|
Trace::FancyZones::EnableFancyZones(false);
|
||||||
@@ -178,14 +197,15 @@ private:
|
|||||||
{
|
{
|
||||||
ResetEvent(m_toggleEditorEvent);
|
ResetEvent(m_toggleEditorEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_hProcess)
|
if (m_hProcess)
|
||||||
{
|
{
|
||||||
TerminateProcess(m_hProcess, 0);
|
TerminateProcess(m_hProcess, 0);
|
||||||
|
SendFZECloseEvent();
|
||||||
m_hProcess = nullptr;
|
m_hProcess = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring app_name;
|
std::wstring app_name;
|
||||||
//contains the non localized key of the powertoy
|
//contains the non localized key of the powertoy
|
||||||
std::wstring app_key;
|
std::wstring app_key;
|
||||||
|
|||||||
@@ -80,6 +80,15 @@ namespace FancyZonesEditor
|
|||||||
FancyZonesEditorIO = new FancyZonesEditorIO();
|
FancyZonesEditorIO = new FancyZonesEditorIO();
|
||||||
Overlay = new Overlay();
|
Overlay = new Overlay();
|
||||||
MainWindowSettings = new MainWindowSettingsModel();
|
MainWindowSettings = new MainWindowSettingsModel();
|
||||||
|
|
||||||
|
new Thread(() =>
|
||||||
|
{
|
||||||
|
var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, interop.Constants.FZEExitEvent());
|
||||||
|
if (eventHandle.WaitOne())
|
||||||
|
{
|
||||||
|
Environment.Exit(0);
|
||||||
|
}
|
||||||
|
}).Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnStartup(object sender, StartupEventArgs e)
|
private void OnStartup(object sender, StartupEventArgs e)
|
||||||
|
|||||||
@@ -81,6 +81,7 @@
|
|||||||
<Resource Include="images\FancyZonesEditor.ico" />
|
<Resource Include="images\FancyZonesEditor.ico" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\..\..\common\interop\PowerToysInterop.vcxproj" />
|
||||||
<ProjectReference Include="..\..\..\..\common\ManagedCommon\ManagedCommon.csproj" />
|
<ProjectReference Include="..\..\..\..\common\ManagedCommon\ManagedCommon.csproj" />
|
||||||
<ProjectReference Include="..\..\..\..\common\Microsoft.PowerToys.Common.UI\Microsoft.PowerToys.Common.UI.csproj" />
|
<ProjectReference Include="..\..\..\..\common\Microsoft.PowerToys.Common.UI\Microsoft.PowerToys.Common.UI.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user