Handle clipboard::Action in iced_winit shell

This commit is contained in:
Héctor Ramón Jiménez 2021-09-02 13:46:01 +07:00
parent 76698ff2b5
commit c9711ff48f
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
5 changed files with 57 additions and 17 deletions

View file

@ -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,
);