Merge pull request #701 from cossonfork/focus_event

This commit is contained in:
Héctor Ramón Jiménez 2021-01-15 18:23:50 +01:00
commit 984583b0cc
2 changed files with 12 additions and 1 deletions

View File

@ -3,7 +3,7 @@ use std::path::PathBuf;
/// A window-related event. /// A window-related event.
#[derive(PartialEq, Clone, Debug)] #[derive(PartialEq, Clone, Debug)]
pub enum Event { pub enum Event {
/// A window was resized /// A window was resized.
Resized { Resized {
/// The new width of the window (in units) /// The new width of the window (in units)
width: u32, width: u32,
@ -12,6 +12,12 @@ pub enum Event {
height: u32, height: u32,
}, },
/// A window was focused.
Focused,
/// A window was unfocused.
Unfocused,
/// A file is being hovered over the window. /// A file is being hovered over the window.
/// ///
/// When the user hovers multiple files at once, this event will be emitted /// When the user hovers multiple files at once, this event will be emitted

View File

@ -109,6 +109,11 @@ pub fn window_event(
WindowEvent::ModifiersChanged(new_modifiers) => Some(Event::Keyboard( WindowEvent::ModifiersChanged(new_modifiers) => Some(Event::Keyboard(
keyboard::Event::ModifiersChanged(self::modifiers(*new_modifiers)), keyboard::Event::ModifiersChanged(self::modifiers(*new_modifiers)),
)), )),
WindowEvent::Focused(focused) => Some(Event::Window(if *focused {
window::Event::Focused
} else {
window::Event::Unfocused
})),
WindowEvent::HoveredFile(path) => { WindowEvent::HoveredFile(path) => {
Some(Event::Window(window::Event::FileHovered(path.clone()))) Some(Event::Window(window::Event::FileHovered(path.clone())))
} }