Skip to content

Make the menu search line a real text input - #12338

Closed
linyiru wants to merge 1 commit into
omacom:quattrofrom
linyiru:menu-ime-input
Closed

linyiru wants to merge 1 commit into
omacom:quattrofrom
linyiru:menu-ime-input

Conversation

@linyiru

@linyiru linyiru commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

The menu's search line cannot be typed into with a CJK input method. Composing Chinese, Japanese or Korean through fcitx5 either drops the text or leaves the raw Latin keysyms behind: typing the bopomofo for 你好 fills the filter with su3cl3, so the menu cannot be searched in those languages. Both SUPER + SPACE and SUPER + ALT + SPACE are affected — they are the same Menu.qml.

Why

The filter was a Text element fed by keyCatcher's Keys.onPressed, which appended event.text one character at a time. Qt delivers input-method events — the preedit an input method shows while composing, and the text it commits — only to an item that answers inputMethodQuery, and in QML that means TextInput or TextEdit. An Item with a key handler is invisible to that protocol.

Layer shell is not the problem: Hyprland grants zwp_text_input_v3 to layer surfaces, and a plain TextInput in a PanelWindow with keyboardFocus: Exclusive — byte-for-byte the menu's own window configuration — composes CJK correctly.

How

Focus moves to a TextInput that forwards every key to keyCatcher first (Keys.forwardTo with Keys.priority: Keys.BeforeItem), so the menu keeps all of its own bindings and only the keys the handler leaves unaccepted — printable characters, paste, IME commits — reach the search line. The hand-rolled character accumulator is gone. Util.editsFilter stays where it is, so Backspace / Ctrl+Backspace / Ctrl+U are still handled once, by the menu.

The modal branch now accepts unconditionally, because an unhandled key would otherwise fall through and type into the search line behind the uninstall confirmation.

The line stays an append-only buffer with no caret and no selection, so the menu looks and behaves exactly as before for Latin input. cursorDelegate: Item {} is what actually holds the caret hidden — a constant cursorVisible: false does not, because Qt turns cursorVisible back on by itself on every focus change.

Scope

This is about typing into the menu: the input experience for CJK users, and nothing more. It does not install, configure or detect an input method — getting fcitx5 and an engine onto the machine, and wiring up the environment for it, is a separate concern and deliberately not part of this PR. Nothing here is specific to Chinese either; Japanese and Korean users hit the same code path, and Latin input is unchanged.

Verified

On Arch with Hyprland, quickshell 0.3.1, fcitx5 + fcitx5-chewing.

The fix works, against a controlled negative. Same session, same script, same input method, fcitx5-remote -o as the oracle:

reported input method filter contents
patched im=chewing preedit 你好 → commits 你好, menu renders No matches for "你好"
unpatched im=keyboard-us su3cl3

Both entry points were run separately (omarchy-menu toggle and omarchy-menu toggle apps).

Nothing looks different. Compared against screenshots of the unpatched shell: search line 0.0026 differing pixels of 89600, whole menu card 0.0052, full 3840x2160 frame 73 px — the clock in the bar.

The caret and selection stay invisible. 0 differing pixels across Ctrl+A, Home, Shift+Left, Ctrl+Left and Ctrl+V, and across 8 frames spanning 2.8 s to catch a blink.

Keys cannot leak past the modal. With the uninstall confirmation up, typing zzz leaves the full frame byte-identical; Escape then cancels it and typing resumes normally.

One behaviour does change, for the better: Ctrl+V now pastes into the filter. The old accumulator required NoModifier or ShiftModifier, so paste did nothing at all.

./test/shell gives identical results on the patched and unpatched trees for every menu-related test file.

The same defect exists elsewhere

Four sibling plugins have the byte-same Keys.onPressed accumulator and cannot take CJK input either:

  • shell/plugins/reminders/ReminderFlow.qml — the worst of them, since this is text entry, not a filter
  • shell/plugins/clipboard/Clipboard.qml
  • shell/plugins/emojis/Emojis.qml
  • shell/plugins/image-picker/ImagePicker.qml

I've kept this PR to the menu so it stays reviewable and because it's the surface people hit first. Happy to follow up with the other four, verified the same way, if this shape looks right to you.

How this relates to the open menu-input PRs

Three open PRs are working on this same search line. Where this one overlaps them, and where it does not:

