diff options
author | 2021-07-22 12:37:39 -0500 | |
---|---|---|
committer | 2021-07-22 12:37:39 -0500 | |
commit | e822f654e44d2d7375b7fda966bb772055f377d4 (patch) | |
tree | 8707561f1bb09c9e58cc9d9884bfb16d956f9f65 /glutin | |
parent | 1c06920158e1a47977b2762bf8b34e56fd1a935a (diff) | |
parent | dc0b96ce407283f2ffd9add5ad339f89097555d3 (diff) | |
download | iced-e822f654e44d2d7375b7fda966bb772055f377d4.tar.gz iced-e822f654e44d2d7375b7fda966bb772055f377d4.tar.bz2 iced-e822f654e44d2d7375b7fda966bb772055f377d4.zip |
Merge branch 'master' of https://github.com/hecrj/iced into wgpu_outdatedframe
Diffstat (limited to 'glutin')
-rw-r--r-- | glutin/Cargo.toml | 14 | ||||
-rw-r--r-- | glutin/README.md | 2 | ||||
-rw-r--r-- | glutin/src/application.rs | 68 | ||||
-rw-r--r-- | glutin/src/lib.rs | 2 |
4 files changed, 68 insertions, 18 deletions
diff --git a/glutin/Cargo.toml b/glutin/Cargo.toml index 505ee7e5..b2a7f307 100644 --- a/glutin/Cargo.toml +++ b/glutin/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "iced_glutin" -version = "0.1.0" +version = "0.2.0" authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"] edition = "2018" description = "A glutin runtime for Iced" @@ -13,18 +13,20 @@ categories = ["gui"] [features] debug = ["iced_winit/debug"] -[dependencies] -glutin = "0.26" +[dependencies.glutin] +version = "0.27" +git = "https://github.com/iced-rs/glutin" +rev = "03437d8a1826d83c62017b2bb7bf18bfc9e352cc" [dependencies.iced_native] -version = "0.3" +version = "0.4" path = "../native" [dependencies.iced_winit] -version = "0.2" +version = "0.3" path = "../winit" [dependencies.iced_graphics] -version = "0.1" +version = "0.2" path = "../graphics" features = ["opengl"] diff --git a/glutin/README.md b/glutin/README.md index addb9228..fcae157e 100644 --- a/glutin/README.md +++ b/glutin/README.md @@ -20,7 +20,7 @@ It exposes a renderer-agnostic `Application` trait that can be implemented and t Add `iced_glutin` as a dependency in your `Cargo.toml`: ```toml -iced_glutin = "0.1" +iced_glutin = "0.2" ``` __Iced moves fast and the `master` branch can contain breaking changes!__ If diff --git a/glutin/src/application.rs b/glutin/src/application.rs index 42513feb..991c8705 100644 --- a/glutin/src/application.rs +++ b/glutin/src/application.rs @@ -52,11 +52,14 @@ where runtime.track(subscription); let context = { - let builder = settings.window.into_builder( - &application.title(), - application.mode(), - event_loop.primary_monitor(), - ); + let builder = settings + .window + .into_builder( + &application.title(), + application.mode(), + event_loop.primary_monitor(), + ) + .with_menu(Some(conversion::menu(&application.menu()))); let context = ContextBuilder::new() .with_vsync(true) @@ -92,10 +95,11 @@ where application, compositor, renderer, - context, runtime, debug, receiver, + context, + settings.exit_on_close_request, )); let mut context = task::Context::from_waker(task::noop_waker_ref()); @@ -107,7 +111,22 @@ where return; } - if let Some(event) = event.to_static() { + let event = match event { + glutin::event::Event::WindowEvent { + event: + glutin::event::WindowEvent::ScaleFactorChanged { + new_inner_size, + .. + }, + window_id, + } => Some(glutin::event::Event::WindowEvent { + event: glutin::event::WindowEvent::Resized(*new_inner_size), + window_id, + }), + _ => event.to_static(), + }; + + if let Some(event) = event { sender.start_send(event).expect("Send event"); let poll = instance.as_mut().poll(&mut context); @@ -124,10 +143,11 @@ async fn run_instance<A, E, C>( mut application: A, mut compositor: C, mut renderer: A::Renderer, - context: glutin::ContextWrapper<glutin::PossiblyCurrent, Window>, mut runtime: Runtime<E, Proxy<A::Message>, A::Message>, mut debug: Debug, mut receiver: mpsc::UnboundedReceiver<glutin::event::Event<'_, A::Message>>, + context: glutin::ContextWrapper<glutin::PossiblyCurrent, Window>, + exit_on_close_request: bool, ) where A: Application + 'static, E: Executor + 'static, @@ -136,7 +156,7 @@ async fn run_instance<A, E, C>( use glutin::event; use iced_winit::futures::stream::StreamExt; - let clipboard = Clipboard::new(context.window()); + let mut clipboard = Clipboard::connect(context.window()); let mut state = application::State::new(&application, context.window()); let mut viewport_version = state.viewport_version(); @@ -170,8 +190,8 @@ async fn run_instance<A, E, C>( let statuses = user_interface.update( &events, state.cursor_position(), - clipboard.as_ref().map(|c| c as _), &mut renderer, + &mut clipboard, &mut messages, ); @@ -190,12 +210,15 @@ async fn run_instance<A, E, C>( &mut application, &mut runtime, &mut debug, + &mut clipboard, &mut messages, ); // Update window state.synchronize(&application, context.window()); + let should_exit = application.should_exit(); + user_interface = ManuallyDrop::new(application::build_user_interface( &mut application, @@ -204,6 +227,10 @@ async fn run_instance<A, E, C>( state.logical_size(), &mut debug, )); + + if should_exit { + break; + } } debug.draw_started(); @@ -213,6 +240,16 @@ async fn run_instance<A, E, C>( context.window().request_redraw(); } + event::Event::PlatformSpecific(event::PlatformSpecific::MacOS( + event::MacOS::ReceivedUrl(url), + )) => { + use iced_native::event; + events.push(iced_native::Event::PlatformSpecific( + event::PlatformSpecific::MacOS(event::MacOS::ReceivedUrl( + url, + )), + )); + } event::Event::UserEvent(message) => { messages.push(message); } @@ -270,10 +307,21 @@ async fn run_instance<A, E, C>( // Maybe we can use `ControlFlow::WaitUntil` for this. } event::Event::WindowEvent { + event: event::WindowEvent::MenuEntryActivated(entry_id), + .. + } => { + if let Some(message) = + conversion::menu_message(state.menu(), entry_id) + { + messages.push(message); + } + } + event::Event::WindowEvent { event: window_event, .. } => { if application::requests_exit(&window_event, state.modifiers()) + && exit_on_close_request { break; } diff --git a/glutin/src/lib.rs b/glutin/src/lib.rs index f2c0102a..107d9556 100644 --- a/glutin/src/lib.rs +++ b/glutin/src/lib.rs @@ -17,7 +17,7 @@ pub use iced_native::*; pub mod application; pub use iced_winit::settings; -pub use iced_winit::{Error, Mode}; +pub use iced_winit::{Clipboard, Error, Mode}; #[doc(no_inline)] pub use application::Application; |