From 76698ff2b5753e637b14533650c0d28e681be3c5 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez <hector0193@gmail.com> Date: Wed, 1 Sep 2021 19:21:49 +0700 Subject: Make `Command` implementations platform-specific This allows us to introduce a platform-specific `Action` to both `iced_native` and `iced_web` and remove the `Clipboard` from `Application::update` to maintain purity. Additionally, this should let us implement further actions to let users query and modify the shell environment (e.g. window, clipboard, and more!) --- glutin/src/application.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'glutin/src/application.rs') diff --git a/glutin/src/application.rs b/glutin/src/application.rs index 4a5f4bd2..1368f7f8 100644 --- a/glutin/src/application.rs +++ b/glutin/src/application.rs @@ -48,7 +48,7 @@ where let subscription = application.subscription(); - runtime.spawn(init_command); + application::run_command(init_command, &mut runtime); runtime.track(subscription); let context = { @@ -211,7 +211,6 @@ async fn run_instance<A, E, C>( &mut application, &mut runtime, &mut debug, - &mut clipboard, &mut messages, ); -- cgit From c9711ff48fa1ad16365bc7eb37fa7153143bcee6 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez <hector0193@gmail.com> Date: Thu, 2 Sep 2021 13:46:01 +0700 Subject: Handle `clipboard::Action` in `iced_winit` shell --- glutin/src/application.rs | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'glutin/src/application.rs') diff --git a/glutin/src/application.rs b/glutin/src/application.rs index 1368f7f8..cef49ea0 100644 --- a/glutin/src/application.rs +++ b/glutin/src/application.rs @@ -33,6 +33,8 @@ where debug.startup_started(); let event_loop = EventLoop::with_user_event(); + let mut proxy = event_loop.create_proxy(); + let mut runtime = { let executor = E::new().map_err(Error::ExecutorCreationFailed)?; let proxy = Proxy::new(event_loop.create_proxy()); @@ -48,9 +50,6 @@ where let subscription = application.subscription(); - application::run_command(init_command, &mut runtime); - runtime.track(subscription); - let context = { let builder = settings .window @@ -90,6 +89,16 @@ where })? }; + let mut clipboard = Clipboard::connect(context.window()); + + application::run_command( + init_command, + &mut runtime, + &mut clipboard, + &mut proxy, + ); + runtime.track(subscription); + let (mut sender, receiver) = mpsc::unbounded(); let mut instance = Box::pin(run_instance::<A, E, C>( @@ -97,6 +106,8 @@ where compositor, renderer, runtime, + clipboard, + proxy, debug, receiver, context, @@ -145,6 +156,8 @@ async fn run_instance<A, E, C>( mut compositor: C, mut renderer: A::Renderer, mut runtime: Runtime<E, Proxy<A::Message>, A::Message>, + mut clipboard: Clipboard, + mut proxy: glutin::event_loop::EventLoopProxy<A::Message>, mut debug: Debug, mut receiver: mpsc::UnboundedReceiver<glutin::event::Event<'_, A::Message>>, mut context: glutin::ContextWrapper<glutin::PossiblyCurrent, Window>, @@ -157,8 +170,6 @@ async fn run_instance<A, E, C>( use glutin::event; use iced_winit::futures::stream::StreamExt; - let mut clipboard = Clipboard::connect(context.window()); - let mut state = application::State::new(&application, context.window()); let mut viewport_version = state.viewport_version(); let mut user_interface = @@ -210,6 +221,8 @@ async fn run_instance<A, E, C>( application::update( &mut application, &mut runtime, + &mut clipboard, + &mut proxy, &mut debug, &mut messages, ); -- cgit From 7cb6e7438f7fb5d0d8be4528a31b888e2b12cd51 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez <hector0193@gmail.com> Date: Thu, 2 Sep 2021 16:30:14 +0700 Subject: Implement `move_to` and `resize` commands for `window` --- glutin/src/application.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'glutin/src/application.rs') diff --git a/glutin/src/application.rs b/glutin/src/application.rs index cef49ea0..936f0cce 100644 --- a/glutin/src/application.rs +++ b/glutin/src/application.rs @@ -96,6 +96,7 @@ where &mut runtime, &mut clipboard, &mut proxy, + context.window(), ); runtime.track(subscription); @@ -225,6 +226,7 @@ async fn run_instance<A, E, C>( &mut proxy, &mut debug, &mut messages, + context.window(), ); // Update window -- cgit