servoshell: Fallback to light theme when initializing egui (#37228)

Not all winit platforms support getting the system theme properly. In
some places we fall back to the light theme, but it seems that the
default for `egui` is dark. This change makes it so that we fall back to
the light theme more consistently, meaning that servoshell on Wayland
will properly use the light theme.

Testing: This is difficult to test because we have no servoshell display
tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2025-06-03 15:47:10 +02:00 committed by GitHub
parent 5ef66ce386
commit c94605b13e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -39,6 +39,7 @@ pub use egui_winit;
pub use egui_winit::EventResponse; pub use egui_winit::EventResponse;
use egui_winit::winit; use egui_winit::winit;
use winit::event_loop::ActiveEventLoop; use winit::event_loop::ActiveEventLoop;
use winit::window::Theme;
/// Use [`egui`] from a [`glow`] app based on [`winit`]. /// Use [`egui`] from a [`glow`] app based on [`winit`].
pub struct EguiGlow { pub struct EguiGlow {
@ -63,6 +64,7 @@ impl EguiGlow {
}) })
.unwrap(); .unwrap();
let theme = event_loop.system_theme().unwrap_or(Theme::Light);
let egui_ctx = egui::Context::default(); let egui_ctx = egui::Context::default();
Self { Self {
egui_winit: egui_winit::State::new( egui_winit: egui_winit::State::new(
@ -70,7 +72,7 @@ impl EguiGlow {
ViewportId::ROOT, ViewportId::ROOT,
event_loop, event_loop,
None, None,
event_loop.system_theme(), Some(theme),
None, None,
), ),
egui_ctx, egui_ctx,