/
githubmirror
/
PowerToys
Обзор
Документация
Войти
/
githubmirror
/
PowerToys
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/modules/LightSwitch/LightSwitchService/LightSwitchStateManager.h
54 строки
2 KB
moooyo
[PowerDisplay] Add stable profile IDs (#49175)
16 июл 2026, 09:33
Не верифицирован
16 июл 2026, 09:33
2b8e624
Код
Авторство
О чём код?
#pragma once #include "LightSwitchSettings.h" #include <optional> // Represents runtime-only information (not saved in settings.json) struct LightSwitchState { ScheduleMode lastAppliedMode = ScheduleMode::Off; bool isManualOverride = false; bool isSystemLightActive = false; bool isAppsLightActive = false; bool isNightLightActive = false; int lastEvaluatedDay = -1; int lastTickMinutes = -1; // Derived, runtime-resolved times int effectiveLightMinutes = 0; // the boundary we actually act on int effectiveDarkMinutes = 0; // includes offsets if needed }; // The controller that reacts to settings changes, time ticks, and manual overrides. class LightSwitchStateManager { public: LightSwitchStateManager(); // Called when settings.json changes or stabilizes. void OnSettingsChanged(); // Called every minute (from service worker tick). void OnTick(); // Called when manual override is toggled (via shortcut or system change). void OnManualOverride(); // Called when night light changes in windows settings void OnNightLightChange(); // Initial sync at startup to align internal state with system theme void SyncInitialThemeState(); // Accessor for current state (optional, for debugging or telemetry) const LightSwitchState& GetState() const { return _state; } private: LightSwitchState _state; std::mutex _stateMutex; void EvaluateAndApplyIfNeeded(); bool CoordinatesAreValid(const std::wstring& lat, const std::wstring& lon); // Notify PowerDisplay that LightSwitch applied a new theme. void NotifyPowerDisplayThemeChanged(bool isLight); };