On Windows and MacOS, add Window::has_focus
This commit is contained in:
parent
067535eb38
commit
a88d2e079d
17 changed files with 102 additions and 2 deletions
|
|
@ -1,5 +1,7 @@
|
|||
//! Handling of various keyboard events.
|
||||
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
use sctk::reexports::client::protocol::wl_keyboard::KeyState;
|
||||
|
||||
use sctk::seat::keyboard::Event as KeyboardEvent;
|
||||
|
|
@ -22,6 +24,9 @@ pub(super) fn handle_keyboard(
|
|||
KeyboardEvent::Enter { surface, .. } => {
|
||||
let window_id = wayland::make_wid(&surface);
|
||||
|
||||
let window_handle = winit_state.window_map.get_mut(&window_id).unwrap();
|
||||
window_handle.has_focus.store(true, Ordering::Relaxed);
|
||||
|
||||
// Window gained focus.
|
||||
event_sink.push_window_event(WindowEvent::Focused(true), window_id);
|
||||
|
||||
|
|
@ -44,6 +49,9 @@ pub(super) fn handle_keyboard(
|
|||
);
|
||||
}
|
||||
|
||||
let window_handle = winit_state.window_map.get_mut(&window_id).unwrap();
|
||||
window_handle.has_focus.store(false, Ordering::Relaxed);
|
||||
|
||||
// Window lost focus.
|
||||
event_sink.push_window_event(WindowEvent::Focused(false), window_id);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue