diff --git a/crates/eframe/src/epi.rs b/crates/eframe/src/epi.rs index 1f04be0d996..c6432d26b1d 100644 --- a/crates/eframe/src/epi.rs +++ b/crates/eframe/src/epi.rs @@ -769,11 +769,6 @@ pub struct IntegrationInfo { #[cfg(target_arch = "wasm32")] pub web_info: WebInfo, - /// Does the OS use dark or light mode? - /// - /// `None` means "don't know". - pub system_theme: Option, - /// Seconds of cpu usage (in seconds) on the previous frame. /// /// This includes [`App::update`] as well as rendering (except for vsync waiting). diff --git a/crates/eframe/src/native/epi_integration.rs b/crates/eframe/src/native/epi_integration.rs index 733ffca704a..6d7b695d344 100644 --- a/crates/eframe/src/native/epi_integration.rs +++ b/crates/eframe/src/native/epi_integration.rs @@ -7,7 +7,7 @@ use winit::event_loop::EventLoopWindowTarget; use raw_window_handle::{HasDisplayHandle as _, HasWindowHandle as _}; -use egui::{DeferredViewportUiCallback, NumExt as _, Theme, ViewportBuilder, ViewportId, Visuals}; +use egui::{DeferredViewportUiCallback, NumExt as _, ViewportBuilder, ViewportId}; use egui_winit::{EventResponse, WindowSettings}; use crate::epi; @@ -162,7 +162,6 @@ pub struct EpiIntegration { close: bool, can_drag_window: bool, - follow_system_theme: bool, #[cfg(feature = "persistence")] persist_window: bool, app_icon_setter: super::app_icon::AppTitleIconSetter, @@ -173,7 +172,6 @@ impl EpiIntegration { pub fn new( egui_ctx: egui::Context, window: &winit::window::Window, - system_theme: Option, app_name: &str, native_options: &crate::NativeOptions, storage: Option>, @@ -184,10 +182,7 @@ impl EpiIntegration { #[cfg(feature = "wgpu")] wgpu_render_state: Option, ) -> Self { let frame = epi::Frame { - info: epi::IntegrationInfo { - system_theme, - cpu_usage: None, - }, + info: epi::IntegrationInfo { cpu_usage: None }, storage, #[cfg(feature = "glow")] gl, @@ -221,7 +216,6 @@ impl EpiIntegration { pending_full_output: Default::default(), close: false, can_drag_window: false, - follow_system_theme: native_options.follow_system_theme, #[cfg(feature = "persistence")] persist_window: native_options.persist_window, app_icon_setter, @@ -277,11 +271,6 @@ impl EpiIntegration { state: ElementState::Pressed, .. } => self.can_drag_window = true, - WindowEvent::ThemeChanged(winit_theme) if self.follow_system_theme => { - let theme = theme_from_winit_theme(*winit_theme); - self.frame.info.system_theme = Some(theme); - self.egui_ctx.set_visuals(Visuals::theme(theme)); - } _ => {} } @@ -424,10 +413,3 @@ pub fn load_egui_memory(_storage: Option<&dyn epi::Storage>) -> Option Theme { - match theme { - winit::window::Theme::Dark => Theme::Dark, - winit::window::Theme::Light => Theme::Light, - } -} diff --git a/crates/eframe/src/native/glow_integration.rs b/crates/eframe/src/native/glow_integration.rs index 27d978239c5..e2f0e049bd8 100644 --- a/crates/eframe/src/native/glow_integration.rs +++ b/crates/eframe/src/native/glow_integration.rs @@ -29,7 +29,7 @@ use winit::{ use ahash::{HashMap, HashSet}; use egui::{ DeferredViewportUiCallback, ImmediateViewport, ViewportBuilder, ViewportClass, ViewportId, - ViewportIdMap, ViewportIdPair, ViewportInfo, ViewportOutput, Visuals, + ViewportIdMap, ViewportIdPair, ViewportInfo, ViewportOutput, }; #[cfg(feature = "accesskit")] use egui_winit::accesskit_winit; @@ -228,14 +228,11 @@ impl GlowWinitApp { } } - let system_theme = - winit_integration::system_theme(&glutin.window(ViewportId::ROOT), &self.native_options); let painter = Rc::new(RefCell::new(painter)); let integration = EpiIntegration::new( egui_ctx, &glutin.window(ViewportId::ROOT), - system_theme, &self.app_name, &self.native_options, storage, @@ -281,9 +278,6 @@ impl GlowWinitApp { } } - let theme = system_theme.unwrap_or(self.native_options.default_theme); - integration.egui_ctx.set_visuals(Visuals::theme(theme)); - if self .native_options .viewport diff --git a/crates/eframe/src/native/wgpu_integration.rs b/crates/eframe/src/native/wgpu_integration.rs index 685b444322a..0fcd3f8eb25 100644 --- a/crates/eframe/src/native/wgpu_integration.rs +++ b/crates/eframe/src/native/wgpu_integration.rs @@ -19,7 +19,6 @@ use ahash::{HashMap, HashSet, HashSetExt}; use egui::{ DeferredViewportUiCallback, FullOutput, ImmediateViewport, ViewportBuilder, ViewportClass, ViewportId, ViewportIdMap, ViewportIdPair, ViewportIdSet, ViewportInfo, ViewportOutput, - Visuals, }; #[cfg(feature = "accesskit")] use egui_winit::accesskit_winit; @@ -206,11 +205,9 @@ impl WgpuWinitApp { let wgpu_render_state = painter.render_state(); - let system_theme = winit_integration::system_theme(&window, &self.native_options); let integration = EpiIntegration::new( egui_ctx.clone(), &window, - system_theme, &self.app_name, &self.native_options, storage, @@ -256,9 +253,6 @@ impl WgpuWinitApp { } egui_winit.init_system_theme(&window); - let theme = system_theme.unwrap_or(self.native_options.default_theme); - egui_ctx.set_visuals(Visuals::theme(theme)); - let app_creator = std::mem::take(&mut self.app_creator) .expect("Single-use AppCreator has unexpectedly already been taken"); let cc = CreationContext { diff --git a/crates/eframe/src/native/winit_integration.rs b/crates/eframe/src/native/winit_integration.rs index 5a8879f1d02..3399467a428 100644 --- a/crates/eframe/src/native/winit_integration.rs +++ b/crates/eframe/src/native/winit_integration.rs @@ -5,7 +5,7 @@ use winit::{ window::{Window, WindowId}, }; -use egui::{Theme, ViewportId}; +use egui::ViewportId; #[cfg(feature = "accesskit")] use egui_winit::accesskit_winit; @@ -103,16 +103,6 @@ pub enum EventResult { Exit, } -pub fn system_theme(window: &Window, options: &crate::NativeOptions) -> Option { - if options.follow_system_theme { - window - .theme() - .map(super::epi_integration::theme_from_winit_theme) - } else { - None - } -} - /// Short and fast description of an event. /// Useful for logging and profiling. pub fn short_event_description(event: &winit::event::Event) -> &'static str { diff --git a/crates/eframe/src/web/app_runner.rs b/crates/eframe/src/web/app_runner.rs index 6a9722d60f5..160ecb26d2f 100644 --- a/crates/eframe/src/web/app_runner.rs +++ b/crates/eframe/src/web/app_runner.rs @@ -1,4 +1,4 @@ -use egui::{TexturesDelta, Visuals}; +use egui::TexturesDelta; use crate::{epi, App}; @@ -38,18 +38,11 @@ impl AppRunner { ) -> Result { let painter = super::ActiveWebPainter::new(canvas_id, &web_options).await?; - let system_theme = if web_options.follow_system_theme { - super::system_theme() - } else { - None - }; - let info = epi::IntegrationInfo { web_info: epi::WebInfo { user_agent: super::user_agent().unwrap_or_default(), location: super::web_location(), }, - system_theme, cpu_usage: None, }; let storage = LocalStorage::default(); @@ -68,9 +61,6 @@ impl AppRunner { o.zoom_factor = 1.0; }); - let theme = system_theme.unwrap_or(web_options.default_theme); - egui_ctx.set_visuals(Visuals::theme(theme)); - let cc = epi::CreationContext { egui_ctx: egui_ctx.clone(), integration_info: info.clone(), diff --git a/crates/eframe/src/web/events.rs b/crates/eframe/src/web/events.rs index 7395482c521..fa3e78382b4 100644 --- a/crates/eframe/src/web/events.rs +++ b/crates/eframe/src/web/events.rs @@ -1,4 +1,3 @@ -use egui::Visuals; use web_sys::EventTarget; use super::*; @@ -368,8 +367,6 @@ pub(crate) fn install_color_scheme_change_event(runner_ref: &WebRunner) -> Resul "change", |event, runner| { let theme = theme_from_dark_mode(event.matches()); - runner.frame.info.system_theme = Some(theme); - runner.egui_ctx().set_visuals(Visuals::theme(theme)); runner.input.raw.system_theme = Some(theme); runner.needs_repaint.repaint_asap(); }, diff --git a/crates/eframe/src/web/web_runner.rs b/crates/eframe/src/web/web_runner.rs index 6f6cc9308db..6dfa8b90311 100644 --- a/crates/eframe/src/web/web_runner.rs +++ b/crates/eframe/src/web/web_runner.rs @@ -63,8 +63,6 @@ impl WebRunner { ) -> Result<(), JsValue> { self.destroy(); - let follow_system_theme = web_options.follow_system_theme; - let text_agent = TextAgent::attach(self)?; let runner = AppRunner::new(canvas_id, web_options, app_creator, text_agent).await?; @@ -82,10 +80,7 @@ impl WebRunner { { events::install_event_handlers(self)?; - - if follow_system_theme { - events::install_color_scheme_change_event(self)?; - } + events::install_color_scheme_change_event(self)?; // The resize observer handles calling `request_animation_frame` to start the render loop. events::install_resize_observer(self)?;