From 07247cd4fd99f1730ddd7a5707ca12d9fe40898e Mon Sep 17 00:00:00 2001 From: Euclid Ye Date: Thu, 10 Jul 2025 12:41:41 +0800 Subject: [PATCH] servoshell: Enable headless event loop for Windows (#37975) Testing: For windows, it now passes `/_mozilla/mozilla/window_resizeTo.html` in headless mode but fails in headed window as expected in https://github.com/servo/servo/pull/37899#issuecomment-3052566865. Fixes: #37973 Fixes: #26431 Fixes: #20365 Signed-off-by: Euclid Ye yezhizhenjiakang@gmail.com Co-authored-by: Josh Matthews josh@joshmatthews.net Signed-off-by: Euclid Ye Co-authored-by: Josh Matthews --- ports/servoshell/desktop/events_loop.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/servoshell/desktop/events_loop.rs b/ports/servoshell/desktop/events_loop.rs index 4e1a64a00e5..4137001e4eb 100644 --- a/ports/servoshell/desktop/events_loop.rs +++ b/ports/servoshell/desktop/events_loop.rs @@ -47,13 +47,13 @@ pub struct EventsLoop(EventLoop); impl EventsLoop { // Ideally, we could use the winit event loop in both modes, // but on Linux, the event loop requires a X11 server. - #[cfg(not(any(target_os = "linux", target_os = "macos")))] + #[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))] pub fn new(_headless: bool, _has_output_file: bool) -> Result { Ok(EventsLoop(EventLoop::Winit( WinitEventLoop::with_user_event().build()?, ))) } - #[cfg(target_os = "linux")] + #[cfg(any(target_os = "linux", target_os = "windows"))] pub fn new(headless: bool, _has_output_file: bool) -> Result { Ok(EventsLoop(if headless { EventLoop::Headless(Arc::new((Mutex::new(false), Condvar::new())))