-
-
Notifications
You must be signed in to change notification settings - Fork 797
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
Support input method editors for X11 #250
Comments
Same issue here, I use fcitx but I can't switch my IME with |
Can you tell me how to configure the UIM? I'd like to try to reproduce this, but I'm not sure how to set it up. |
Thanks for the info! I've done a bit of reading and it appears that |
I'm classifying this as an enhancement as we don't currently have support for IME on linux |
I looked into this a bit more; there are still things to figure out before any meaningful support can be added:
|
From my experience, xim is too limiting and I never used it. gtkim has advanced features such as embedding the candidate text and is the main backend I have used. IBus is another solid IME framework on Linux, which lives in the gtk-ish eco-system. In the past I wrote an IME in IBus using Vala. I would suggest targeting gtkim if possible. |
I don't know if wezterm can use gtkim without effectively being rewritten as a separate GTK frontend, which is not something that I want to do. |
I don't know much about X, and wezterm and alacritty probably have different underlying goals but if it helps you get an inspiration- here's the PR in alacritty that added this support- https://github.com/alacritty/alacritty/pull/691/files |
Alacritty uses winit, which just directly calls |
@H-M-H do you want to try making a PR for wezterm that does that? |
Turns out the methods Have a look at https://github.com/H-M-H/wezterm/tree/ime for the current progress. |
@H-M-H thanks for diving in! I'm excited to look through https://github.com/H-M-H/xcb-imdkit-rs and the integration in wezterm when I done with work later today! |
Alright, I think I am mostly happy now with https://github.com/H-M-H/xcb-imdkit-rs and will probably publish it on crates.io soonish. |
I'll check it out! Re: IME positioning, here's the equivalent thing in the Windows version: https://github.com/wez/wezterm/blob/main/window/src/os/windows/window.rs#L506-L509 which is called by: https://github.com/wez/wezterm/blob/main/window/src/os/windows/window.rs#L657-L662 so you'd want to do something similar by inserting a https://github.com/wez/wezterm/blob/main/window/src/os/x11/window.rs#L993 |
For injecting the composed text, the Windows version does this: https://github.com/wez/wezterm/blob/main/window/src/os/windows/window.rs#L1227-L1237 |
Thanks for the hints! I got it working now. The IME is correctly positioned now and works fine with multiple windows. I changed the code for text injection to mirror what is done on Windows. On thing that is bugging me is that the IME is not closed once wezterm exits, this may be a shortcoming of xcb-imdkit though fcitx/xcb-imdkit#10. Apart from that all that needs to be done is some more testing I guess. |
I think one final functionality question is: would a user ever want to disable using the IME? On macOS we have a Respecting this option should be as simple as: if config::configuration().use_ime && self.ime.borrow_mut().process_event(event) { |
I got this just now when trying to compile your wezterm branch:
you'll need to update the |
If there is an option to toggle IME support it's probably confusing if it does not work, so I changed the line as you proposed. I hopefully fixed |
I gave it a quick try, and it looks good! (caveat: I have no idea what I've typed it, other than it rendered as Chinese glyphs!) There's something a bit "floaty" or laggy about keyboard input with the IME changes included; it can sometimes take several seconds for the input to show up even when the IME candidate window is not open. I feel like there might be something missing in the integration! |
I think I figured what's causing this, apparently updating the IME position is pretty expensive, I will have to think about a way around this. |
Many thanks to @H-M-H; this is now available in the nightly builds if you set |
Tested on wezterm compiled from source with rust 1.54.0, sha 40c8fb1 Input method: fcitx4 wezterm config:
IM popup instead of in-placeBottom window: terminator 2.1.0 wezterm does not change the letters in-place, it uses a popup. I /think/ this might be the XIM default, and terminator provides the nice in-place editing because it's a GTK application, meaning this would not be improvable. Default fontAfter removing the "Noto Sans CJK KR" line from the config, the default Korean font looks horrible (imagine your font being cursive). No idea if that fallback font is specific to my system though. Adding a line to the font setup documentation to the ime documention seems like a good idea. |
Actually this is possible to implement. The problem is that interfacing with wezterms internals gets more complicated in that case. The XIM library provides callbacks on changes of the IME text and these would need to be handled. About the fonts: I have not touched any font related code here, so this should perhaps be a separate issue. |
I don't think it's fair to say "nice in-place editing" without qualification. Of the two language sets I'm familiar with (Indic languages and Hanji/Kanji languages, both 1B+ speakers), the former would work better with in-place but the latter with popup. I'd much prefer popup if I have only one option |
Also! Thank you guys! This was a much needed feature :-) |
Re: fonts, when a glyph can't be resolved from the fonts listed directly in your config, wezterm:
That search process can take a visible number of milliseconds to complete the first time around, which is why we don't want to do that in the render pass itself (it would lock up the UI while it was resolving), and is why you might see a flash with a placeholder glyph initially. In terms of the quality of the matching: I don't know if there's a better way to ask fontconfig for a better looking font for your script than we're using. You may want to experiment with |
I also found the font loading to be very slow, I am experimenting with improvements here: https://github.com/H-M-H/wezterm/tree/font_perf |
I'm definitely open to seeing this as an option for the IME. It'll be a little bit indirect to hook up because our That sort of channel from the IME -> renderer would be partially aligned with #686 and #688 |
You are correct, I should not have assumed what works best for me. Is there any way for your input method editor to specify which you prefer? Or is it always up to the program you're currently using?
That sounds like it shouldn't swallow any input though, but that's what happened to me in the gif. |
The way it works is that you can ask the installed IME for text editing events and typically the IME will only show a completion list (if applicable) in this case and it is up to the program to display the currently typed text. If you don't request those events the IME will handle text editing completely and has to as the program can not. So in conclusion while it may be possible for the IME to do it's own thing, it is bound by what the program can handle and I don't think you can configure this. |
@H-M-H 6404099 broke building for me
|
Please describe your build environment, xcb-imdkit-rs uses a git submodule for the wrapped C library. For some reason this module hasn't been initialized and thus my build script tried to run git manually but that failed as well? Are you perhaps doing some trickery with building across different filesystems? If so try setting |
nixpkgs, I am also the upstream maintainer of wezterm there.
That is not going to work if it if downloaded at runtime. This is also a big no no for most distros. You can't just download random things during build time. Trying to fix it at #1064. |
I am also not 100% happy with it, but what are the alternatives? On most distributions the system xcb-imdkit C library is just too old and copying said library into my project seems disingenuous as well. Also thanks for maintaining the package! |
Can rust download a release tarball that includes the submodule? I think that would work around this or wezterm needs to add the submodule to the third-party directory and download it while downloading the source. Maybe we can deactivate the feature on systems that do not have a new enough library? |
Plenty of crates use a git submodule for this sort of thing. I'm not really a fan of using the system library as I think that will be less likely to be available and will pose more of a build headache. Instead, I think that having the crate use a submodule is fine, but then: publish that crate to crates.io with the submodule files included. Then we can change wezterm to use the published crate rather than building from the git repo. |
Sounds good, I found and fixed some more minor bugs and want to test things before publishing to crates.io. These include:
|
Alright, so far it's working fine, I have now published the crate at: https://crates.io/crates/xcb-imdkit |
|
@H-M-H: I pulled in your font_perf changes; thanks! |
I'm closing this issue, as the heart of IME for X11 is done, and this issue is pretty long. Please open separate issue(s) if there are things that need further attention! |
Did anyone get this working with ibus on linux? Maybe we can add fcitx and ibus in the documentation as keywords to find this 🤔 Because this sounds like it only addresses MacOs: |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Describe the bug
Hello Wez,
I use UIM for switching the input method to Korean. I have bound it to
ctrl + alt + space
.Works fine in my current terminal emulator (terminator), but not in wezterm.
I only get a log message saying
I have no idea whether this is an issue with UIM or wezterm, but I found this and thought it might be related:
FIXME in shift-space now emits space maybe?
My guess (without looking at any code and / understanding how wezterm or UIM work) would be that wezterm swallows the key presses.
Environment (please complete the following information):
To Reproduce
Steps to reproduce the behavior.
Please include as much information as possible that can help to reproduce and
understand the issue; some pointers and suggestions are included here in this
template. You are empowered to include more or less information than is asked
for here!
Configuration
Happens without a config file. Also happens with
use_ime = true
, but from the text that appears to only affect MacOS anywat.Expected behavior
When I press
ctrl + alt + space
, UIM receives that key combination so it can switch my IM.Screenshots
Session Recording
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: