Skip to content

Commit

Permalink
Use empty XSetLocaleModifiers beforehand
Browse files Browse the repository at this point in the history
Also, for modifiers, convert from length-based UTF-8 strings to
null-terminated bytestrings.
  • Loading branch information
hcpl authored and francesca64 committed Mar 29, 2018
1 parent 2356a3e commit 30d04c7
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/platform/linux/x11/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1010,22 +1010,20 @@ impl Window {
let im = unsafe {
let _lock = GLOBAL_XOPENIM_LOCK.lock().unwrap();

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: ffi::XIM = ptr::null_mut();

let mut im = open_im();

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

(x_events_loop.display.xlib.XSetLocaleModifiers)(modifiers.as_ptr() as *const i8);
im = open_im();
im = (x_events_loop.display.xlib.XOpenIM)(
x_events_loop.display.display,
ptr::null_mut(),
ptr::null_mut(),
ptr::null_mut(),
);
}

if im.is_null() {
Expand Down

0 comments on commit 30d04c7

Please sign in to comment.