aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/x11
diff options
context:
space:
mode:
authortomaka <pierre.krieger1708@gmail.com>2015-05-19 10:04:41 +0200
committertomaka <pierre.krieger1708@gmail.com>2015-05-19 10:04:41 +0200
commitcbb05791918c8da218bd5b2b423394e00ffad3fc (patch)
treeb0eee58e1c9ad3988c0c3e07249f39c178025f9b /src/api/x11
parentff829f7d9d8441569d91936bef5cf3bbc646ef43 (diff)
parent966c2f2e546b899a1e3e18d16faafd3a84c1cb5c (diff)
downloadglutin-cbb05791918c8da218bd5b2b423394e00ffad3fc.tar.gz
glutin-cbb05791918c8da218bd5b2b423394e00ffad3fc.zip
Merge pull request #456 from aweinstock314/numlock-fix
Fix handling of numpad keys w.r.t. numlock (derived from fix mentione…
Diffstat (limited to 'src/api/x11')
-rw-r--r--src/api/x11/window.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/api/x11/window.rs b/src/api/x11/window.rs
index 0994638..f5f3f2f 100644
--- a/src/api/x11/window.rs
+++ b/src/api/x11/window.rs
@@ -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));