Revert "[Light Switch] Switch desktop wallpapers with the Light/Dark mode" (#44588)

This uses IVirtualDesktopManagerInternal*, which is an undocumented
Windows Shell internal API.
These interfaces are not stable and can change across Windows updates,
so using them in PowerToys carries some long-term risk
This commit is contained in:
Kai Tao
2026-01-08 10:14:43 +08:00
committed by GitHub
parent 08d4689ec5
commit 9c58574484
25 changed files with 310 additions and 1118 deletions

View File

@@ -4,9 +4,8 @@
#include <LightSwitchUtils.h>
#include "ThemeScheduler.h"
#include <ThemeHelper.h>
#include <filesystem>
void ApplyTheme(bool shouldBeLight, bool changeWallpaper);
void ApplyTheme(bool shouldBeLight);
// Constructor
LightSwitchStateManager::LightSwitchStateManager()
@@ -148,11 +147,6 @@ static std::pair<int, int> update_sun_times(auto& settings)
return { newLightTime, newDarkTime };
}
static bool IsValidPath(const std::wstring& path)
{
return !path.empty() && std::filesystem::exists(path);
}
// Internal: decide what should happen now
void LightSwitchStateManager::EvaluateAndApplyIfNeeded()
{
@@ -246,11 +240,6 @@ void LightSwitchStateManager::EvaluateAndApplyIfNeeded()
bool appsNeedsToChange = _currentSettings.changeApps && (_state.isAppsLightActive != shouldBeLight);
bool systemNeedsToChange = _currentSettings.changeSystem && (_state.isSystemLightActive != shouldBeLight);
bool changeWallpaper =
_currentSettings.wallpaperEnabled &&
IsValidPath(_currentSettings.wallpaperPathDark) &&
IsValidPath(_currentSettings.wallpaperPathLight);
/* Logger::debug(
L"[LightSwitchStateManager] now = {:02d}:{:02d}, light boundary = {:02d}:{:02d} ({}), dark boundary = {:02d}:{:02d} ({})",
now / 60,
@@ -271,11 +260,11 @@ void LightSwitchStateManager::EvaluateAndApplyIfNeeded()
if (!_state.isManualOverride && (appsNeedsToChange || systemNeedsToChange))
{
Logger::info(L"[LightSwitchStateManager] Applying {} theme", shouldBeLight ? L"light" : L"dark");
ApplyTheme(shouldBeLight, changeWallpaper);
ApplyTheme(shouldBeLight);
_state.isSystemLightActive = GetCurrentSystemTheme();
_state.isAppsLightActive = GetCurrentAppsTheme();
}
_state.lastTickMinutes = now;
}
}