#7659 and #8023 patch the exact statement this PR deletes. Both fix the accumulator's modifier test — event.modifiers === Qt.NoModifier || event.modifiers === Qt.ShiftModifier drops numpad digits, which Qt stamps with KeypadModifier, and AltGr characters, which it stamps with GroupSwitchModifier. A TextInput inserts event.text without consulting the modifiers at all, so the menu no longer has that decision to get wrong: +, numpad digits and AltGr symbols type, while Ctrl and Alt chords still stay with keyCatcher, which sees every key first. Whichever of the three lands first, the others need a rebase; they edit the same line.

#8023 is only half superseded. Its Util.extendsFilter also serves ImagePicker.qml, which this PR does not touch, so the helper keeps a caller and the image picker keeps the bug. Note that its new test asserts the menu routes through Util.extendsFilter, which this PR makes untrue of the menu. If this shape is the one you want, the follow-up above would take the image picker off the helper too, and extendsFilter could go away with the last accumulator.

#9135 is orthogonal, and I am not claiming it. It changes the layer-shell surface — keyboardFocus from Exclusive to OnDemand, exclusionMode from Ignore to Auto — so an on-screen keyboard can appear and take pointer input. Different mechanism, different line; this PR neither fixes nor conflicts with it. I have tested this change only against Exclusive, the menu's current configuration, and have not tested an on-screen keyboard at all, so I make no claim about how the two compose beyond not touching the same code.

🤖 Generated with Claude Code

The filter was a Text element fed by keyCatcher's Keys.onPressed, which
appended event.text one character at a time. Qt delivers input-method
events -- the preedit an input method shows while composing, and the text
it commits -- only to an item that answers inputMethodQuery, and in QML
that means TextInput or TextEdit. An Item with a key handler is invisible
to that protocol, so composing Chinese, Japanese or Korean through fcitx5
either dropped the text or left the raw Latin keysyms behind: typing the
bopomofo for 你好 filled the filter with "su3cl3".

Focus now lives on a TextInput that forwards every key to keyCatcher
first, so the menu keeps all of its own bindings and only the keys the
handler leaves unaccepted -- printable characters, paste, IME commits --
reach the search line. The modal branch accepts unconditionally, so keys
pressed while the uninstall confirmation is up cannot type into the field
behind it.

The line stays an append-only buffer with no caret and no selection, so
the menu looks and behaves exactly as before for Latin input.
@codenamekt

Copy link
Copy Markdown

Verification: Omacloud Test Harness

✅ Passed — All 114 unit test assertions passed. Live QML TextInput key forwarding and IME-compatible search filtering visually verified in Hyprland session.

PR #12338 — Make the menu search line a real text input
Author @linyiru
Head Commit 3175e060be
Base Branch quattro
Verification Scope verifiable-graphical (1 file: shell/plugins/menu/Menu.qml)
Test Output 114 passed · 0 failed · 0 skipped (100% TAP coverage)
Environment Hyprland 0.56.2 + Quickshell (omarchy-shell) · 1920×1080 · Intel UHD 630 iGPU

Graphical Menu Search Verification

Verified the refactored TextInput component inside a live Omarchy session:

  1. Initial Menu Summon (menu_initial.png):
    • Menu opens with clean Go... placeholder overlay.
    • Active focus is automatically acquired by filterInput without rendering an intrusive text caret.
  2. Keystroke & Input Method Routing (menu_typed_term.png):
    • Typed "term" via synthetic Wayland input events (wtype).
    • Verified that printable keystrokes populate filterInput.text, forward navigation keys to keyCatcher, and dynamically filter the menu to matching entries (Terminal, Defaults > Terminal).

Screenshots Captured During Run:

  • Initial Open (Go... placeholder):
menu_initial
  • Filtered Search (term query):
menu_typed_term

Triage Insights for Upstream

  • Why this fix is critical: The previous implementation used a generic Text element with a manual Keys.onPressed accumulator. Input methods (such as fcitx5 for Chinese, Japanese, and Korean) send IME composition/preedit events that never emit standalone single-character key events. Switching to a true TextInput with Keys.forwardTo: [keyCatcher] enables full CJK and international input method support.
  • Regression Guard: Confirmed that navigation key bindings (Up, Down, Return, Esc, Backspace) remain fully operational while typing.

