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

Wayland: Implement text_input_v3 and xkb compose #11712

Merged
merged 9 commits into from May 16, 2024

Conversation

XDeme1
Copy link
Contributor

@XDeme1 XDeme1 commented May 11, 2024

Release Notes:

  • N/A

Fixes #9207
Known Issues:

  • After launching Zed and immediately trying to change input method, the input panel will appear at Point{0, 0}
  • ime_handle_preedit should not trigger write_to_primary Move to other PR
  • Cursor is visually stuck at the end. Move to other PR
    Currently tested with KDE & fcitx5.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label May 11, 2024
@jansol
Copy link
Contributor

jansol commented May 11, 2024

Thank you so much for tackling this! I've been meaning to get into this but other responsibilities have kept me occupied.

Looks to be working on NixOS with fcitx5 in a Plasma Wayland session. In fact it works better than on macOS, since the arrow keys don't move the zed cursor around during preedit, causing the committed preedit string to end up in a completely different location than intended!

Things that immediately stand out to me:

  • no underline indicating the separately "words" of the preedit string
  • preedit cursor does not show where in the preedit string I'm currently editing (it's stuck at the end)
  • (no suggestions window, but that one is a problem on the fcitx5 side that affects all other applications too)

As a bonus, dead keys Just Work as expected with this, so:
Fixes: #9207

@XDeme1
Copy link
Contributor Author

XDeme1 commented May 11, 2024

* (no suggestions window, but that one is a problem on the fcitx5 side that affects all other applications too)

This one I think you need to configure, since you said you were on plasma
System Settings > Keyboard > Virtual Keyboard > Select fcitx5 Wayland

@apricotbucket28
Copy link
Contributor

apricotbucket28 commented May 11, 2024

no underline indicating the separately "words" of the preedit string

FYI underline rendering is broken in general. It's not related to this PR. I'm working on a fix.

As a bonus, dead keys Just Work as expected with this, so:

Weird, they don't seem to work for me. I thought they were unrelated to IME.

@XDeme1
Copy link
Contributor Author

XDeme1 commented May 11, 2024

Weird, they don't seem to work for me. I thought they were unrelated to IME.

Whats your Compositor and Input Method?

@apricotbucket28
Copy link
Contributor

I'm on Plasma 6 Wayland and I don't have any input methods installed (fcitx or anything alike), just default settings. I'm on a Spanish keyboard layout.

Copy link
Contributor

@npmania npmania left a comment

Choose a reason for hiding this comment

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

-             if let Some(range) = input_handler.marked_text_range() {
+             if let Some(range) = input_handler.selected_text_range() {

Does this affects any client behaviors? If so, I also have to modify this line.

@jansol
Copy link
Contributor

jansol commented May 11, 2024

@apricotbucket28 Hmm, interesting. If I set Virtual Keyboard to None in plasma settings dead keys stop working in zed with this PR. However they work in Firefox and alacritty. But if I set the Virtual Keyboard to Fcitx 5 they work in Zed, even when the input method is not enabled....

@XDeme1 I have it set to "Fcitx 5" -- if I set it to "Fcitx 5 Wayland Launcher" I get no input at all. I'll have to investigate the input method configuration some more I guess... and maybe nuke my ~/.config, I think there is a bunch of leftovers from Plasma 5 / X11 that may or may not be interfering with things.

@XDeme1
Copy link
Contributor Author

XDeme1 commented May 11, 2024

-             if let Some(range) = input_handler.marked_text_range() {
+             if let Some(range) = input_handler.selected_text_range() {

Does this affects any client behaviors? If so, I also have to modify this line.

Just a small one.
when using if let Some(range) = input_handler.marked_text_range() {.
If you try to change IM after focusing with the keyboard, the call to window.get_ime_area returns None, this is just to make the position of the input panel correct.

I'm on Plasma 6 Wayland and I don't have any input methods installed (fcitx or anything alike), just default settings. I'm on a Spanish keyboard layout.

@apricotbucket28 Hmm, interesting. If I set Virtual Keyboard to None in plasma settings dead keys stop working in zed with this PR. However they work in Firefox and alacritty. But if I set the Virtual Keyboard to Fcitx 5 they work in Zed, even when the input method is not enabled....

For dead keys to work without an IME enabled we need to implement https://xkbcommon.org/doc/current/group__compose.html

Edit:
@apricotbucket28 I've now implemented xkb compose now, it should probably work with your setup

@XDeme1 XDeme1 changed the title Wayland: Implement text_input_v3 Wayland: Implement text_input_v3 and xkb compose May 12, 2024
Copy link
Contributor

@apricotbucket28 apricotbucket28 left a comment

Choose a reason for hiding this comment

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

Can confirm dead keys work now! Though the text is selected, which isn't desired behaviour.
image

Edit: The compositing state isn't reset when clicking or when the window loses focus.
Fixed!

Edit 2:
We should probably commit when clicking, that's what Firefox does.

Screencast_20240512_201925.webm

crates/gpui/src/platform/linux/wayland/window.rs Outdated Show resolved Hide resolved
@npmania
Copy link
Contributor

npmania commented May 13, 2024

Since this pull request shares the window.rs code with #11657, it shares the same limitation: the preedit display in the built-in terminal doesn't work.

I can start working on that part this week, and hopefully the fix will be applicable to this PR as well.

@OtaK
Copy link

OtaK commented May 13, 2024

Gave a quick test to the PR and indeed dead keys work as expected on a Qwerty international w/ dead keys layout under Hyprland 0.39

Update: Spent a whole working day running the build. Works perfect!

@jansol
Copy link
Contributor

jansol commented May 13, 2024

Okay, I cleared out my ~/.config (and ended up reinstalling the whole system since some subdirectory there had been corrupted and attempting to fix it ended with btrfs going in a wholly non-mountable state.) Long story short, now that I started over without all the Plasma 5 and X11 dotfiles I see the candidate window as expected 🎉

@mikayla-maki
Copy link
Contributor

Really excited to see everyone building out IME support :D

@mikayla-maki mikayla-maki merged commit 5596a34 into zed-industries:main May 16, 2024
12 checks passed
@XDeme1 XDeme1 deleted the wayland-ime branch May 16, 2024 19:14
osiewicz pushed a commit to RemcoSmitsDev/zed that referenced this pull request May 18, 2024
Release Notes:

- N/A

Fixes zed-industries#9207 
Known Issues:
- [ ] ~~After launching Zed and immediately trying to change input
method, the input panel will appear at Point{0, 0}~~
- [ ] ~~`ime_handle_preedit` should not trigger `write_to_primary`~~
Move to other PR
- [ ] ~~Cursor is visually stuck at the end.~~ Move to other PR
Currently tested with KDE & fcitx5.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

linux: No US International / Dead Keys input support
6 participants