aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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));