docs: Wayland

One popup per session, so the frontend is picked at startup: a compositor
with zwp_input_method_v2 gets that frontend and neither XIM nor the X11
popup is started.  The answer for a user is one sentence -- on Wayland set
none of the module variables -- and the two exceptions the plan asked to
check turned out this way: GTK 4 binds text-input-v3 by itself, with
GTK_IM_MODULE unset (4.22 under sway 1.12, typed and composed), and
Chromium is beyond help either way, since it asks for text-input-v1 and
wlroots implements only v3.

The plan is deleted, as it said to be once the README described what
landed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-17 19:43:38 +09:00
parent 5664a008de
commit 2e1e0b9645
2 changed files with 35 additions and 313 deletions

View File

@@ -1,8 +1,10 @@
# strans
strans is a small, single-user input method for Korean, Japanese, English,
emoji, and symbols. It provides one engine for IBus (which GTK 4 and
Qt use), XIM, and GTK 3. Vietnamese Telex is also available as a
emoji, and symbols. It provides one engine for Wayland compositors that
speak `zwp_input_method_v2` — the wlroots and smithay families, so sway,
river, labwc, Wayfire, dwl, niri and COSMIC — and for IBus (which GTK 4
and Qt use), XIM, and GTK 3. Vietnamese Telex is also available as a
compatibility mode.
## Input modes
@@ -72,6 +74,7 @@ clicking elsewhere commits what is pending.
| Frontend | Preedit | Candidates |
| --- | --- | --- |
| Wayland input method | inline in the client | strans popup |
| GTK 3 and IBus | inline in the client | strans popup |
| XIM PreeditCallbacks | inline through XIM callbacks | strans popup |
| XIM PreeditPosition | strans popup | strans popup |
@@ -90,11 +93,13 @@ style, and above the line when there is no room below; otherwise the popup
sits under the focus window, or under the client window when no focus
window is set.
The popup is an X11 window sized by `GDK_SCALE` on HiDPI displays, XIM is
X11-only, and GTK popup placement converts the GTK caret to X11 root
coordinates. There is no native Wayland popup surface or Wayland caret
positioning. GTK and IBus clients can still use inline preedit where their
display environment supports it.
On a compositor with `zwp_input_method_v2` the popup is a Wayland surface
that the compositor itself puts at the text cursor, flipping it above the
line when there is no room below; a client that reports no cursor location
gets it under its window instead. Everywhere else the popup is an X11 window,
placed from the XIM spot or from the GTK caret converted to root
coordinates, and XIM is X11-only. Either way `GDK_SCALE` sizes it for
HiDPI displays.
## Build and test
@@ -109,7 +114,7 @@ make docker-build
Build output:
```text
strans daemon with IBus and XIM frontends
strans daemon with Wayland, IBus, and XIM frontends
gtk/im-strans.so GTK 3 frontend module
```
@@ -133,6 +138,8 @@ development files for:
- Plan 9 port (`9c`, `9l`, `libthread`, and `libbio`);
- D-Bus development files;
- XCB, XCB RandR, XCB XKB, xcb-util, xcb-imdkit, xkbcommon, and xkbcommon-x11;
- the Wayland client library and `wayland-scanner`, which writes the
input-method and virtual-keyboard bindings from the XML in `proto/`;
- Pango, PangoCairo, Cairo, and Fontconfig;
- GTK 3, plus libibus and Xlib for the live clients;
- Xvfb for the X11 live tests;
@@ -158,8 +165,9 @@ build-tree daemon in the background, and returns to the shell. It requires
`pkill` from procps. Startup and frontend failures remain visible on the
caller's standard error. A service supervisor should instead run
`./strans map` directly in the foreground, with the session's
`XDG_RUNTIME_DIR` and `DISPLAY`: the GTK module finds the daemon at
`$XDG_RUNTIME_DIR/strans.sock` (else `/tmp/strans.UID`), and IBus clients
`XDG_RUNTIME_DIR` and its `WAYLAND_DISPLAY` or `DISPLAY`: the GTK module
finds the daemon at `$XDG_RUNTIME_DIR/strans.sock` (else
`/tmp/strans.UID`), and IBus clients
through the address file libibus expects under `~/.config/ibus/bus/`,
which strans writes as `ibus-daemon` would, named after `WAYLAND_DISPLAY`
when there is one and `DISPLAY` otherwise.
@@ -169,6 +177,20 @@ opens `hira.map`, `kata.map`, `telex.map`, `kanji.dict`, `emoji.dict`, and
`hanja.dict` from `DIR` at runtime; `run.sh` passes the tracked `map/`
directory. Only the GTK subdirectory has install and uninstall targets.
strans shows one popup per session, so it picks its frontend at startup: a
session whose compositor offers `zwp_input_method_v2` gets that frontend,
and neither XIM nor the X11 popup is started; every other session gets XIM
as before. The IBus endpoint and the GTK 3 module are served in both.
On Wayland, then, set none of the variables below. GTK, Qt and Firefox
speak text-input-v3 themselves and need nothing — GTK 4 binds it without
`GTK_IM_MODULE`, checked with 4.22 under sway 1.12 — and `GTK_IM_MODULE`
is what pushes them off the path that works. A client that reaches strans
over IBus or the GTK 3 module while the Wayland frontend runs still
composes inline, but shows no candidate list, because the popup belongs to
that frontend. Chromium is helped by neither: it still asks for
`text-input-v1`, which wlroots does not implement at all.
Configure clients as needed:
```sh
@@ -201,8 +223,9 @@ doas make -C gtk uninstall
strans provides its own IBus endpoint; `ibus-daemon` and fcitx are not
required. IBus clients that process keys synchronously — GTK 4, or GTK 3
with `IBUS_ENABLE_SYNC_MODE=1` — get their commits and preedits through
`PostProcessKeyEvent`, in order with the key. Without `DISPLAY`, the daemon and IBus frontend still work, but XIM
is not started and the popup is disabled.
`PostProcessKeyEvent`, in order with the key. With neither
`WAYLAND_DISPLAY` nor `DISPLAY`, the daemon, its IBus endpoint and its
socket still work, but no frontend draws a popup.
## Dictionary data