summaryrefslogtreecommitdiffstats
path: root/glutin
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-07-28 02:46:51 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-07-28 02:46:51 +0200
commit80688689aa4b15bc23824df899974a9094a77b07 (patch)
treebbfce1c91b9ee22990503a55d31d04cadf4093b7 /glutin
parenta003e797e8a1bb5d365c1db5de6af88e61a47329 (diff)
downloadiced-80688689aa4b15bc23824df899974a9094a77b07.tar.gz
iced-80688689aa4b15bc23824df899974a9094a77b07.tar.bz2
iced-80688689aa4b15bc23824df899974a9094a77b07.zip
Draft widget operations
Diffstat (limited to 'glutin')
-rw-r--r--glutin/src/application.rs46
1 files changed, 26 insertions, 20 deletions
diff --git a/glutin/src/application.rs b/glutin/src/application.rs
index dddf0067..96b982ac 100644
--- a/glutin/src/application.rs
+++ b/glutin/src/application.rs
@@ -12,7 +12,7 @@ use iced_winit::futures;
use iced_winit::futures::channel::mpsc;
use iced_winit::renderer;
use iced_winit::user_interface;
-use iced_winit::{Clipboard, Debug, Proxy, Settings};
+use iced_winit::{Clipboard, Command, Debug, Proxy, Settings};
use glutin::window::Window;
use std::mem::ManuallyDrop;
@@ -39,9 +39,9 @@ where
debug.startup_started();
let mut event_loop = EventLoop::with_user_event();
- let mut proxy = event_loop.create_proxy();
+ let proxy = event_loop.create_proxy();
- let mut runtime = {
+ let runtime = {
let executor = E::new().map_err(Error::ExecutorCreationFailed)?;
let proxy = Proxy::new(event_loop.create_proxy());
@@ -54,8 +54,6 @@ where
runtime.enter(|| A::new(flags))
};
- let subscription = application.subscription();
-
let context = {
let builder = settings.window.into_builder(
&application.title(),
@@ -125,18 +123,6 @@ where
})?
};
- let mut clipboard = Clipboard::connect(context.window());
-
- application::run_command(
- init_command,
- &mut runtime,
- &mut clipboard,
- &mut proxy,
- context.window(),
- || compositor.fetch_information(),
- );
- runtime.track(subscription);
-
let (mut sender, receiver) = mpsc::unbounded();
let mut instance = Box::pin(run_instance::<A, E, C>(
@@ -144,11 +130,11 @@ where
compositor,
renderer,
runtime,
- clipboard,
proxy,
debug,
receiver,
context,
+ init_command,
settings.exit_on_close_request,
));
@@ -196,11 +182,11 @@ 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>,
+ init_command: Command<A::Message>,
exit_on_close_request: bool,
) where
A: Application + 'static,
@@ -211,9 +197,26 @@ 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 cache = user_interface::Cache::default();
let mut state = application::State::new(&application, context.window());
let mut viewport_version = state.viewport_version();
+ application::run_command(
+ &application,
+ &mut cache,
+ &state,
+ &mut renderer,
+ init_command,
+ &mut runtime,
+ &mut clipboard,
+ &mut proxy,
+ &mut debug,
+ context.window(),
+ || compositor.fetch_information(),
+ );
+ runtime.track(application.subscription());
+
let mut user_interface =
ManuallyDrop::new(application::build_user_interface(
&mut application,
@@ -258,12 +261,15 @@ async fn run_instance<A, E, C>(
user_interface::State::Outdated
)
{
- let cache =
+ let mut cache =
ManuallyDrop::into_inner(user_interface).into_cache();
// Update application
application::update(
&mut application,
+ &mut cache,
+ &state,
+ &mut renderer,
&mut runtime,
&mut clipboard,
&mut proxy,