mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 21:30:03 -04:00
Create new helper fn to determine initial window visibility
This commit is contained in:
@@ -90,6 +90,20 @@ pub fn viewport_builder(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn should_start_visible() -> bool {
|
||||||
|
if cfg!(feature = "accesskit") {
|
||||||
|
false // accesskit requires this: https://docs.rs/accesskit_winit/latest/accesskit_winit/struct.Adapter.html#method.with_event_loop_proxy
|
||||||
|
} else if cfg!(windows) {
|
||||||
|
false // Fixes white flash on startup (https://github.com/emilk/egui/pull/3631)
|
||||||
|
} else if cfg!(target_os = "macos") {
|
||||||
|
// Fix the top window area not being clickable on macOS when in fullscreen on an external display
|
||||||
|
// See https://github.com/rust-windowing/winit/issues/4295, https://github.com/rerun-io/rerun/issues/10280
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false // no known preference one way or the other
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn apply_window_settings(
|
pub fn apply_window_settings(
|
||||||
window: &winit::window::Window,
|
window: &winit::window::Window,
|
||||||
window_settings: Option<WindowSettings>,
|
window_settings: Option<WindowSettings>,
|
||||||
|
|||||||
@@ -31,15 +31,15 @@ use egui::{
|
|||||||
#[cfg(feature = "accesskit")]
|
#[cfg(feature = "accesskit")]
|
||||||
use egui_winit::accesskit_winit;
|
use egui_winit::accesskit_winit;
|
||||||
|
|
||||||
use crate::{
|
|
||||||
App, AppCreator, CreationContext, NativeOptions, Result, Storage,
|
|
||||||
native::epi_integration::EpiIntegration,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
epi_integration, event_loop_context,
|
epi_integration, event_loop_context,
|
||||||
winit_integration::{EventResult, UserEvent, WinitApp, create_egui_context},
|
winit_integration::{EventResult, UserEvent, WinitApp, create_egui_context},
|
||||||
};
|
};
|
||||||
|
use crate::native::epi_integration::should_start_visible;
|
||||||
|
use crate::{
|
||||||
|
App, AppCreator, CreationContext, NativeOptions, Result, Storage,
|
||||||
|
native::epi_integration::EpiIntegration,
|
||||||
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Types:
|
// Types:
|
||||||
@@ -155,12 +155,7 @@ impl<'app> GlowWinitApp<'app> {
|
|||||||
native_options,
|
native_options,
|
||||||
window_settings,
|
window_settings,
|
||||||
)
|
)
|
||||||
.with_visible(false); // Start hidden until we render the first frame to fix white flash on startup (https://github.com/emilk/egui/pull/3631)
|
.with_visible(should_start_visible());
|
||||||
|
|
||||||
// Fix the top window area not being clickable on macOS when in fullscreen on an external display
|
|
||||||
// See https://github.com/rust-windowing/winit/issues/4295, https://github.com/rerun-io/rerun/issues/10280
|
|
||||||
#[cfg(all(target_os = "macos", not(feature = "accesskit")))]
|
|
||||||
let winit_window_builder = winit_window_builder.with_visible(true);
|
|
||||||
|
|
||||||
let mut glutin_window_context = unsafe {
|
let mut glutin_window_context = unsafe {
|
||||||
GlutinWindowContext::new(egui_ctx, winit_window_builder, native_options, event_loop)?
|
GlutinWindowContext::new(egui_ctx, winit_window_builder, native_options, event_loop)?
|
||||||
|
|||||||
@@ -24,13 +24,13 @@ use egui::{
|
|||||||
use egui_winit::accesskit_winit;
|
use egui_winit::accesskit_winit;
|
||||||
use winit_integration::UserEvent;
|
use winit_integration::UserEvent;
|
||||||
|
|
||||||
|
use super::{epi_integration, event_loop_context, winit_integration, winit_integration::WinitApp};
|
||||||
|
use crate::native::epi_integration::should_start_visible;
|
||||||
use crate::{
|
use crate::{
|
||||||
App, AppCreator, CreationContext, NativeOptions, Result, Storage,
|
App, AppCreator, CreationContext, NativeOptions, Result, Storage,
|
||||||
native::{epi_integration::EpiIntegration, winit_integration::EventResult},
|
native::{epi_integration::EpiIntegration, winit_integration::EventResult},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{epi_integration, event_loop_context, winit_integration, winit_integration::WinitApp};
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Types:
|
// Types:
|
||||||
|
|
||||||
@@ -911,12 +911,7 @@ fn create_window(
|
|||||||
native_options,
|
native_options,
|
||||||
window_settings,
|
window_settings,
|
||||||
)
|
)
|
||||||
.with_visible(false); // Start hidden until we render the first frame to fix white flash on startup (https://github.com/emilk/egui/pull/3631)
|
.with_visible(should_start_visible()); // Start hidden until we render the first frame to fix white flash on startup (https://github.com/emilk/egui/pull/3631)
|
||||||
|
|
||||||
// Fix the top window area not being clickable on macOS when in fullscreen on an external display
|
|
||||||
// See https://github.com/rust-windowing/winit/issues/4295, https://github.com/rerun-io/rerun/issues/10280
|
|
||||||
#[cfg(all(target_os = "macos", not(feature = "accesskit")))]
|
|
||||||
let viewport_builder = viewport_builder.with_visible(true);
|
|
||||||
|
|
||||||
let window = egui_winit::create_window(egui_ctx, event_loop, &viewport_builder)?;
|
let window = egui_winit::create_window(egui_ctx, event_loop, &viewport_builder)?;
|
||||||
epi_integration::apply_window_settings(&window, window_settings);
|
epi_integration::apply_window_settings(&window, window_settings);
|
||||||
|
|||||||
Reference in New Issue
Block a user