TAP Assertion Breakdown (114 / 114 OK)
ok - menu parses JSONC with comments and trailing commas
ok - menu normalizes parsed items
ok - menu user entries override default entries
ok - menu preserves original order on override
ok - menu injects root when merging sources
ok - menu slugifies provider rows
ok - menu builds item paths
ok - menu builds parent paths
ok - menu detects descendants
ok - menu counts children
ok - menu appends checked marker
ok - menu marks a disabled row as something you already have
ok - menu leaves an uninstalled row unmarked
ok - menu hides a submenu with no visible children
ok - menu shows a submenu with a visible child
ok - menu hides recursively empty submenus
ok - menu keeps provider-backed submenus visible
ok - menu keeps a disabled row visible
ok - menu disables a row whose disabled: succeeded
ok - menu leaves a row selectable when its disabled: failed
ok - menu never disables a row that declares no disabled:
ok - menu display rows carry their disabled state
ok - menu search skips disabled rows, which belong to the submenu they sit in rather than a list of what you can do
ok - menu matches labels and aliases
ok - menu matches aliases
ok - menu rejects missing terms
ok - menu hides invisible matches
ok - menu scores name matches above description matches
ok - menu builds display rows
ok - menu ranks an installed app above menu entries matching the query equally well
ok - menu ranks an app matching the query as a whole word above exact-labeled menu entries
ok - menu keeps a better-matching menu entry above a weaker app match
ok - menu routes an exact id even when an app keyword matches it
ok - menu never routes to an app row through its keywords
ok - menu routes declared aliases to their item
ok - menu normalizes underscores in routes
ok - menu routes empty input to root
ok - menu falls through to the literal input
ok - menu still finds an app by its keywords in search
ok - menu delegates route resolution to the shared model
ok - menu lists Emoji first under Trigger
ok - menu opens the emoji picker from Trigger
ok - menu update Omarchy entry uses the Omarchy glyph
ok - menu update Omarchy entry renders the private glyph with the Omarchy font
ok - menu hides Extra Themes until a theme cloned from git is there to update
ok - menu keeps Input as a direct config action
ok - menu places Direct Boot directly under Setup
ok - menu exposes Reset Computer under Setup
ok - menu lists Reset Computer last under Setup
ok - menu exposes every supported coding agent with its own glyph under Defaults > Agent
ok - menu sorts coding agents alphabetically
ok - menu always exposes every supported browser, terminal, and editor under Defaults
ok - menu removes Crush from Install > AI
ok - menu never hides an Install row because the software is already there
ok - menu dims the Install rows for software that is already installed
ok - menu asks the same presence question it used to hide the row with
ok - menu keeps hiding Chromium Account without Chromium, and dims it once the account is set up
ok - menu still hides Remove rows for software that is not installed
ok - menu orders Remove categories like their Install counterparts, followed by Remove-only categories
ok - menu places Passwordless Sudo under Setup > Security
ok - menu removes the relocated toggles from Trigger > Toggle
ok - menu groups Menu Bar positions in a submenu
ok - menu lists all Menu Bar positions under Position
ok - menu exposes Menu Bar transparency as a toggle
ok - menu manages plugins from Setup > Plugins
ok - menu picks a plugin the way it already picks a theme or a timezone
ok - menu always offers Enable and Disable, which cover the built-in plugins too
ok - menu hides Remove until a plugin the user installed exists to delete
ok - menu adds a plugin through the CLI, where the trust warning and clone output are visible
ok - plugin picker offers what each verb can act on
ok - plugin picker leaves plugin-kind decisions to its data and the plugin command
ok - plugin enable reports a bar as replacing the one in use, whether enabled or freshly added
ok - interactive plugin add selects the manifest placement or center fallback by default
ok - plugin picker delegates enable and disable without interpreting plugin kinds
ok - plugin picker shows the id as row subtext and acts on the id the selection hands back
ok - menu select mode reads a leading icon and a trailing subtext off an option
ok - plugin picker removes where the confirmation and backup path are visible
ok - menu re-enumerates the font list every time it is opened
ok - menu invalidates volatile providers when entering a menu, not on every keystroke
ok - menu search never restarts a volatile provider
ok - menu only shows Laptop Display on laptops
ok - menu only shows Mirror Display on laptops
ok - menu only shows webcam screen recording when a webcam is available
ok - menu rows support per-icon font families
ok - menu keyboard navigation disarms pointer selection
ok - menu keyboard navigation skips disabled rows in the direction of travel
ok - menu reads selectability off the row
ok - menu refuses to activate a disabled row
ok - menu leaves the cursor put when the pointer crosses a disabled row
ok - menu renders a disabled row faded, and leaves it at that
ok - menu parks the cursor on a selectable row after the rows change
ok - menu ties the cursor to a selectable row existing, both ways
ok - menu filter changes disarm pointer selection
ok - menu route changes only accept an initial pointer sample for mouse activation
ok - menu Left key follows empty-filter Backspace navigation
ok - menu uses shared pointer movement gate in card coordinates
ok - menu resets pointer movement gate when pointer selection is disarmed
ok - app merge appends app rows after the static menu items
ok - repeating the app merge with the same entries does not duplicate rows
ok - app merge drops rows for entries that went away
ok - app merge lists an app once even when two desktop entries share an id
ok - app merge heals an order entry whose item went missing instead of duplicating it
ok - app merge leaves the map it was handed untouched
ok - provider merge appends its rows
ok - repeating a provider merge does not duplicate rows
ok - provider merge drops rows the provider no longer lists
ok - provider merge leaves rows belonging to another provider alone
ok - menu slugs collide across plugin ids that differ only in separator
ok - menu keeps colliding provider rows apart so none is dropped
ok - menu assigns the rebuilt app item map instead of mutating it in place
ok - menu assigns the rebuilt provider item map instead of mutating it in place
ok - menu never writes into the item map held by the var property
ok - menu openExistingMenu function exists
ok - menu openExistingMenu ignores a stale hidden-pointer position when becoming visible
ok - menu openDmenu function exists
ok - menu openDmenu ignores a stale hidden-pointer position when becoming visible
ok - menu only selects from pointer after real movement
ok - menu row hover routes through pointer movement gate
ok - menu samples pointer movement immediately when entering a row
ok - mouse activation carries pointer intent into subordinate menus
ok - Omarchy icon font includes the official agent marks

