diff --git a/crates/eframe/src/native/epi_integration.rs b/crates/eframe/src/native/epi_integration.rs index cca0f999f1a..066deae4370 100644 --- a/crates/eframe/src/native/epi_integration.rs +++ b/crates/eframe/src/native/epi_integration.rs @@ -338,11 +338,12 @@ impl EpiIntegration { app_name: &str, native_options: &crate::NativeOptions, storage: Option>, - desktop: bool, + is_desktop: bool, #[cfg(feature = "glow")] gl: Option>, #[cfg(feature = "wgpu")] wgpu_render_state: Option, ) -> Self { - let egui_ctx = egui::Context::new(desktop); + let egui_ctx = egui::Context::default(); + egui_ctx.set_embed_viewports(!is_desktop); let memory = load_egui_memory(storage.as_deref()).unwrap_or_default(); egui_ctx.memory_mut(|mem| *mem = memory); diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index b9ffefaf7f5..d3849e76ac9 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -173,7 +173,6 @@ struct ContextImpl { viewports: ViewportMap, viewport_commands: Vec<(ViewportId, ViewportCommand)>, - is_desktop: bool, embed_viewports: bool, /// Written to during the frame. @@ -504,16 +503,6 @@ impl Context { self.write(|ctx| ctx.begin_frame_mut(new_input, id_pair)); } - - /// Create a new Context and specify if is desktop - pub fn new(desktop: bool) -> Context { - let context = Context::default(); - context.write(|ctx| { - ctx.is_desktop = desktop; - ctx.embed_viewports = !desktop; - }); - context - } } /// ## Borrows parts of [`Context`] @@ -2525,20 +2514,22 @@ impl Context { }); } - /// This will tell you if is possible to open a native window - pub fn is_desktop(&self) -> bool { - self.read(|ctx| ctx.is_desktop) - } - - /// If this is true no other native window will be created, when a viewport is created! + /// If `true`, [`Self::create_viewport_async`] and [`Self::create_viewport_sync`] will + /// embed the new viewports as [`egui::Window`]s instead of spawning a new native window. + /// + /// `eframe` sets this to `false` on supported platforms, + /// but the default value is `true`. pub fn embed_viewports(&self) -> bool { self.read(|ctx| ctx.embed_viewports) } - /// If this is true no other native window will be created, when a viewport is created! - /// You will always be able to set to true + /// If `true`, [`Self::create_viewport_async`] and [`Self::create_viewport_sync`] will + /// embed the new viewports as [`egui::Window`]s instead of spawning a new native window. + /// + /// `eframe` sets this to `false` on supported platforms, + /// but the default value is `true`. pub fn set_embed_viewports(&self, value: bool) { - self.write(|ctx| ctx.embed_viewports = value || !ctx.is_desktop); + self.write(|ctx| ctx.embed_viewports = value); } /// Send a command to the current viewport.