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

Try XOpenIM with different locale modifiers #424

Merged
merged 3 commits into from
Apr 5, 2018

Conversation

hcpl
Copy link
Contributor

@hcpl hcpl commented Mar 19, 2018

Implements the solution suggested in #277 (comment).

@hcpl
Copy link
Contributor Author

hcpl commented Mar 19, 2018

Please let me know if you think this needs to be handled more gracefully, like returning CreationError instead of panicking.

@francesca64
Copy link
Member

Thanks for tackling this!

Do you think you could rebase my commit for making XIM optional into your branch? That way, the issue should be completely resolved.

@hcpl
Copy link
Contributor Author

hcpl commented Mar 20, 2018

@francesca64 thanks for the commit! I can't build your branch yet though:

error[E0308]: mismatched types
   --> src/platform/linux/x11/mod.rs:453:79
    |
453 |                         let mut count = (self.display.xlib.Xutf8LookupString)(window_data.ic, xkev,
    |                                                                               ^^^^^^^^^^^^^^ expected *-ptr, found enum `std::option::Option`
    |
    = note: expected type `*mut x11_dl::xlib::_XIC`
               found type `std::option::Option<*mut x11_dl::xlib::_XIC>`
    = help: here are some functions which might fulfill your needs:
            - .unwrap()

error[E0308]: mismatched types
   --> src/platform/linux/x11/mod.rs:460:75
    |
460 |                             count = (self.display.xlib.Xutf8LookupString)(window_data.ic, xkev,
    |                                                                           ^^^^^^^^^^^^^^ expected *-ptr, found enum `std::option::Option`
    |
    = note: expected type `*mut x11_dl::xlib::_XIC`
               found type `std::option::Option<*mut x11_dl::xlib::_XIC>`
    = help: here are some functions which might fulfill your needs:
            - .unwrap()

error: aborting due to 2 previous errors

error: Could not compile `winit`.

Can you fix these first? I'll try to rebase when it'll be ok to do so.

@francesca64
Copy link
Member

Oh, whoops. I picked that commit out of my libxkbcommon branch, where that section of code doesn't exist. Sorting that out would be more involved than what I'm able to commit to right now, but fortunately, after this PR, I assume it would be rather unusual for users not to be able to get a valid input method.

I'm going to go ahead and give you a proper review now; sorry about that.

@francesca64 francesca64 self-requested a review March 21, 2018 01:24

let mut im = open_im();

for modifiers in &["@im=local", "@im="] {
Copy link
Member

Choose a reason for hiding this comment

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

These strings must be null-terminated.

ptr::null_mut(),
);

let mut im = open_im();
Copy link
Member

Choose a reason for hiding this comment

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

After doing some research, I believe this call should be preceded by an empty XSetLocaleModifiers, as is done in alacritty. Otherwise, the user's XMODIFIERS environment variable is never used. This is also done in GLFW, GTK, and so on.

Copy link
Member

@francesca64 francesca64 left a comment

Choose a reason for hiding this comment

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

I'm thinking this likely also warrants a CHANGELOG entry. Applications that currently call XSetLocaleModifiers on their own to use the value from XMODIFIERS (namely alacritty, but presumably others as well) no longer need to do that, and that change would be inobvious otherwise.

let 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();

for modifiers in &[b"\0" as &[u8], b"@im=local\0", b"@im=\0"] {
Copy link
Member

Choose a reason for hiding this comment

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

For one final concern, this should really have a comment explaining its purpose. It would be hard for future contributors to figure out the meaning of these constants and why we're looping over them.

@francesca64 francesca64 force-pushed the xopenim-different-locales branch from 833a43e to 0e894fb Compare March 29, 2018 19:23
@francesca64 francesca64 force-pushed the xopenim-different-locales branch from 0e894fb to 9b775d7 Compare April 2, 2018 23:55
@jwilm
Copy link
Contributor

jwilm commented Apr 5, 2018

Thanks @hcpl and @francesca64 for working on this feature. It looks like all of the issues in this thread have been addressed, and the latest review was an approval. Can it be merged?

hcpl and others added 3 commits April 5, 2018 12:59
Also, for modifiers, convert from length-based UTF-8 strings to
null-terminated bytestrings.
@francesca64 francesca64 force-pushed the xopenim-different-locales branch from 9b775d7 to 2de123f Compare April 5, 2018 17:01
@francesca64
Copy link
Member

Sorry for the delay.

@francesca64 francesca64 merged commit 7cd4401 into rust-windowing:master Apr 5, 2018
tmfink pushed a commit to tmfink/winit that referenced this pull request Jan 5, 2022
Add [defines] section to cbindgen.toml
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.

3 participants