mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-25 06:41:31 +11:00
Fix handling of numpad keys w.r.t. numlock (derived from fix mentioned at http://www.kaffe.org/pipermail/kaffe/2000-April/175201.html).
Conflicts: src/api/x11/window.rs
This commit is contained in:
parent
ff829f7d9d
commit
b6a63ad11f
|
@ -177,6 +177,8 @@ impl<'a> Iterator for PollEventsIterator<'a> {
|
|||
|
||||
let state = if xev.get_type() == ffi::KeyPress { Pressed } else { Released };
|
||||
|
||||
let mut kp_keysym = 0;
|
||||
|
||||
let written = unsafe {
|
||||
use std::str;
|
||||
|
||||
|
@ -184,7 +186,7 @@ impl<'a> Iterator for PollEventsIterator<'a> {
|
|||
let raw_ev: *mut ffi::XKeyEvent = event;
|
||||
let count = (self.window.x.display.xlib.Xutf8LookupString)(self.window.x.ic, mem::transmute(raw_ev),
|
||||
mem::transmute(buffer.as_mut_ptr()),
|
||||
buffer.len() as libc::c_int, ptr::null_mut(), ptr::null_mut());
|
||||
buffer.len() as libc::c_int, &mut kp_keysym, ptr::null_mut());
|
||||
|
||||
str::from_utf8(&buffer[..count as usize]).unwrap_or("").to_string()
|
||||
};
|
||||
|
@ -196,10 +198,14 @@ impl<'a> Iterator for PollEventsIterator<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
let keysym = unsafe {
|
||||
let mut keysym = unsafe {
|
||||
(self.window.x.display.xlib.XKeycodeToKeysym)(self.window.x.display.display, event.keycode as ffi::KeyCode, 0)
|
||||
};
|
||||
|
||||
if (ffi::XK_KP_Space as u64 <= keysym) || (keysym <= ffi::XK_KP_9 as u64) {
|
||||
keysym = kp_keysym
|
||||
};
|
||||
|
||||
let vkey = events::keycode_to_element(keysym as libc::c_uint);
|
||||
|
||||
return Some(KeyboardInput(state, event.keycode as u8, vkey));
|
||||
|
|
Loading…
Reference in a new issue