-
Notifications
You must be signed in to change notification settings - Fork 929
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
Try XOpenIM with different locale modifiers #424
Conversation
Please let me know if you think this needs to be handled more gracefully, like returning |
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. |
@francesca64 thanks for the commit! I can't build your branch yet though:
Can you fix these first? I'll try to rebase when it'll be ok to do so. |
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. |
src/platform/linux/x11/mod.rs
Outdated
|
||
let mut im = open_im(); | ||
|
||
for modifiers in &["@im=local", "@im="] { |
There was a problem hiding this comment.
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.
src/platform/linux/x11/mod.rs
Outdated
ptr::null_mut(), | ||
); | ||
|
||
let mut im = open_im(); |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
src/platform/linux/x11/mod.rs
Outdated
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"] { |
There was a problem hiding this comment.
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.
833a43e
to
0e894fb
Compare
0e894fb
to
9b775d7
Compare
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? |
Implements the solution suggested in rust-windowing#277 (comment).
Also, for modifiers, convert from length-based UTF-8 strings to null-terminated bytestrings.
9b775d7
to
2de123f
Compare
Sorry for the delay. |
Add [defines] section to cbindgen.toml
Implements the solution suggested in #277 (comment).