summaryrefslogtreecommitdiffstats
path: root/winit/src/application
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector@hecrj.dev>2024-06-11 20:22:44 +0200
committerLibravatar GitHub <noreply@github.com>2024-06-11 20:22:44 +0200
commite6d0b3bda5042a1017a5944a5227c97e0ed6caf9 (patch)
tree916f837424c3baeacc1e0f43b02bc892a3445cbb /winit/src/application
parentbda01567d59c00e42e5a208ee6d9ec4153d5c195 (diff)
parent6ea7846d88915f8d820c5126d7757f1346234522 (diff)
downloadiced-e6d0b3bda5042a1017a5944a5227c97e0ed6caf9.tar.gz
iced-e6d0b3bda5042a1017a5944a5227c97e0ed6caf9.tar.bz2
iced-e6d0b3bda5042a1017a5944a5227c97e0ed6caf9.zip
Merge pull request #2456 from iced-rs/window-id-in-event-subscriptions
Introduce `window::Id` to `Event` subscriptions
Diffstat (limited to '')
-rw-r--r--winit/src/application.rs27
1 files changed, 16 insertions, 11 deletions
diff --git a/winit/src/application.rs b/winit/src/application.rs
index 4aed1eee..d93ea42e 100644
--- a/winit/src/application.rs
+++ b/winit/src/application.rs
@@ -12,7 +12,8 @@ use crate::core::widget::operation;
use crate::core::window;
use crate::core::{Color, Event, Point, Size, Theme};
use crate::futures::futures;
-use crate::futures::{Executor, Runtime, Subscription};
+use crate::futures::subscription::{self, Subscription};
+use crate::futures::{Executor, Runtime};
use crate::graphics;
use crate::graphics::compositor::{self, Compositor};
use crate::runtime::clipboard;
@@ -574,12 +575,10 @@ async fn run_instance<A, E, C>(
event::Event::PlatformSpecific(event::PlatformSpecific::MacOS(
event::MacOS::ReceivedUrl(url),
)) => {
- use crate::core::event;
-
- events.push(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) => {
@@ -623,7 +622,6 @@ async fn run_instance<A, E, C>(
// 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 = Event::Window(
- window::Id::MAIN,
window::Event::RedrawRequested(Instant::now()),
);
@@ -651,7 +649,11 @@ async fn run_instance<A, E, C>(
_ => ControlFlow::Wait,
});
- runtime.broadcast(redraw_event, core::event::Status::Ignored);
+ runtime.broadcast(subscription::Event::Interaction {
+ window: window::Id::MAIN,
+ event: redraw_event,
+ status: core::event::Status::Ignored,
+ });
debug.draw_started();
let new_mouse_interaction = user_interface.draw(
@@ -714,7 +716,6 @@ async fn run_instance<A, E, C>(
state.update(&window, &window_event, &mut debug);
if let Some(event) = conversion::window_event(
- window::Id::MAIN,
window_event,
state.scale_factor(),
state.modifiers(),
@@ -742,7 +743,11 @@ async fn run_instance<A, E, C>(
for (event, status) in
events.drain(..).zip(statuses.into_iter())
{
- runtime.broadcast(event, status);
+ runtime.broadcast(subscription::Event::Interaction {
+ window: window::Id::MAIN,
+ event,
+ status,
+ });
}
if !messages.is_empty()