Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
IME on winit
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
You can’t perform that action at this time.