chore: audit components

This commit is contained in:
2026-11-10 15:06:16 +07:00
parent af2177c6c8
commit 03369f501e
92 changed files with 2744 additions and 1947 deletions
+10 -13
View File
@@ -74,16 +74,19 @@ pub(crate) struct WindowsSource {
}
pub(crate) fn platform_source() -> Box<dyn ThemeSource> {
// SAFETY: WinRT activation requires COM on this thread; the STA matches
// the UI thread's message pump, and RPC_E_CHANGED_MODE means COM is
// already initialized in another apartment.
let initialized = unsafe { CoInitializeEx(None, COINIT_APARTMENTTHREADED) };
if initialized.is_err() && initialized != RPC_E_CHANGED_MODE {
eprintln!("theme: COM initialization failed: {initialized:?}");
log::error!("theme: COM initialization failed: {initialized:?}");
}
match WindowsSource::new() {
Some(source) => Box::new(source),
None => {
eprintln!("theme: Windows system theme unavailable; using fallback");
log::warn!("theme: Windows system theme unavailable; using fallback");
Box::new(super::fallback::FallbackSource)
}
}
@@ -94,7 +97,7 @@ impl WindowsSource {
let ui_settings = match UISettings::new() {
Ok(ui_settings) => ui_settings,
Err(error) => {
eprintln!("theme: UISettings unavailable: {error}");
log::warn!("theme: UISettings unavailable: {error}");
return None;
}
};
@@ -102,7 +105,7 @@ impl WindowsSource {
let accessibility_settings = match AccessibilitySettings::new() {
Ok(accessibility_settings) => accessibility_settings,
Err(error) => {
eprintln!("theme: AccessibilitySettings unavailable: {error}");
log::warn!("theme: AccessibilitySettings unavailable: {error}");
return None;
}
};
@@ -157,13 +160,7 @@ impl ThemeSource for WindowsSource {
let foreground = self.color(UIColorType::Foreground);
let variant = background
.map(|background| {
if background.l >= 0.5 {
ThemeVariant::Light
} else {
ThemeVariant::Dark
}
})
.map(ThemeVariant::by_lightness)
.or(self.registry.apps_use_light_theme.map(|light| {
if light {
ThemeVariant::Light
@@ -212,7 +209,7 @@ impl ThemeSource for WindowsSource {
});
if let Err(error) = self.ui_settings.ColorValuesChanged(&color_handler) {
eprintln!("theme: color change watch failed: {error}");
log::warn!("theme: color change watch failed: {error}");
}
let contrast_signal = signal.sender();
@@ -226,7 +223,7 @@ impl ThemeSource for WindowsSource {
.accessibility_settings
.HighContrastChanged(&contrast_handler)
{
eprintln!("theme: high contrast watch failed: {error}");
log::warn!("theme: high contrast watch failed: {error}");
}
self._signal = Some(signal);