increase the buffer size; proper IC focus/unfocus

This commit is contained in:
Determinant 2017-06-23 14:27:48 -04:00
parent a08347eef0
commit 5e5debc48f

View file

@ -290,9 +290,10 @@ impl EventsLoop {
let written = unsafe { let written = unsafe {
use std::str; use std::str;
const BUFF_SIZE: usize = 512;
let mut windows = self.windows.lock().unwrap(); let mut windows = self.windows.lock().unwrap();
let window_data = windows.get_mut(&WindowId(xwindow)).unwrap(); let window_data = windows.get_mut(&WindowId(xwindow)).unwrap();
let mut buffer: [u8; 16] = [mem::uninitialized(); 16]; let mut buffer: [u8; BUFF_SIZE] = [mem::uninitialized(); BUFF_SIZE];
let mut keysym = 0; let mut keysym = 0;
let count = (self.display.xlib.Xutf8LookupString)(window_data.ic, xkev, let count = (self.display.xlib.Xutf8LookupString)(window_data.ic, xkev,
mem::transmute(buffer.as_mut_ptr()), mem::transmute(buffer.as_mut_ptr()),
@ -442,10 +443,16 @@ impl EventsLoop {
} }
ffi::XI_FocusIn => { ffi::XI_FocusIn => {
let xev: &ffi::XIFocusInEvent = unsafe { &*(xev.data as *const _) }; let xev: &ffi::XIFocusInEvent = unsafe { &*(xev.data as *const _) };
let mut windows = self.windows.lock().unwrap();
let window_data = windows.get_mut(&WindowId(xev.event)).unwrap();
unsafe { (self.display.xlib.XSetICFocus)(window_data.ic) };
callback(Event::WindowEvent { window_id: mkwid(xev.event), event: Focused(true) }) callback(Event::WindowEvent { window_id: mkwid(xev.event), event: Focused(true) })
} }
ffi::XI_FocusOut => { ffi::XI_FocusOut => {
let xev: &ffi::XIFocusOutEvent = unsafe { &*(xev.data as *const _) }; let xev: &ffi::XIFocusOutEvent = unsafe { &*(xev.data as *const _) };
let mut windows = self.windows.lock().unwrap();
let window_data = windows.get_mut(&WindowId(xev.event)).unwrap();
unsafe { (self.display.xlib.XUnsetICFocus)(window_data.ic) };
callback(Event::WindowEvent { window_id: mkwid(xev.event), event: Focused(false) }) callback(Event::WindowEvent { window_id: mkwid(xev.event), event: Focused(false) })
} }