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 Apr 5, 2018
1 parent f3ab8af commit 749d2d1
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 @@ -1010,10 +1010,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 749d2d1

Please sign in to comment.