Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
windows: Remove more `todo`s (#13818)
张小白8203b6875bcf
diff --git a/crates/gpui/src/platform/windows/events.rs b/crates/gpui/src/platform/windows/events.rsindex aa550109e00..7c5a9736146 100644--- a/crates/gpui/src/platform/windows/events.rs+++ b/crates/gpui/src/platform/windows/events.rs@@ -1259,7 +1259,7 @@ fn is_modifier(virtual_key: VIRTUAL_KEY) -> bool {}#[inline]-fn current_modifiers() -> Modifiers {+pub(crate) fn current_modifiers() -> Modifiers {Modifiers {control: is_virtual_key_pressed(VK_CONTROL),alt: is_virtual_key_pressed(VK_MENU),diff --git a/crates/gpui/src/platform/windows/platform.rs b/crates/gpui/src/platform/windows/platform.rsindex 4edd807b8b8..f46b325cd76 100644--- a/crates/gpui/src/platform/windows/platform.rs+++ b/crates/gpui/src/platform/windows/platform.rs@@ -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()?;diff --git a/crates/gpui/src/platform/windows/util.rs b/crates/gpui/src/platform/windows/util.rsindex ba2d9ff7b23..e39390056e0 100644--- a/crates/gpui/src/platform/windows/util.rs+++ b/crates/gpui/src/platform/windows/util.rs@@ -1,7 +1,13 @@use std::sync::OnceLock;use ::util::ResultExt;-use windows::Win32::{Foundation::*, UI::WindowsAndMessaging::*};+use windows::{+ Win32::{Foundation::*, UI::WindowsAndMessaging::*},+ UI::{+ Color,+ ViewManagement::{UIColorType, UISettings},+ },+};use crate::*;@@ -118,3 +124,22 @@ pub(crate) fn logical_point(x: f32, y: f32, scale_factor: f32) -> Point<Pixels>y: px(y / scale_factor),}}++// https://learn.microsoft.com/en-us/windows/apps/desktop/modernize/apply-windows-themes+#[inline]+pub(crate) 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)+}diff --git a/crates/gpui/src/platform/windows/window.rs b/crates/gpui/src/platform/windows/window.rsindex 8c648661caf..46a2a4e6b3b 100644--- a/crates/gpui/src/platform/windows/window.rs+++ b/crates/gpui/src/platform/windows/window.rs@@ -383,9 +383,8 @@ impl PlatformWindow for WindowsWindow {self.0.state.borrow().scale_factor}- // todo(windows)fn appearance(&self) -> WindowAppearance {- WindowAppearance::Dark+ system_appearance().log_err().unwrap_or_default()}fn display(&self) -> Option<Rc<dyn PlatformDisplay>> {@@ -405,9 +404,8 @@ impl PlatformWindow for WindowsWindow {logical_point(point.x as f32, point.y as f32, scale_factor)}- // todo(windows)fn modifiers(&self) -> Modifiers {- Modifiers::none()+ current_modifiers()}fn set_input_handler(&mut self, input_handler: PlatformInputHandler) {