Introduce subscription::Event

... and remove `PlatformSpecific` from `Event`
This commit is contained in:
Héctor Ramón Jiménez 2024-06-11 19:41:05 +02:00
parent 83296a73eb
commit 5d7dcf417c
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
13 changed files with 156 additions and 129 deletions

View file

@ -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) => {
@ -650,11 +649,11 @@ async fn run_instance<A, E, C>(
_ => ControlFlow::Wait,
});
runtime.broadcast(
redraw_event,
core::event::Status::Ignored,
window::Id::MAIN,
);
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(
@ -744,7 +743,11 @@ async fn run_instance<A, E, C>(
for (event, status) in
events.drain(..).zip(statuses.into_iter())
{
runtime.broadcast(event, status, window::Id::MAIN);
runtime.broadcast(subscription::Event::Interaction {
window: window::Id::MAIN,
event,
status,
});
}
if !messages.is_empty()

View file

@ -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<A, E, C>(
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<A, E, C>(
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<A, E, C>(
.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,
},
);
}