From 2fe01a0b1ee930759d2180fe25666c0701bffd40 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 10 Oct 2019 05:53:57 +0200 Subject: Use improved `RedrawRequested` API in `iced_winit` --- winit/Cargo.toml | 2 +- winit/src/application.rs | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/winit/Cargo.toml b/winit/Cargo.toml index 15158e0e..fa5d6adf 100644 --- a/winit/Cargo.toml +++ b/winit/Cargo.toml @@ -9,5 +9,5 @@ repository = "https://github.com/hecrj/iced" [dependencies] iced_native = { version = "0.1.0-alpha", path = "../native" } -winit = "0.20.0-alpha3" +winit = { version = "0.20.0-alpha3", git = "https://github.com/hecrj/winit", branch = "redraw-requested-2.0" } log = "0.4" diff --git a/winit/src/application.rs b/winit/src/application.rs index d09aad7a..ab6a43f5 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -48,7 +48,7 @@ pub trait Application { window.request_redraw(); event_loop.run(move |event, _, control_flow| match event { - event::Event::EventsCleared => { + event::Event::MainEventsCleared => { // TODO: We should be able to keep a user interface alive // between events once we remove state references. // @@ -90,16 +90,16 @@ pub trait Application { window.request_redraw(); } + event::Event::RedrawRequested(_) => { + renderer.draw(&mut target, &primitive); + + // TODO: Handle animations! + // Maybe we can use `ControlFlow::WaitUntil` for this. + } event::Event::WindowEvent { event: window_event, .. } => match window_event { - WindowEvent::RedrawRequested => { - renderer.draw(&mut target, &primitive); - - // TODO: Handle animations! - // Maybe we can use `ControlFlow::WaitUntil` for this. - } WindowEvent::CursorMoved { position, .. } => { let physical_position = position.to_physical(window.hidpi_factor()); -- cgit