servoshell: Fallback to light theme when initializing egui

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.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2025-06-03 12:26:39 +02:00
parent 56c0ad8420
commit 9e453740b9

View file

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