From 0b140488b425a7d1fd45ca41592de25b28d3ac17 Mon Sep 17 00:00:00 2001 From: cossonleo Date: Fri, 15 Jan 2021 22:40:16 +0800 Subject: [PATCH] add focus event --- native/src/window/event.rs | 3 +++ winit/src/conversion.rs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/native/src/window/event.rs b/native/src/window/event.rs index b177141a..d649760b 100644 --- a/native/src/window/event.rs +++ b/native/src/window/event.rs @@ -29,4 +29,7 @@ pub enum Event { /// There will be a single `FilesHoveredLeft` event triggered even if /// multiple files were hovered. FilesHoveredLeft, + + /// A window was focused or not + Focused(bool), } diff --git a/winit/src/conversion.rs b/winit/src/conversion.rs index f073c474..5265b844 100644 --- a/winit/src/conversion.rs +++ b/winit/src/conversion.rs @@ -121,6 +121,9 @@ pub fn window_event( WindowEvent::Touch(touch) => { Some(Event::Touch(touch_event(*touch, scale_factor))) } + WindowEvent::Focused(focused) => { + Some(Event::Window(window::Event::Focused(*focused))) + } _ => None, } }