From ae2bf8ee40d1eb8f8176eae4541550fa2365f7a4 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 6 Jun 2024 02:13:06 +0200 Subject: Broadcast orphaned events in `multi_window` runtime --- winit/src/multi_window.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'winit/src') diff --git a/winit/src/multi_window.rs b/winit/src/multi_window.rs index 3696f952..b4c30a20 100644 --- a/winit/src/multi_window.rs +++ b/winit/src/multi_window.rs @@ -491,7 +491,7 @@ async fn run_instance( let mut clipboard = Clipboard::connect(&main_window.raw); let mut events = { vec![( - Some(window::Id::MAIN), + window::Id::MAIN, core::Event::Window(window::Event::Opened { position: main_window.position(), size: main_window.size(), @@ -561,7 +561,7 @@ async fn run_instance( let _ = ui_caches.insert(id, user_interface::Cache::default()); events.push(( - Some(id), + id, core::Event::Window(window::Event::Opened { position: window.position(), size: window.size(), @@ -588,7 +588,7 @@ async fn run_instance( use crate::core::event; events.push(( - None, + window::Id::MAIN, event::Event::PlatformSpecific( event::PlatformSpecific::MacOS( event::MacOS::ReceivedUrl(url), @@ -795,7 +795,7 @@ async fn run_instance( let _ = ui_caches.remove(&id); events.push(( - None, + id, core::Event::Window(window::Event::Closed), )); @@ -814,7 +814,7 @@ async fn run_instance( window.state.scale_factor(), window.state.modifiers(), ) { - events.push((Some(id), event)); + events.push((id, event)); } } } @@ -830,8 +830,7 @@ async fn run_instance( let mut window_events = vec![]; events.retain(|(window_id, event)| { - if *window_id == Some(id) || window_id.is_none() - { + if *window_id == id { window_events.push(event.clone()); false } else { @@ -871,6 +870,14 @@ async fn run_instance( } } + for (id, event) in events.drain(..) { + runtime.broadcast( + event, + core::event::Status::Ignored, + id, + ); + } + debug.event_processing_finished(); // TODO mw application update returns which window IDs to update -- cgit