Skip to content

feat(ibus): add kime-ibus IBus engine frontend (#422, #748)#751

Open
Riey wants to merge 1 commit into
developfrom
ibus-frontend
Open

feat(ibus): add kime-ibus IBus engine frontend (#422, #748)#751
Riey wants to merge 1 commit into
developfrom
ibus-frontend

Conversation

@Riey

@Riey Riey commented Jun 27, 2026

Copy link
Copy Markdown
Owner

Summary

Add a new kime-ibus frontend: an IBus engine that forwards input to the kime engine. This is the path for environments where the Wayland input-method protocols are unavailable — notably GNOME Wayland, whose Mutter compositor does not implement zwp_input_method_v2, so kime-wayland cannot work there.

Addresses #422 (IBus server interface) and #748 (Ubuntu 26.04 / GNOME Wayland).

What it does

  • Registers as IBus engine kime (component org.freedesktop.IBus.Kime), launched on demand by ibus-daemon via kime-ibus --ibus.
  • One InputEngine per input context; ProcessKeyEventpress_key_code → emits CommitText / UpdatePreeditText / HidePreeditText, mirroring the xim/wayland contract exactly (modifier/keycode/CONSUMED mapping, commit-then-preedit ordering, LANGUAGE_CHANGED/NOT_READY handling).
  • Pure-Rust D-Bus via zbus 5 (tokio), no glib/libibus C deps.

Scope (MVP)

Parity with xim/wayland: preedit + commit + key/focus/reset. No hanja/candidate UI — develop's engine exposes no candidate-enumeration API; an IBus lookup table is a clean follow-up once that API exists.

Build

New meson ibus feature (auto). Installs the kime-ibus binary and res/ibus/component/kime.xml to share/ibus/component/.

meson setup build -Dibus=enabled && ninja -C build && sudo ninja -C build install
ibus write-cache && ibus restart   # then add “Kime” (Korean) in Settings, or: ibus engine kime

Verification

  • cargo build -p kime-ibus → clean, 0 warnings.
  • cargo test -p kime-ibus → 3/3 (IBusText/IBusAttrList (sa{sv}sv) signature + variant round-trip — the riskiest marshalling).
  • Binary runs (--help/--version).

Needs live testing (maintainer)

Headless CI can't exercise a real ibus-daemon, so the following want a live GNOME-Wayland/IBus session: end-to-end IBusText demarshal + visible preedit/commit; daemon activation via the component XML; real keycode/modifier behavior under the GNOME IBus path; socket-file address fallback.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FT8zVKCvTRgZiMLPpNw8Hs

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 782ca1e2fb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +190 to +194
// IBus `keycode` is the X11 hardware keycode (evdev + 8), which is what
// kime's keycode table expects as the hardware code.
let ret = self
.engine
.press_key_code(keycode as u16, mods, numlock, &self.config);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add the missing IBus keycode offset

IBus clients pass evdev keycodes to engines (the GTK path subtracts 8 before ProcessKeyEvent: https://github.com/ibus/ibus/blob/main/client/gtk2/ibusimcontext.c#L3085-L3090), but KeyCode::from_hardware_code uses X11 keycodes (A=38, U=30). Passing keycode straight through makes keys decode eight positions early under the real IBus path, so Hangul composition/hotkeys are wrong; add the +8 offset before press_key_code.

Useful? React with 👍 / 👎.

Comment on lines +78 to +79
"UpdatePreeditText",
&(v, cursor_pos, visible),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Emit the engine preedit signal with its mode

IBus's engine interface defines UpdatePreeditText with a fourth mode argument (vubu, see the engine introspection in https://github.com/ibus/ibus/blob/main/src/ibusengine.c), while the three-argument form is the daemon-to-client input-context signal. Emitting only (v, cursor_pos, visible) from the engine makes ibus-daemon fail to decode/drop preedit updates, so users will not see active composition; include a mode such as IBUS_ENGINE_PREEDIT_CLEAR.

Useful? React with 👍 / 👎.

<component>
<name>org.freedesktop.IBus.Kime</name>
<description>Kime Korean input method</description>
<exec>/usr/bin/kime-ibus --ibus</exec>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Use the configured install prefix in the IBus exec

With a normal Meson source install, kime-ibus is installed under ${MESON_INSTALL_PREFIX}/bin (default /usr/local/bin), but this XML always tells ibus-daemon to launch /usr/bin/kime-ibus. Anyone installing with the default prefix gets a selectable component that cannot be activated because the executable path does not exist; generate/substitute this value or use a command that resolves to the installed binary.

Useful? React with 👍 / 👎.

@Riey Riey force-pushed the ibus-frontend branch 2 times, most recently from 7a5cea3 to 69462c0 Compare June 27, 2026 03:15
Add a new IBus engine that forwards key events to the kime input engine,
providing the supported input-method path on GNOME Wayland where Mutter
lacks zwp_input_method_v2 (#422, #748).

Feature parity with xim/wayland: preedit + commit + key/focus/reset. No
hanja/candidate UI (engine on develop has no candidate enumeration API).

IBus is a D-Bus protocol, implemented directly with zbus (pure Rust),
matching kime's hand-rolled-protocol philosophy:
- connection: discover the bus via IBUS_ADDRESS (or the per-session socket
  file), request org.freedesktop.IBus.Kime, serve the factory.
- factory: org.freedesktop.IBus.Factory.CreateEngine spawns a per-context
  Engine object at a unique path.
- engine: org.freedesktop.IBus.Engine (ProcessKeyEvent, FocusIn/Out[Id],
  Enable/Disable/Reset/Destroy, plus no-op stubs); emits CommitText /
  UpdatePreeditText / HidePreeditText.
- ibus_types: IBusText/IBusAttrList marshalling ((sa{sv}sv)/(sa{sv}av)),
  verified by round-trip tests.

Key/modifier/CONSUMED mapping mirrors xim/wayland: IBus keycode is the X11
hardware code passed to InputEngine::press_key_code; modifier bits mapped to
ModifierState; ProcessKeyEvent returns true iff InputResult::CONSUMED.

Build wiring (meson): new `ibus` feature option, cargo -p kime-ibus, binary
install rule, and the IBus component XML to share/ibus/component.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FT8zVKCvTRgZiMLPpNw8Hs
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.

1 participant