feat(webkitgtk): make input method preedit configurable#1724
Conversation
Add `WebViewBuilderExtUnix::with_input_method_preedit(bool)` so apps on Linux can opt in to inline IME preedit. Defaults to `false`, preserving the behavior introduced in 0.29.0 (tauri-apps/tauri#5986) where `set_enable_preedit(false)` was added unconditionally to work around fcitx popup positioning on older webkit2gtk. On modern webkit2gtk-4.1 (>= 2.50) inline preedit works correctly with the major Linux IMEs, and disabling it forces CJK users into a detached popup that doesn't match the IME UX of native GTK, Firefox, or Chromium-based apps. Enabling this lets webkit's GtkIMContext report `compositionstart` / `compositionupdate` / `compositionend` to the DOM so editable elements render the preedit string with its underline inline at the cursor. Verified manually on Ubuntu 24.04 (X11) + webkit2gtk-4.1 2.50.x with fcitx5-hangul (Korean) and fcitx5-anthy (Japanese): inline preedit renders, candidate selection commits cleanly, and repeated send-and-clear works without dropped composition. Link: tauri-apps/tauri#11412
|
Hi maintainers, would love a review when you have time. Happy to take it in a different direction if there's a better approach. |
|
since the other pr, wry's minimum webkitgtk increased and distros removed old-ish versions from their repos so i wonder if it's fine to enable for all again? Though that indeed would require more testing, so at least wayland and ideally also older webkitgtk/gtk versions and perhaps in a tiling wm as well since it was first reported there 🤔 |
|
@FabianLars I'm leaning toward enabling it for everyone too, but I unfortunately couldn't test on Wayland. I did do my testing under i3, so that covers the tiling-WM + X11 at least. Is there anyone on Wayland who could give it a spin before we flip the default? |
|
I have wayland kde and wayland gnome to test but i never used IMEs so idk how to set that up and use it 🙃 I asked on our discord server, hopefully someone's up to the task there :) |
Package Changes Through cac61a5There are 1 changes which include wry with minor Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
Background
I ran into this while experimenting with a Linux desktop app on wry 0.53.5 against webkit2gtk-4.1 2.50.x on Ubuntu 24.04, and trying to use a plain
<input>for Korean text. With a default wry build, typing Hangul felt broken — each keystroke either dropped the in-progress composition or briefly flickered into a detached fcitx popup that didn't track the cursor.The root cause is that wry currently disables IME preedit unconditionally on Linux, so there is no way for any wry-based app to display preedit text inline.
webkitgtk::InnerWebView::set_webview_settingscallsset_enable_preedit(false)with no opt-out, which means CJK users never see what they're composing inside<input>/<textarea>/contenteditableelements — they only see characters appear after the IME commits, with no underlined preedit in between.That call landed in wry 0.29.0 to work around fcitx popup positioning on older webkit2gtk (tauri-apps/tauri#5986). On modern webkit2gtk-4.1 (≥ 2.50) the popup positioning issue is gone, but the unconditional
falseis now actively preventing the standard IME UX that GTK, Firefox, and Chromium-based apps all render correctly on the same systems.What this PR does
Adds
WebViewBuilderExtUnix::with_input_method_preedit(bool)so apps can opt in to inline preedit:The default stays false, so this is non-breaking — existing apps that rely on the popup behavior keep getting it.
When enabled, webkit's GtkIMContext reports compositionstart / compositionupdate / compositionend to the DOM, and the IME renders its preedit string (with the standard underline) inline at the cursor.
Testing
Manually tested on Ubuntu 24.04 (X11) + webkit2gtk-4.1 2.50.x with two IMEs:
I haven't tested Wayland or ibus — happy to add those data points if a maintainer wants them before merging.
Related