Skip to content

fix(wayland): CJK fallback, wheel distance and a stuck input method - #38

Open
Mirr0ch1 wants to merge 3 commits into
RoversX:mainfrom
Mirr0ch1:fix/wayland-font-wheel-ime
Open

Mirr0ch1 wants to merge 3 commits into
RoversX:mainfrom
Mirr0ch1:fix/wayland-font-wheel-ime

Conversation

@Mirr0ch1

@Mirr0ch1 Mirr0ch1 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Three wayland-input fixes, tested on Ubuntu 26.04 / GNOME 50 (Wayland, fcitx5 + rime, NVIDIA + llvmpipe both).

1. CJK fallback picked Arphic UKai/UMing

thinkterm ls-fonts --text 中文 reported AR PL UKai TW for every Han character (Latin text was JetBrains Mono, so it looked like a "Chinese font" problem rather than a font-fallback problem).

locate_fallback_for_codepoints asked FcFontList, which answers in fontconfig's cache order; on Ubuntu the Arphic faces sit ahead of Noto CJK there. Ask for the same single-codepoint charset with the generic monospace family and the user's language applied, then take what FcFontSort ranks first.

locale before after
zh_CN.UTF-8 AR PL UKai TW Noto Sans Mono CJK SC
C.UTF-8 AR PL UKai TW Noto Sans Mono CJK JP

The unsorted list is kept as the last resort for a fontconfig whose sort comes back empty. Symbols and emoji still resolve (⏵ → Noto Sans Symbols2, 🚀 → Noto Color Emoji).

2. A wheel notch moved half a row, or ten

wl_pointer.axis carries 10 units per notch (Mutter's meta-wayland-pointer.c multiplies the discrete step by factor = 10.0; the same notch is 120 in axis_value120), and a touchpad sends a fraction of one. The Wayland backend passed that value on twice: as precise_scroll_delta (which the smooth path and the chrome read as pixels: a notch moved ~10px) and truncated as VertWheel (which the stepped path reads as lines: a notch jumped 10 rows). That is why "Smooth" felt like it ate the wheel and "Stepped" suddenly felt fast.

The axis is converted to notches once: the integer part feeds VertWheel/HorzWheel, the fraction feeds precise_wheel_lines — the channel the Windows precision touchpad already uses — and precise_scroll_delta is no longer set here, so the chrome's WHEEL_NOTCH_PIXELS path applies.

A notched wheel then moves three rows a click, as GNU/Linux terminals and Windows Terminal do, which also keeps a pane in step with the chrome's own three-row notch. A device that reports pixel deltas (a trackpad) is taken as it comes.

3. Text input could stay disabled, leaving the IME in English

With fcitx5 on GNOME the input method is reached through Mutter's zwp_text_input_v3 (architecturally: Mutter → IBus → fcitx5's ibusfrontend; GNOME has no zwp_input_method_v2). The client enabled text input from wl_keyboard::Enter only, and that path silently does nothing when its keyboard → seat → text-input mapping is not in place yet; the two focus signals are also not atomic, so an enable could be skipped or cancelled. The window then stayed in the input method's inactive layout until focus left and came back — ctrl+space reached the terminal instead of the IME.

Track what was last asked of the compositor (enabled per text-input object) and act on every path: wl_keyboard Enter/Leave and zwp_text_input_v3 Enter/Leave. A key press proves the surface has focus, so re-ask there too; the next keystroke — including the rest of a ctrl+space chord — reaches the input method again.

Reproduced and verified with compositor-level key injection (org.gnome.Mutter.RemoteDesktop: CreateSession() → Session.Start() → NotifyKeyboardKeycode(29/57, …)) while watching fcitx5-remote -n: before the fix the state stayed keyboard-us, after it flips to rime. A plain letter injected the same way lands in the terminal either way, which separates "keys do not reach the app" from "the app is not attached to the IME".

Testing

  • cargo test -p window --features wayland a_wheel_notch_is_ten_axis_units_and_one_notch
  • Manual: ls-fonts before/after (table above), wheel feel in the terminal and in Settings, IME toggle via the injection above.

The CJK fallback asked FcFontList, which answers in cache order. On Ubuntu the
Arphic UKai/UMing faces come first there, so every Han cell in the terminal and
in the chrome was drawn in a brush-written kai while the Latin text was fine
(ls-fonts --text 中文 reported AR PL UKai TW).

Ask for the same single-codepoint charset with the generic monospace family and
the user's language applied, then take the first font FcFontSort puts first: on
zh_CN that is Noto Sans Mono CJK SC, on an unset locale CJK JP. The unsorted
list stays as the fallback for a fontconfig whose sort comes back empty.
@Mirr0ch1
Mirr0ch1 force-pushed the fix/wayland-font-wheel-ime branch from aa95b46 to 8474c02 Compare November 16, 2026 17:48
@Mirr0ch1 Mirr0ch1 changed the title fix(wayland): CJK fallback, wheel distance and a stuck input method; add Wheel rows fix(wayland): CJK fallback, wheel distance and a stuck input method Nov 16, 2026
…a notch

A wheel notch arrives as 10 units of wl_pointer.axis (Mutter multiplies the
discrete step by 10 in meta-wayland-pointer.c; the same notch is 120 in
axis_value120), and a touchpad sends a fraction of one. The client passed that
value on as a pixel delta to the smooth path and truncated it into a line count
for the stepped one, so a notch moved roughly half a row in smooth mode and ten
rows in stepped mode, and the settings and sidebars crawled: the chrome read
the same value as pixels, ten a notch instead of its thirty-four.

Convert to notches once: the integer part goes to VertWheel/HorzWheel, the
fraction to precise_wheel_lines, the channel the Windows precision touchpad
already uses. A notched wheel then moves three rows a click -- what GNU/Linux
terminals and Windows Terminal do, and what keeps the pane in step with the
chrome's own three-row notch. A device that reports pixel deltas is taken as it
comes: it is already at the distance the finger travelled.
Text input was enabled from wl_keyboard::Enter and disabled from the matching
Leave, and nothing else. The mapping Enter consults (keyboard -> seat -> text
input) can be incomplete when a surface is focused, and the keyboard and
text-input focus events are not atomic, so an enable could be skipped or
cancelled. The window then sat in the input method's inactive (English) layout
until focus left and came back: with fcitx5 on GNOME, ctrl+space reached the
terminal instead of the input method and Chinese could not be typed at all.

Track what was last asked of the compositor and act on every path
(wl_keyboard Enter/Leave and zwp_text_input_v3 Enter/Leave). A key press proves
the surface has focus, so re-ask there as well: the next keystroke, including
the rest of a ctrl+space chord, reaches the input method again.
@Mirr0ch1
Mirr0ch1 force-pushed the fix/wayland-font-wheel-ime branch from 8474c02 to 55c2660 Compare November 16, 2026 17:52

This branch has not been deployed

No deployments
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