From 00de9d0c9ba20b313ffb459ed291ea2b85e53d32 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 30 Mar 2021 21:33:57 +0200 Subject: Add `CloseRequested` variant to `window::Event` --- native/src/window/event.rs | 6 ++++++ winit/src/conversion.rs | 3 +++ 2 files changed, 9 insertions(+) diff --git a/native/src/window/event.rs b/native/src/window/event.rs index fc746781..3aa1ab0b 100644 --- a/native/src/window/event.rs +++ b/native/src/window/event.rs @@ -12,6 +12,12 @@ pub enum Event { height: u32, }, + /// The user has requested for the window to close. + /// + /// Usually, you will want to terminate the execution whenever this event + /// occurs. + CloseRequested, + /// A window was focused. Focused, diff --git a/winit/src/conversion.rs b/winit/src/conversion.rs index 0e04b35d..0fa27413 100644 --- a/winit/src/conversion.rs +++ b/winit/src/conversion.rs @@ -33,6 +33,9 @@ pub fn window_event( height: logical_size.height, })) } + WindowEvent::CloseRequested => { + Some(Event::Window(window::Event::CloseRequested)) + } WindowEvent::CursorMoved { position, .. } => { let position = position.to_logical::(scale_factor); -- cgit