diff options
author | 2022-12-15 03:06:04 +0100 | |
---|---|---|
committer | 2022-12-15 03:06:04 +0100 | |
commit | b5ab50b2a8a869d8d433d9e13878c1cf1d721414 (patch) | |
tree | 0df0af8b14189cd437eb9d276f7f54825c961464 /winit/src/application.rs | |
parent | 0591798db7afb945d634e1f6f781701f4549bc6a (diff) | |
download | iced-b5ab50b2a8a869d8d433d9e13878c1cf1d721414.tar.gz iced-b5ab50b2a8a869d8d433d9e13878c1cf1d721414.tar.bz2 iced-b5ab50b2a8a869d8d433d9e13878c1cf1d721414.zip |
Implement `window::close` action and remove `should_exit`
Diffstat (limited to 'winit/src/application.rs')
-rw-r--r-- | winit/src/application.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/winit/src/application.rs b/winit/src/application.rs index d17db2cd..0f9b562e 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -93,13 +93,6 @@ where fn scale_factor(&self) -> f64 { 1.0 } - - /// Returns whether the [`Application`] should be terminated. - /// - /// By default, it returns `false`. - fn should_exit(&self) -> bool { - false - } } /// Runs an [`Application`] with an executor, compositor, and the provided @@ -255,6 +248,7 @@ async fn run_instance<A, E, C>( let mut clipboard = Clipboard::connect(&window); let mut cache = user_interface::Cache::default(); let mut surface = compositor.create_surface(&window); + let mut should_exit = false; let mut state = State::new(&application, &window); let mut viewport_version = state.viewport_version(); @@ -275,6 +269,7 @@ async fn run_instance<A, E, C>( init_command, &mut runtime, &mut clipboard, + &mut should_exit, &mut proxy, &mut debug, &window, @@ -336,6 +331,7 @@ async fn run_instance<A, E, C>( &mut renderer, &mut runtime, &mut clipboard, + &mut should_exit, &mut proxy, &mut debug, &mut messages, @@ -346,8 +342,6 @@ async fn run_instance<A, E, C>( // Update window state.synchronize(&application, &window); - let should_exit = application.should_exit(); - user_interface = ManuallyDrop::new(build_user_interface( &application, cache, @@ -555,6 +549,7 @@ pub fn update<A: Application, E: Executor>( renderer: &mut A::Renderer, runtime: &mut Runtime<E, Proxy<A::Message>, A::Message>, clipboard: &mut Clipboard, + should_exit: &mut bool, proxy: &mut winit::event_loop::EventLoopProxy<A::Message>, debug: &mut Debug, messages: &mut Vec<A::Message>, @@ -578,6 +573,7 @@ pub fn update<A: Application, E: Executor>( command, runtime, clipboard, + should_exit, proxy, debug, window, @@ -598,6 +594,7 @@ pub fn run_command<A, E>( command: Command<A::Message>, runtime: &mut Runtime<E, Proxy<A::Message>, A::Message>, clipboard: &mut Clipboard, + should_exit: &mut bool, proxy: &mut winit::event_loop::EventLoopProxy<A::Message>, debug: &mut Debug, window: &winit::window::Window, @@ -629,6 +626,9 @@ pub fn run_command<A, E>( } }, command::Action::Window(action) => match action { + window::Action::Close => { + *should_exit = true; + } window::Action::Drag => { let _res = window.drag_window(); } |