Created
June 23, 2017 18:14
-
-
Save Determinant/9c87925bed3c637a661ae72da4689e54 to your computer and use it in GitHub Desktop.
IME on winit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate winit; | |
extern crate libc; | |
extern crate x11_dl; | |
fn main() { | |
let mut events_loop = winit::EventsLoop::new(); | |
unsafe { | |
libc::setlocale(libc::LC_CTYPE, b"zh_CN.utf8\0".as_ptr() as *const _); | |
let xlib = x11_dl::xlib::Xlib::open().expect("get xlib"); | |
(xlib.XSetLocaleModifiers)(b"@im=fcitx\0".as_ptr() as *const _); | |
} | |
let _window = winit::Window::new(&events_loop) | |
.unwrap(); | |
events_loop.run_forever(|event| { | |
match event { | |
winit::Event::WindowEvent { | |
event: winit::WindowEvent::ReceivedCharacter(chr), ..} => { | |
println!("{:?}", chr); | |
winit::ControlFlow::Continue | |
} | |
winit::Event::WindowEvent { event: winit::WindowEvent::Closed, .. } => { | |
winit::ControlFlow::Break | |
}, | |
_ => winit::ControlFlow::Continue, | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment