Skip to content

Commit

Permalink
Try XOpenIM with different locale modifiers
Browse files Browse the repository at this point in the history
Implements the solution suggested in
rust-windowing#277 (comment).
  • Loading branch information
hcpl authored and francesca64 committed Mar 29, 2018
1 parent 02e287a commit f508dab
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/platform/linux/x11/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1020,10 +1020,28 @@ impl Window {
let im = unsafe {
let _lock = GLOBAL_XOPENIM_LOCK.lock().unwrap();

let im = (x_events_loop.display.xlib.XOpenIM)(x_events_loop.display.display, ptr::null_mut(), ptr::null_mut(), ptr::null_mut());
let open_im = || (x_events_loop.display.xlib.XOpenIM)(
x_events_loop.display.display,
ptr::null_mut(),
ptr::null_mut(),
ptr::null_mut(),
);

let mut im = open_im();

for modifiers in &["@im=local", "@im="] {
if !im.is_null() {
break;
}

(x_events_loop.display.xlib.XSetLocaleModifiers)(modifiers.as_ptr() as *const i8);
im = open_im();
}

if im.is_null() {
panic!("XOpenIM failed");
}

im
};

Expand Down

0 comments on commit f508dab

Please sign in to comment.