Introduce window::Id to Event subscriptions
And remove `window::Id` from `Event` altogether.
This commit is contained in:
parent
49affc44ff
commit
e400f972c1
19 changed files with 95 additions and 91 deletions
|
|
@ -37,9 +37,8 @@ impl Events {
|
|||
Command::none()
|
||||
}
|
||||
Message::EventOccurred(event) => {
|
||||
if let Event::Window(id, window::Event::CloseRequested) = event
|
||||
{
|
||||
window::close(id)
|
||||
if let Event::Window(window::Event::CloseRequested) = event {
|
||||
window::close(window::Id::MAIN)
|
||||
} else {
|
||||
Command::none()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ use iced_wgpu::{wgpu, Engine, Renderer};
|
|||
use iced_winit::conversion;
|
||||
use iced_winit::core::mouse;
|
||||
use iced_winit::core::renderer;
|
||||
use iced_winit::core::window;
|
||||
use iced_winit::core::{Color, Font, Pixels, Size, Theme};
|
||||
use iced_winit::futures;
|
||||
use iced_winit::runtime::program;
|
||||
|
|
@ -317,7 +316,6 @@ pub fn main() -> Result<(), winit::error::EventLoopError> {
|
|||
|
||||
// Map window event to iced event
|
||||
if let Some(event) = iced_winit::conversion::window_event(
|
||||
window::Id::MAIN,
|
||||
event,
|
||||
window.scale_factor(),
|
||||
*modifiers,
|
||||
|
|
|
|||
|
|
@ -275,7 +275,7 @@ where
|
|||
) -> event::Status {
|
||||
let state = tree.state.downcast_mut::<State>();
|
||||
|
||||
if let Event::Window(_, window::Event::RedrawRequested(now)) = event {
|
||||
if let Event::Window(window::Event::RedrawRequested(now)) = event {
|
||||
state.animation = state.animation.timed_transition(
|
||||
self.cycle_duration,
|
||||
self.rotation_duration,
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ where
|
|||
) -> event::Status {
|
||||
let state = tree.state.downcast_mut::<State>();
|
||||
|
||||
if let Event::Window(_, window::Event::RedrawRequested(now)) = event {
|
||||
if let Event::Window(window::Event::RedrawRequested(now)) = event {
|
||||
*state = state.timed_transition(self.cycle_duration, now);
|
||||
|
||||
shell.request_redraw(RedrawRequest::NextFrame);
|
||||
|
|
|
|||
|
|
@ -145,16 +145,18 @@ impl multi_window::Application for Example {
|
|||
}
|
||||
|
||||
fn subscription(&self) -> Subscription<Self::Message> {
|
||||
event::listen_with(|event, _| {
|
||||
if let iced::Event::Window(id, window_event) = event {
|
||||
event::listen_with(|event, _, window| {
|
||||
if let iced::Event::Window(window_event) = event {
|
||||
match window_event {
|
||||
window::Event::CloseRequested => {
|
||||
Some(Message::CloseWindow(id))
|
||||
Some(Message::CloseWindow(window))
|
||||
}
|
||||
window::Event::Opened { position, .. } => {
|
||||
Some(Message::WindowOpened(id, position))
|
||||
Some(Message::WindowOpened(window, position))
|
||||
}
|
||||
window::Event::Closed => {
|
||||
Some(Message::WindowClosed(window))
|
||||
}
|
||||
window::Event::Closed => Some(Message::WindowClosed(id)),
|
||||
_ => None,
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -499,9 +499,7 @@ mod toast {
|
|||
clipboard: &mut dyn Clipboard,
|
||||
shell: &mut Shell<'_, Message>,
|
||||
) -> event::Status {
|
||||
if let Event::Window(_, window::Event::RedrawRequested(now)) =
|
||||
&event
|
||||
{
|
||||
if let Event::Window(window::Event::RedrawRequested(now)) = &event {
|
||||
let mut next_redraw: Option<window::RedrawRequest> = None;
|
||||
|
||||
self.instants.iter_mut().enumerate().for_each(
|
||||
|
|
|
|||
|
|
@ -145,11 +145,11 @@ impl Example {
|
|||
}
|
||||
|
||||
fn subscription(&self) -> Subscription<Message> {
|
||||
event::listen_with(|event, _| match event {
|
||||
event::listen_with(|event, _status, _window| match event {
|
||||
Event::Mouse(mouse::Event::CursorMoved { position }) => {
|
||||
Some(Message::MouseMoved(position))
|
||||
}
|
||||
Event::Window(_, window::Event::Resized { .. }) => {
|
||||
Event::Window(window::Event::Resized { .. }) => {
|
||||
Some(Message::WindowResized)
|
||||
}
|
||||
_ => None,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue