zed icon indicating copy to clipboard operation
zed copied to clipboard

Wayland: Implement text_input_v3 and xkb compose

Open XDeme1 opened this issue 9 months ago • 11 comments

Release Notes:

  • Implemented text_input_v3 and xkb compose on Wayland.

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
  • [ ] Cursor is visually stuck at the end. Currently tested with KDE & fcitx5.

XDeme1 avatar May 11 '24 20:05 XDeme1

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

jansol avatar May 11 '24 23:05 jansol

* (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

XDeme1 avatar May 11 '24 23:05 XDeme1

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.

apricotbucket28 avatar May 11 '24 23:05 apricotbucket28

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

Whats your Compositor and Input Method?

XDeme1 avatar May 11 '24 23:05 XDeme1

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 avatar May 11 '24 23:05 apricotbucket28

@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.

jansol avatar May 11 '24 23:05 jansol

-             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 avatar May 11 '24 23:05 XDeme1

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.

npmania avatar May 13 '24 03:05 npmania

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!

OtaK avatar May 13 '24 10:05 OtaK

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 :tada:

jansol avatar May 13 '24 21:05 jansol

Really excited to see everyone building out IME support :D

mikayla-maki avatar May 14 '24 18:05 mikayla-maki

Can't type Chinese in arch using fcitx.

Athrun-Judah avatar Aug 30 '24 04:08 Athrun-Judah