From 2de123fbd641ae604c45c554794d5b3496a7492d Mon Sep 17 00:00:00 2001 From: Francesca Frangipane Date: Thu, 29 Mar 2018 15:17:54 -0400 Subject: [PATCH] Add CHANGELOG entry and comments --- CHANGELOG.md | 1 + src/platform/linux/x11/mod.rs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f3065c646..3d8d5b5b1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - Added subclass to macos windows so they can be made resizable even with no decorations. - Dead keys now work properly on X11, no longer resulting in a panic. +- On X11, input method creation first tries to use the value from the user's `XMODIFIERS` environment variable, so application developers should no longer need to manually call `XSetLocaleModifiers`. If that fails, fallbacks are tried, which should prevent input method initialization from ever outright failing. # Version 0.11.3 (2018-03-28) diff --git a/src/platform/linux/x11/mod.rs b/src/platform/linux/x11/mod.rs index e89ea95411..f8ab509676 100644 --- a/src/platform/linux/x11/mod.rs +++ b/src/platform/linux/x11/mod.rs @@ -1012,6 +1012,10 @@ impl Window { let mut im: ffi::XIM = ptr::null_mut(); + // Setting an empty locale results in the user's XMODIFIERS environment variable being + // read, which should result in the user's configured input method (ibus, fcitx, etc.) + // being used. If that fails, we fall back to internal input methods which should + // always be available. for modifiers in &[b"\0" as &[u8], b"@im=local\0", b"@im=\0"] { if !im.is_null() { break; @@ -1027,6 +1031,10 @@ impl Window { } if im.is_null() { + // While it's possible to make IME optional and handle this more gracefully, it's + // not clear in what situations the fallbacks wouldn't work. Therefore, this panic + // is left here so that if it ever fails, someone will hopefully tell us about it, + // and we'd have a better grasp of what's necessary. panic!("XOpenIM failed"); }