Skip to content

feat(webkitgtk): make input method preedit configurable#1724

Open
eldenpark wants to merge 1 commit into
tauri-apps:devfrom
eldenpark:feat/configurable-input-method-preedit
Open

feat(webkitgtk): make input method preedit configurable#1724
eldenpark wants to merge 1 commit into
tauri-apps:devfrom
eldenpark:feat/configurable-input-method-preedit

Conversation

@eldenpark
Copy link
Copy Markdown

@eldenpark eldenpark commented May 6, 2026

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_settings calls set_enable_preedit(false) with no opt-out, which means CJK users never see what they're composing inside <input> / <textarea> / contenteditable elements — 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 false is 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:

let builder = WebViewBuilder::new()
    .with_input_method_preedit(true);

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:

  • fcitx5-hangul (Korean): typing 안녕 shows inline preedit underlined at the cursor; commit lands cleanly; repeated send-and-clear works in a loop.
  • fcitx5-anthy (Japanese): typing romaji like nihongo shows にほんご inline; Space opens the candidate window; Enter commits.

I haven't tested Wayland or ibus — happy to add those data points if a maintainer wants them before merging.

Related

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
@eldenpark eldenpark requested a review from a team as a code owner May 6, 2026 04:13
@eldenpark
Copy link
Copy Markdown
Author

Hi maintainers, would love a review when you have time. Happy to take it in a different direction if there's a better approach.

@FabianLars
Copy link
Copy Markdown
Member

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 🤔

@eldenpark
Copy link
Copy Markdown
Author

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

@FabianLars
Copy link
Copy Markdown
Member

FabianLars commented May 12, 2026

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

@github-actions
Copy link
Copy Markdown
Contributor

Package Changes Through cac61a5

There are 1 changes which include wry with minor

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
wry 0.55.1 0.56.0

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants