Sync LightSwitch event names, add monitor refresh delay

- Use shared constants for LightSwitch theme event names in both C++ and C# to ensure cross-module consistency.
- Replace "Brightness update rate" with "Monitor refresh delay" setting in PowerDisplay; user can now configure delay (1–30s) after display changes before monitor refresh.
- Update UI and resources to reflect new setting and remove old references.
- MainViewModel now uses the configurable delay instead of a hardcoded value.
- Improves user control and reliability of monitor detection after hot-plug events.
This commit is contained in:
Yu Leng
2025-12-15 13:53:23 +08:00
parent 4f4a724d35
commit 6acd859d43
8 changed files with 42 additions and 28 deletions

View File

@@ -4,6 +4,7 @@
#include <LightSwitchUtils.h>
#include "ThemeScheduler.h"
#include <ThemeHelper.h>
#include <common/interop/shared_constants.h>
void ApplyTheme(bool shouldBeLight);
@@ -300,8 +301,8 @@ void LightSwitchStateManager::NotifyPowerDisplay(bool isLight)
// Using separate events for light/dark eliminates race conditions where PowerDisplay
// might read the registry before LightSwitch has finished updating it
const wchar_t* eventName = isLight
? L"Local\\PowerToys_LightSwitch_LightTheme"
: L"Local\\PowerToys_LightSwitch_DarkTheme";
? CommonSharedConstants::LIGHT_SWITCH_LIGHT_THEME_EVENT
: CommonSharedConstants::LIGHT_SWITCH_DARK_THEME_EVENT;
Logger::info(L"[LightSwitchStateManager] Notifying PowerDisplay about theme change (isLight: {})", isLight);