Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an example of activating XIM #204

Closed
wants to merge 4 commits into from

Conversation

Determinant
Copy link
Contributor

@Determinant Determinant commented Jun 23, 2017

This follows up and closes #195.

To make this example work, one should ensure he/she configures LC_CTYPE and XMODIFIERS correctly in environment. An example is LC_CTYPE=zh_CN.utf8 and XMODIFIERS='@im=fcitx' for fcitx-base IMEs.

Copy link
Contributor

@jwilm jwilm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but I think this raises the question though of whether XIM should just work out of the box without the user having to set locale manually. Could use more feedback on that aspect.

examples/xim.rs Outdated
fn main() {
let mut events_loop = winit::EventsLoop::new();
unsafe {
libc::setlocale(libc::LC_CTYPE, b"\0".as_ptr() as *const _);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be nice to have a comment that passing an empty string will cause the locale to be set from environment variables. Ditto for XSetLocaleModifiers.

@Determinant
Copy link
Contributor Author

User usually don't have to set LC_CTYPE manually as long as they have a utf8 locale environment. But they probably need to set XMODIFIERS or the config in the relevant application. But yes, this is just the current scenario for Chinese IME. Feedbacks are welcomed.

@Determinant
Copy link
Contributor Author

The build test failed due to missing x11-dl crate. But x11-dl is in deps, could anybody explain why? (BTW, it passed cargo test on my machine).

@quininer
Copy link

quininer commented Jun 24, 2017

Because this only works on linux (x11) and does not work in macOS with Windows.
Maybe you can add a #![cfg(target_os = "linux")]?

@quininer
Copy link

I think work out of the box is good, SDL2 also do so.

@Determinant
Copy link
Contributor Author

@quininer adding it at the beginning of the file does not help because it will create an empty file so test will fail on non-linux platform. Is there any way of preventing it from running the test? I'm new to Rust, so not familiar with such options.

@quininer
Copy link

Maybe you can create a new crate under examples/?

@tomaka
Copy link
Contributor

tomaka commented Aug 31, 2017

I don't think an example should be added for such an obscure thing, especially considering that the example is both unsafe and platform-specific.
Closing. Feel free to reopen if you disagree.

@tomaka tomaka closed this Aug 31, 2017
@jwilm
Copy link
Contributor

jwilm commented Aug 31, 2017

I don't think an example should be added for such an obscure thing

It may be obscure to you, but IME support is an often requested feature for CJK users. Suggesting that it's obscure seems disrespectful for those that rely on it.

especially considering that the example is both unsafe and platform-specific.

Those seem like reasons to open a new issue about having a safe, cross-platform API for achieving this and not a reason for closing a PR about XIM example.

@tomaka
Copy link
Contributor

tomaka commented Aug 31, 2017

That's probably just ignorance by myself, as I thought this example was supposed to demonstrate some sort of way of overwriting the default key mapping. IME is supposed to work out of the box.

@Ralith
Copy link
Contributor

Ralith commented Sep 1, 2017

It would be nice if it did, but it currently does not, and something along these lines is necessary. Unfortunately working out of the box would require calling libc::setlocale on startup, which is global and hence might have surprising interactions with unrelated code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

X11 input methods don't appear to work in example programs
5 participants