From 9b5ab4fd60e0ba3d998589b5aede3b4826158b71 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Tue, 18 Apr 2023 20:55:45 +0200 Subject: [PATCH] Remove dark-light dependency Since https://github.com/emilk/egui/pull/2750 we now get what we need straight from `winit`. --- Cargo.lock | 65 --------------------------------- crates/eframe/Cargo.toml | 10 +---- crates/eframe/src/epi.rs | 33 ++--------------- crates/eframe/src/native/run.rs | 3 +- deny.toml | 2 - 5 files changed, 6 insertions(+), 107 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1af8f614820..2f530928cc5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -989,23 +989,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "dark-light" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62007a65515b3cd88c733dd3464431f05d2ad066999a824259d8edc3cf6f645" -dependencies = [ - "dconf_rs", - "detect-desktop-environment", - "dirs", - "objc", - "rust-ini", - "web-sys", - "winreg", - "zbus", - "zvariant", -] - [[package]] name = "darling" version = "0.13.4" @@ -1047,12 +1030,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d7439c3735f405729d52c3fbbe4de140eaf938a1fe47d227c27f8254d4302a5" -[[package]] -name = "dconf_rs" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7046468a81e6a002061c01e6a7c83139daf91b11c30e66795b13217c2d885c8b" - [[package]] name = "derivative" version = "2.2.0" @@ -1064,12 +1041,6 @@ dependencies = [ "syn 1.0.107", ] -[[package]] -name = "detect-desktop-environment" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21d8ad60dd5b13a4ee6bd8fa2d5d88965c597c67bce32b5fc49c94f55cb50810" - [[package]] name = "digest" version = "0.10.6" @@ -1136,12 +1107,6 @@ dependencies = [ "libloading", ] -[[package]] -name = "dlv-list" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0688c2a7f92e427f44895cd63841bff7b29f8d7a1648b9e7e07a4a365b2e1257" - [[package]] name = "document-features" version = "0.2.7" @@ -1211,7 +1176,6 @@ name = "eframe" version = "0.21.3" dependencies = [ "bytemuck", - "dark-light", "directories-next", "document-features", "egui", @@ -2608,16 +2572,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "ordered-multimap" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccd746e37177e1711c20dd619a1620f34f5c8b569c53590a72dedd5344d8924a" -dependencies = [ - "dlv-list", - "hashbrown", -] - [[package]] name = "ordered-stream" version = "0.1.4" @@ -3073,16 +3027,6 @@ dependencies = [ "xmlparser", ] -[[package]] -name = "rust-ini" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6d5f2436026b4f6e79dc829837d467cc7e9a55ee40e750d716713540715a2df" -dependencies = [ - "cfg-if", - "ordered-multimap", -] - [[package]] name = "rustc-demangle" version = "0.1.21" @@ -4471,15 +4415,6 @@ dependencies = [ "x11-dl", ] -[[package]] -name = "winreg" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" -dependencies = [ - "winapi", -] - [[package]] name = "x11-dl" version = "2.21.0" diff --git a/crates/eframe/Cargo.toml b/crates/eframe/Cargo.toml index 649a55a1d02..a30aeeaffc9 100644 --- a/crates/eframe/Cargo.toml +++ b/crates/eframe/Cargo.toml @@ -26,11 +26,6 @@ default = ["accesskit", "default_fonts", "glow"] ## Enable platform accessibility API implementations through [AccessKit](https://accesskit.dev/). accesskit = ["egui/accesskit", "egui-winit/accesskit"] -## Detect dark mode system preference using [`dark-light`](https://docs.rs/dark-light). -## -## See also [`NativeOptions::follow_system_theme`] and [`NativeOptions::default_theme`]. -dark-light = ["dep:dark-light"] - ## If set, egui will use `include_bytes!` to bundle some fonts. ## If you plan on specifying your own fonts you may disable this feature. default_fonts = ["egui/default_fonts"] @@ -75,9 +70,9 @@ wgpu = ["dep:wgpu", "dep:egui-wgpu", "dep:pollster"] # - It's also important that we don't impose an android-activity backend by taking this choice away from applications. ## Enable the `native-activity` backend via `egui-winit` on Android -android-native-activity = [ "egui-winit/android-native-activity" ] +android-native-activity = ["egui-winit/android-native-activity"] ## Enable the `game-activity` backend via `egui-winit` on Android -android-game-activity = [ "egui-winit/android-game-activity" ] +android-game-activity = ["egui-winit/android-game-activity"] [dependencies] egui = { version = "0.21.0", path = "../egui", default-features = false, features = [ @@ -107,7 +102,6 @@ raw-window-handle = { version = "0.5.0" } winit = "0.28.1" # optional native: -dark-light = { version = "1.0", optional = true } directories-next = { version = "2", optional = true } egui-wgpu = { version = "0.21.0", path = "../egui-wgpu", optional = true, features = [ "winit", diff --git a/crates/eframe/src/epi.rs b/crates/eframe/src/epi.rs index 0cc5e8ed76a..b0d2e069895 100644 --- a/crates/eframe/src/epi.rs +++ b/crates/eframe/src/epi.rs @@ -328,18 +328,15 @@ pub struct NativeOptions { /// Try to detect and follow the system preferred setting for dark vs light mode. /// - /// By default, this is `true` on Mac and Windows, but `false` on Linux - /// due to . + /// The theme will automatically change when the dark vs light mode preference is changed. /// - /// On Mac and Windows the theme will automatically change when the dark vs light mode preference is changed. - /// - /// This only works on Linux if the `dark-light` feature is enabled. + /// Does not work on Linux (see https://github.com/rust-windowing/winit/issues/1549). /// /// See also [`Self::default_theme`]. pub follow_system_theme: bool, /// Which theme to use in case [`Self::follow_system_theme`] is `false` - /// or the `dark-light` feature is disabled. + /// or eframe fails to detect the system theme. /// /// Default: [`Theme::Dark`]. pub default_theme: Theme, @@ -454,30 +451,6 @@ impl Default for NativeOptions { } } -#[cfg(not(target_arch = "wasm32"))] -impl NativeOptions { - /// The theme used by the system. - #[cfg(feature = "dark-light")] - pub fn system_theme(&self) -> Option { - if self.follow_system_theme { - crate::profile_scope!("dark_light::detect"); - match dark_light::detect() { - dark_light::Mode::Dark => Some(Theme::Dark), - dark_light::Mode::Light => Some(Theme::Light), - dark_light::Mode::Default => None, - } - } else { - None - } - } - - /// The theme used by the system. - #[cfg(not(feature = "dark-light"))] - pub fn system_theme(&self) -> Option { - None - } -} - // ---------------------------------------------------------------------------- /// Options when using `eframe` in a web page. diff --git a/crates/eframe/src/native/run.rs b/crates/eframe/src/native/run.rs index e53ececcc90..12f431043b0 100644 --- a/crates/eframe/src/native/run.rs +++ b/crates/eframe/src/native/run.rs @@ -1454,9 +1454,8 @@ fn system_theme(window: &winit::window::Window, options: &NativeOptions) -> Opti } // Winit only reads the system theme on macOS and Windows. -// On Linux we have to fall back on dark-light (if enabled). // See: https://github.com/rust-windowing/winit/issues/1549 #[cfg(not(any(target_os = "windows", target_os = "macos")))] fn system_theme(_window: &winit::window::Window, options: &NativeOptions) -> Option { - options.system_theme() + None } diff --git a/deny.toml b/deny.toml index 3d65034959c..303690f32e0 100644 --- a/deny.toml +++ b/deny.toml @@ -36,9 +36,7 @@ deny = [ ] skip = [ - { name = "ahash" }, # old version via dark-light { name = "arrayvec" }, # old version via tiny-skiaz - { name = "hashbrown" }, # old version via dark-light { name = "nix" }, # old version via winit { name = "redox_syscall" }, # old version via winit { name = "time" }, # old version pulled in by unmaintianed crate 'chrono'