mirror of
https://github.com/microsoft/PowerToys
synced 2025-09-01 15:05:12 +00:00
Fixed flashing issue, legacy code got stuck when removing old logic
This commit is contained in:
@@ -11,7 +11,6 @@
|
|||||||
SERVICE_STATUS g_ServiceStatus = {};
|
SERVICE_STATUS g_ServiceStatus = {};
|
||||||
SERVICE_STATUS_HANDLE g_StatusHandle = nullptr;
|
SERVICE_STATUS_HANDLE g_StatusHandle = nullptr;
|
||||||
HANDLE g_ServiceStopEvent = nullptr;
|
HANDLE g_ServiceStopEvent = nullptr;
|
||||||
HANDLE g_ConfigChangedEvent = nullptr;
|
|
||||||
|
|
||||||
// Forward declarations of service functions (we<77>ll define them later)
|
// Forward declarations of service functions (we<77>ll define them later)
|
||||||
VOID WINAPI ServiceMain(DWORD argc, LPTSTR* argv);
|
VOID WINAPI ServiceMain(DWORD argc, LPTSTR* argv);
|
||||||
@@ -105,8 +104,6 @@ VOID WINAPI ServiceMain(DWORD, LPTSTR*)
|
|||||||
sa.bInheritHandle = FALSE;
|
sa.bInheritHandle = FALSE;
|
||||||
sa.lpSecurityDescriptor = nullptr;
|
sa.lpSecurityDescriptor = nullptr;
|
||||||
|
|
||||||
g_ConfigChangedEvent = CreateEventW(&sa, TRUE, FALSE, L"Global\\PT_DarkMode_ConfigChanged");
|
|
||||||
|
|
||||||
g_ServiceStatus.dwCurrentState = SERVICE_RUNNING;
|
g_ServiceStatus.dwCurrentState = SERVICE_RUNNING;
|
||||||
SetServiceStatus(g_StatusHandle, &g_ServiceStatus);
|
SetServiceStatus(g_StatusHandle, &g_ServiceStatus);
|
||||||
|
|
||||||
@@ -154,8 +151,8 @@ DWORD WINAPI ServiceWorkerThread(LPVOID lpParam)
|
|||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
HANDLE waits[3] = { g_ServiceStopEvent, hParent, g_ConfigChangedEvent };
|
HANDLE waits[3] = { g_ServiceStopEvent, hParent };
|
||||||
DWORD count = hParent ? 3 : 2;
|
DWORD count = hParent ? 2 : 1;
|
||||||
|
|
||||||
SYSTEMTIME st;
|
SYSTEMTIME st;
|
||||||
GetLocalTime(&st);
|
GetLocalTime(&st);
|
||||||
@@ -228,19 +225,10 @@ DWORD WINAPI ServiceWorkerThread(LPVOID lpParam)
|
|||||||
break;
|
break;
|
||||||
if (hParent && wait == WAIT_OBJECT_0 + 1) // parent exited
|
if (hParent && wait == WAIT_OBJECT_0 + 1) // parent exited
|
||||||
break;
|
break;
|
||||||
if (wait == WAIT_OBJECT_0 + (hParent ? 2 : 1)) // config changed
|
|
||||||
{
|
|
||||||
// Clear and loop immediately
|
|
||||||
ResetEvent(g_ConfigChangedEvent);
|
|
||||||
// Loop continues, which re-runs LoadSettings() and applies immediately
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hParent)
|
if (hParent)
|
||||||
CloseHandle(hParent);
|
CloseHandle(hParent);
|
||||||
if (g_ConfigChangedEvent)
|
|
||||||
CloseHandle(g_ConfigChangedEvent);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user