Skip to content

Commit

Permalink
windows: Send ModifiersChanged(ModifiersState::empty) on KILLFOCUS
Browse files Browse the repository at this point in the history
Very similar to the changes made in [1], as focus is lost, send an event
to the window indicating that the modifiers have been released.

It's unclear to me (without a Windows device to test this on) whether
this is necessary, but it certainly ensures that unfocused windows will
have at least received this event, which is an improvement.

[1]: f79f216

Signed-off-by: Kristofer Rye <[email protected]>
  • Loading branch information
rye committed Jan 22, 2020
1 parent eb1c08d commit 88aab18
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/platform_impl/windows/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1357,7 +1357,11 @@ unsafe extern "system" fn public_window_callback<T: 'static>(
}

winuser::WM_KILLFOCUS => {
use crate::event::{ElementState::Released, WindowEvent::Focused};
use crate::event::{
ElementState::Released,
ModifiersState,
WindowEvent::{Focused, ModifiersChanged},
};
for windows_keycode in event::get_pressed_keys() {
let scancode =
winuser::MapVirtualKeyA(windows_keycode as _, winuser::MAPVK_VK_TO_VSC);
Expand All @@ -1379,6 +1383,11 @@ unsafe extern "system" fn public_window_callback<T: 'static>(
})
}

subclass_input.send_event(Event::WindowEvent {
window_id: RootWindowId(WindowId(window)),
event: ModifiersChanged(ModifiersState::empty()),
});

subclass_input.send_event(Event::WindowEvent {
window_id: RootWindowId(WindowId(window)),
event: Focused(false),
Expand Down

0 comments on commit 88aab18

Please sign in to comment.