windows: Remove more todos (#13818)

Release Notes:

- N/A
This commit is contained in:
张小白 2024-07-10 01:44:42 +08:00 committed by GitHub
parent ce7074c883
commit 8203b6875b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 30 additions and 29 deletions

View file

@ -27,10 +27,7 @@ use windows::{
System::{Com::*, LibraryLoader::*, Ole::*, SystemInformation::*, Threading::*, Time::*},
UI::{Input::KeyboardAndMouse::*, Shell::*, WindowsAndMessaging::*},
},
UI::{
Color,
ViewManagement::{UIColorType, UISettings},
},
UI::ViewManagement::UISettings,
};
use crate::*;
@ -678,25 +675,6 @@ fn load_icon() -> Result<HICON> {
Ok(HICON(handle.0))
}
// https://learn.microsoft.com/en-us/windows/apps/desktop/modernize/apply-windows-themes
#[inline]
fn system_appearance() -> Result<WindowAppearance> {
let ui_settings = UISettings::new()?;
let foreground_color = ui_settings.GetColorValue(UIColorType::Foreground)?;
// If the foreground is light, then is_color_light will evaluate to true,
// meaning Dark mode is enabled.
if is_color_light(&foreground_color) {
Ok(WindowAppearance::Dark)
} else {
Ok(WindowAppearance::Light)
}
}
#[inline(always)]
fn is_color_light(color: &Color) -> bool {
((5 * color.G as u32) + (2 * color.R as u32) + color.B as u32) > (8 * 128)
}
#[inline]
fn should_auto_hide_scrollbars() -> Result<bool> {
let ui_settings = UISettings::new()?;