aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvi Weinstock <aweinstock314@gmail.com>2015-05-15 18:30:40 -0400
committerAvi Weinstock <aweinstock314@gmail.com>2015-05-18 12:55:59 -0400
commitb6a63ad11f3b7e1c0df60881d33ffee2cdec8ce9 (patch)
tree5b08ab8f06d409daaae79041b67a8d3866bd94e6
parentff829f7d9d8441569d91936bef5cf3bbc646ef43 (diff)
downloadglutin-b6a63ad11f3b7e1c0df60881d33ffee2cdec8ce9.tar.gz
glutin-b6a63ad11f3b7e1c0df60881d33ffee2cdec8ce9.zip
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
-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..a5ccf6e 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));