Verified automatically with Omacloud Test Harness · Run duration: 8.4s

@TAE58

TAE58 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Tested this on Omarchy 4.0.4 with fcitx5 (Hangul), applying only this PR's Menu.qml diff. It fixes #11682: Hangul composes inline (underlined preedit) and the committed text filters the menu. ↑/↓, Enter, Esc, Backspace, ← (back), Ctrl+U, Ctrl+Backspace, Ctrl+V, Ctrl+A, Ctrl+Z and Home/End all behave as before.

I found two regressions, both about keys reaching the new TextInput that the old accumulator filtered out:

1. Alt chords type their letter into the search line

Steps: open the menu and press Alt+a, Alt+1 or Alt+f. The search line shows a, 1 or f.

The old accumulator only took text when the modifiers were none or Shift. With that branch gone, unaccepted Alt chords fall through to filterInput, and TextInput inserts their text.

2. Input-method text leaks into the search line behind the delete confirmation

Steps: search calc, select an app, press Delete, then type Hangul (e.g. 가나) while the dialog is up. The search line becomes calc가나 while the dialog is still open, and the results behind it re-filter. Latin letters are swallowed correctly.

keyCatcher's "swallow everything while the modal is up" only covers key events. fcitx5 delivers composed text as an InputMethodEvent straight to the focused TextInput, so it never passes through Keys.onPressed.

Fix I tested locally (on top of this PR):

// keyCatcher Keys.onPressed, after the Return/Enter/Right branch
} else if (event.modifiers & (Qt.AltModifier | Qt.MetaModifier)) {
  // Alt/Meta chords belong to other shortcuts, as the old accumulator
  // assumed. Left unaccepted, TextInput would insert their text.
  event.accepted = true
}
// filterInput
// Input-method text arrives as an InputMethodEvent, not a key event,
// so keyCatcher's modal swallow never sees it. A read-only TextInput
// rejects input-method events and tells the IME it is not a target.
readOnly: root.deleteConfirmOpen

With both changes: Alt+a and Alt+1 no longer type anything, and Hangul no longer leaks while the dialog is open. Hangul search (터미널), Ctrl+V and Backspace still work after the fix.

Root cause and fix drafted with help from Claude; testing done by me.

@TAE58

TAE58 commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

I'll follow up with a PR for regression 2 only: readOnly: root.deleteConfirmOpen on filterInput, stacked on this branch.

linyiru#3

Leaving the Alt/Meta swallow out. I didn't test AltGr, and those chords are part of what this PR keeps typable.

@omarchybot

Copy link
Copy Markdown
Collaborator

Thank you for this. The work is carried forward in #15508, which brings the still-missing parts of Japanese, Chinese and Korean setup together into one change, so I am closing this in its favour.

The real text input for the menu search line is in #15508, credited to you and to TAE58 as co-authors, together with TAE58's two fixes: Alt and Super chords no longer type their letter, and the line is read-only behind the uninstall confirmation. On a worker, Mozc now composes にほんご and commits 日本語 into the search line, where quattro still types raw romaji. It is a shared FilterInput component, so clipboard and emoji search can adopt it next.

This was checked against quattro by Claude, with Codex at medium effort verifying the claims above. If something here is not covered after all, say so and this can be reopened.

@omarchybot omarchybot closed this Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants