mirror of
https://github.com/rust-windowing/winit.git
synced 2026-08-30 13:20:06 -04:00
Add keyboard modifiers to input event
Making applications track modifier keys results in unnecessary work for
consumers, it's error prone, and it turns out to have unavoidable bugs.
For example, alt-tabbing with x11 results in the alt modifier state
getting stuck.
To resolve these problems, this patch adds a Mods value to the keyboard
input event.
Based on this patch: d287fa96e3
This commit is contained in:
@@ -8,6 +8,7 @@ use std::os::windows::ffi::OsStringExt;
|
||||
|
||||
use CursorState;
|
||||
use WindowEvent as Event;
|
||||
use events::ModifersState;
|
||||
use super::event;
|
||||
use super::WindowState;
|
||||
|
||||
@@ -200,7 +201,7 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
|
||||
user32::DefWindowProcW(window, msg, wparam, lparam)
|
||||
} else {
|
||||
let (scancode, vkey) = event::vkeycode_to_element(wparam, lparam);
|
||||
send_event(window, KeyboardInput(Pressed, scancode, vkey));
|
||||
send_event(window, KeyboardInput(Pressed, scancode, vkey, ModifersState::default()));
|
||||
0
|
||||
}
|
||||
},
|
||||
@@ -209,7 +210,7 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
|
||||
use events::WindowEvent::KeyboardInput;
|
||||
use events::ElementState::Released;
|
||||
let (scancode, vkey) = event::vkeycode_to_element(wparam, lparam);
|
||||
send_event(window, KeyboardInput(Released, scancode, vkey));
|
||||
send_event(window, KeyboardInput(Released, scancode, vkey, ModifersState::default()));
|
||||
0
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user