From e400f972c1fe6fa4f70f8cfe559ded680e6cf740 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 4 Jun 2024 23:20:33 +0200 Subject: Introduce `window::Id` to `Event` subscriptions And remove `window::Id` from `Event` altogether. --- winit/src/multi_window.rs | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) (limited to 'winit/src/multi_window.rs') diff --git a/winit/src/multi_window.rs b/winit/src/multi_window.rs index 74ab64f2..3696f952 100644 --- a/winit/src/multi_window.rs +++ b/winit/src/multi_window.rs @@ -492,13 +492,10 @@ async fn run_instance( let mut events = { vec![( Some(window::Id::MAIN), - core::Event::Window( - window::Id::MAIN, - window::Event::Opened { - position: main_window.position(), - size: main_window.size(), - }, - ), + core::Event::Window(window::Event::Opened { + position: main_window.position(), + size: main_window.size(), + }), )] }; @@ -565,13 +562,10 @@ async fn run_instance( events.push(( Some(id), - core::Event::Window( - id, - window::Event::Opened { - position: window.position(), - size: window.size(), - }, - ), + core::Event::Window(window::Event::Opened { + position: window.position(), + size: window.size(), + }), )); } Event::EventLoopAwakened(event) => { @@ -623,7 +617,6 @@ async fn run_instance( // Then, we can use the `interface_state` here to decide if a redraw // is needed right away, or simply wait until a specific time. let redraw_event = core::Event::Window( - id, window::Event::RedrawRequested(Instant::now()), ); @@ -665,6 +658,7 @@ async fn run_instance( runtime.broadcast( redraw_event.clone(), core::event::Status::Ignored, + id, ); let _ = control_sender.start_send(Control::ChangeFlow( @@ -802,7 +796,7 @@ async fn run_instance( events.push(( None, - core::Event::Window(id, window::Event::Closed), + core::Event::Window(window::Event::Closed), )); if window_manager.is_empty() { @@ -816,7 +810,6 @@ async fn run_instance( ); if let Some(event) = conversion::window_event( - id, window_event, window.state.scale_factor(), window.state.modifiers(), @@ -874,7 +867,7 @@ async fn run_instance( .into_iter() .zip(statuses.into_iter()) { - runtime.broadcast(event, status); + runtime.broadcast(event, status, id); } } -- cgit 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/multi_window.rs') 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 From 83296a73ebbb3c02ed63dfb4661056a8a8962267 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 7 Jun 2024 01:59:17 +0200 Subject: Fix widget operations in `multi_window` runtime --- winit/src/multi_window.rs | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'winit/src/multi_window.rs') diff --git a/winit/src/multi_window.rs b/winit/src/multi_window.rs index b4c30a20..13839828 100644 --- a/winit/src/multi_window.rs +++ b/winit/src/multi_window.rs @@ -1272,25 +1272,20 @@ fn run_command( std::mem::take(ui_caches), ); - 'operate: while let Some(mut operation) = - current_operation.take() - { + while let Some(mut operation) = current_operation.take() { for (id, ui) in uis.iter_mut() { if let Some(window) = window_manager.get_mut(*id) { ui.operate(&window.renderer, operation.as_mut()); + } + } - match operation.finish() { - operation::Outcome::None => {} - operation::Outcome::Some(message) => { - proxy.send(message); - - // operation completed, don't need to try to operate on rest of UIs - break 'operate; - } - operation::Outcome::Chain(next) => { - current_operation = Some(next); - } - } + match operation.finish() { + operation::Outcome::None => {} + operation::Outcome::Some(message) => { + proxy.send(message); + } + operation::Outcome::Chain(next) => { + current_operation = Some(next); } } } -- cgit From 5d7dcf417c694853a606b8fb0a47a580277fc9c0 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 11 Jun 2024 19:41:05 +0200 Subject: Introduce `subscription::Event` ... and remove `PlatformSpecific` from `Event` --- winit/src/multi_window.rs | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'winit/src/multi_window.rs') diff --git a/winit/src/multi_window.rs b/winit/src/multi_window.rs index 13839828..2eaf9241 100644 --- a/winit/src/multi_window.rs +++ b/winit/src/multi_window.rs @@ -16,7 +16,8 @@ use crate::futures::futures::channel::oneshot; use crate::futures::futures::executor; use crate::futures::futures::task; use crate::futures::futures::{Future, StreamExt}; -use crate::futures::{Executor, Runtime, Subscription}; +use crate::futures::subscription::{self, Subscription}; +use crate::futures::{Executor, Runtime}; use crate::graphics; use crate::graphics::{compositor, Compositor}; use crate::multi_window::window_manager::WindowManager; @@ -585,16 +586,13 @@ async fn run_instance( event::MacOS::ReceivedUrl(url), ), ) => { - use crate::core::event; - - events.push(( - window::Id::MAIN, - event::Event::PlatformSpecific( - event::PlatformSpecific::MacOS( - event::MacOS::ReceivedUrl(url), + runtime.broadcast( + subscription::Event::PlatformSpecific( + subscription::PlatformSpecific::MacOS( + subscription::MacOS::ReceivedUrl(url), ), ), - )); + ); } event::Event::UserEvent(message) => { messages.push(message); @@ -655,11 +653,11 @@ async fn run_instance( window.mouse_interaction = new_mouse_interaction; } - runtime.broadcast( - redraw_event.clone(), - core::event::Status::Ignored, - id, - ); + runtime.broadcast(subscription::Event::Interaction { + window: id, + event: redraw_event, + status: core::event::Status::Ignored, + }); let _ = control_sender.start_send(Control::ChangeFlow( match ui_state { @@ -866,15 +864,23 @@ async fn run_instance( .into_iter() .zip(statuses.into_iter()) { - runtime.broadcast(event, status, id); + runtime.broadcast( + subscription::Event::Interaction { + window: id, + event, + status, + }, + ); } } for (id, event) in events.drain(..) { runtime.broadcast( - event, - core::event::Status::Ignored, - id, + subscription::Event::Interaction { + window: id, + event, + status: core::event::Status::Ignored, + }, ); } -- cgit