From c9711ff48fa1ad16365bc7eb37fa7153143bcee6 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez 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') 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::( @@ -97,6 +106,8 @@ where compositor, renderer, runtime, + clipboard, + proxy, debug, receiver, context, @@ -145,6 +156,8 @@ async fn run_instance( mut compositor: C, mut renderer: A::Renderer, mut runtime: Runtime, A::Message>, + mut clipboard: Clipboard, + mut proxy: glutin::event_loop::EventLoopProxy, mut debug: Debug, mut receiver: mpsc::UnboundedReceiver>, mut context: glutin::ContextWrapper, @@ -157,8 +170,6 @@ async fn run_instance( 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( application::update( &mut application, &mut runtime, + &mut clipboard, + &mut proxy, &mut debug, &mut messages, ); -- cgit