Input: keep the input method out of the title's windows (VICTORY_IME_OFF, on by default) #4105

Open
github-bot wants to merge 4 commits from github-bot/gh-4105 into main AGit
Owner

@⁠kongmuqiu on GitHub · 2026-11-30 16:06 UTC · original
kongmuqiu:ime-off-pr → main · +352 −8 · 9 files · 4 commits · open

Fixes # (no open issue found for it; seen here with Microsoft Pinyin)

What it changes

What was wrong: with a Chinese, Japanese or Korean input method on, W, A, S and D start a composition in the game's window. The candidate box shows at the window's top left and the keys go to it, so the player has to switch the input method to English before every session. VICTORY_IME_ENGLISH=1 (#17, opt-in) switches the keyboard layout to en-US when that layout is installed, but it does not keep the input method out of the window, and it does nothing on a PC without the en-US layout.

What this does: games detach the input method from their windows, and this does the same. It is on by default; VICTORY_IME_OFF=0, or INPUT METHOD in the F1 menu, keeps the input method.

  • Every window the title creates is detached at creation (ImmAssociateContextEx with no context). It is detached again when activated, focused, or when the input language changes (WM_INPUTLANGCHANGE, Win+Space).
  • A window is detached only if it has an input context, and a composition in progress is cancelled first (ImmNotifyIME CPS_CANCEL), as SDL and Chromium do.
  • WM_IME_SETCONTEXT reaches the title with every UI flag cleared.
  • A composition that still reaches the window means something attached the input method again. It is cancelled and detached, and the title never sees WM_IME_START/COMPOSITION/ENDCOMPOSITION. This happens at most 256 times, so an overlay is never fought for good.
  • VICTORY_IME_OFF=thread also disables the input method for the window's thread (ImmDisableIME(0) before its first top-level window). It is for input methods or remote sessions where a per-window detach does not hold. The fallback presenter window's thread gets no input method either.
  • The title's text entry dialog is not detached. Keys and mouse buttons typed into it no longer reach the game (they moved the character while typing). The XGameUi button chooser (dialog::choose) counts the same way, through one guard (DialogUp), so the Enter that answers it no longer also presses A.
  • With VICTORY_MNK=1, the native mouse camera's overlay treats such a dialog as a menu: the cursor is let go, and the mouse buttons no longer press the pad's triggers.
  • It works beside VICTORY_IME_ENGLISH; both can be on.

It follows what SDL3, Godot, Chromium and Qt do, the DirectX article on using an input method editor in a game, and the Microsoft Pinyin report in SDL PR #15052 (Pinyin ignores cleared WM_IME_SETCONTEXT flags).

How it was tested

  • GPU and profile: RTX 4070 Laptop 8 GB, Windows 11 26300, Microsoft Pinyin. Series S, 1920x1080 output, with and without DLSS, no frame generation, ray tracing on. The change does not depend on the GPU or the profile.

  • Before: W showed Pinyin's candidate window at the window's top left in Chinese mode.

  • After: no candidate window in Chinese or English mode, also after switching the input language away and back and after Alt+Tab, and the character walks. The text entry dialog is not detached, so it should keep Pinyin, but that was not tried in game.

  • For shader changes, the wave sizes tested: no shader changes.

  • cargo test passed for the crates it touches: yes for victory-hle (lifecycle, xgameui, mnk, gameinput: 126 passed, 0 failed). Three of the tests are new:

    • a detached window has no input context;
    • hooked windows clear WM_IME_SETCONTEXT;
    • VICTORY_IME_OFF=thread leaves new windows without a default IME window.

    The F1 menu no longer has unit tests since its rewrite (3bde4923); its new item has a description line within the 60 columns. Rebased onto 5fabb46e: the release build passes, and cargo clippy -p victory-gpu -p victory-hle --all-targets adds no warning.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #17 (the English-layout switch this works beside), #1977 (F1 menu localization, which also touches menu.rs).

Follow-up: #4260 builds on this PR. It adds opt-in GTA PC controls and a smoothed mouse camera (VICTORY_KBM_GTA=1), which use this PR's dialog guard. This PR stands on its own and can be merged without it.

🤖 Generated with Claude Code

**@⁠kongmuqiu** on GitHub · 2026-11-30 16:06 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4105) `kongmuqiu:ime-off-pr` → `main` · +352 −8 · 9 files · 4 commits · open Fixes # (no open issue found for it; seen here with Microsoft Pinyin) ## What it changes **What was wrong:** with a Chinese, Japanese or Korean input method on, W, A, S and D start a composition in the game's window. The candidate box shows at the window's top left and the keys go to it, so the player has to switch the input method to English before every session. `VICTORY_IME_ENGLISH=1` (#17, opt-in) switches the keyboard layout to en-US when that layout is installed, but it does not keep the input method out of the window, and it does nothing on a PC without the en-US layout. **What this does:** games detach the input method from their windows, and this does the same. It is **on by default**; `VICTORY_IME_OFF=0`, or **INPUT METHOD** in the F1 menu, keeps the input method. - Every window the title creates is detached at creation (`ImmAssociateContextEx` with no context). It is detached again when activated, focused, or when the input language changes (`WM_INPUTLANGCHANGE`, Win+Space). - A window is detached only if it has an input context, and a composition in progress is cancelled first (`ImmNotifyIME CPS_CANCEL`), as SDL and Chromium do. - `WM_IME_SETCONTEXT` reaches the title with every UI flag cleared. - A composition that still reaches the window means something attached the input method again. It is cancelled and detached, and the title never sees `WM_IME_START/COMPOSITION/ENDCOMPOSITION`. This happens at most 256 times, so an overlay is never fought for good. - `VICTORY_IME_OFF=thread` also disables the input method for the window's thread (`ImmDisableIME(0)` before its first top-level window). It is for input methods or remote sessions where a per-window detach does not hold. The fallback presenter window's thread gets no input method either. - The title's text entry dialog is not detached. Keys and mouse buttons typed into it no longer reach the game (they moved the character while typing). The XGameUi button chooser (`dialog::choose`) counts the same way, through one guard (`DialogUp`), so the Enter that answers it no longer also presses A. - With `VICTORY_MNK=1`, the native mouse camera's overlay treats such a dialog as a menu: the cursor is let go, and the mouse buttons no longer press the pad's triggers. - It works beside `VICTORY_IME_ENGLISH`; both can be on. It follows what SDL3, Godot, Chromium and Qt do, the DirectX article on using an input method editor in a game, and the Microsoft Pinyin report in SDL PR #15052 (Pinyin ignores cleared `WM_IME_SETCONTEXT` flags). ## How it was tested - GPU and profile: RTX 4070 Laptop 8 GB, Windows 11 26300, Microsoft Pinyin. Series S, 1920x1080 output, with and without DLSS, no frame generation, ray tracing on. The change does not depend on the GPU or the profile. - Before: W showed Pinyin's candidate window at the window's top left in Chinese mode. - After: no candidate window in Chinese or English mode, also after switching the input language away and back and after Alt+Tab, and the character walks. The text entry dialog is not detached, so it should keep Pinyin, but that was not tried in game. - For shader changes, the wave sizes tested: no shader changes. - `cargo test` passed for the crates it touches: yes for `victory-hle` (`lifecycle`, `xgameui`, `mnk`, `gameinput`: 126 passed, 0 failed). Three of the tests are new: - a detached window has no input context; - hooked windows clear `WM_IME_SETCONTEXT`; - `VICTORY_IME_OFF=thread` leaves new windows without a default IME window. The F1 menu no longer has unit tests since its rewrite (3bde4923); its new item has a description line within the 60 columns. Rebased onto 5fabb46e: the release build passes, and `cargo clippy -p victory-gpu -p victory-hle --all-targets` adds no warning. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #17 (the English-layout switch this works beside), #1977 (F1 menu localization, which also touches `menu.rs`). **Follow-up:** #4260 builds on this PR. It adds opt-in GTA PC controls and a smoothed mouse camera (`VICTORY_KBM_GTA=1`), which use this PR's dialog guard. This PR stands on its own and can be merged without it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
With a Chinese, Japanese or Korean input method on, W, A, S and D
started a composition whose candidate box showed at the window's top
left, and the player had to switch the input method to English first.
Games detach the input method from their window; so does this now:
every window the title creates is detached at creation
(ImmAssociateContextEx with no context) and again when activated or
focused, and WM_IME_SETCONTEXT reaches the title with every UI flag
cleared. Keys reach the title as before (it polls them).

Unlike the other window and input switches this one is on unless
VICTORY_IME_OFF=0 (also INPUT METHOD in the F1 menu), as games do it
without being asked. The title's text entry asks in a dialog of its
own thread, which keeps the input method for Chinese text.

Checked in the game with Microsoft Pinyin (Windows 11 26300): before,
W showed Pinyin's candidate window at (9, 34) in Chinese mode; after,
none in Chinese or English mode, and the character walks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
From a review of public solutions (SDL3, Godot, Chromium, Qt, Moonlight,
totk-pc-recomp, the DirectX "IME in a game" article, scrcpy and
better-genshin-impact reports):

- A window is detached only if it has an input context, and a composition
  in progress is cancelled first (ImmNotifyIME CPS_CANCEL), as SDL and
  Chromium do; the change's own WM_IME_SETCONTEXT does not detach again.
- A new input language (WM_INPUTLANGCHANGE, Win+Space) detaches again.
- A composition that still reaches the title's window means something
  attached the input method again: it is cancelled and detached, and the
  title never sees WM_IME_START/COMPOSITION/ENDCOMPOSITION (SDL PR #15052:
  Microsoft Pinyin ignores the cleared WM_IME_SETCONTEXT flags). At most
  256 times, so an overlay is never fought for good.
- VICTORY_IME_OFF=thread also disables the input method for the thread of
  the title's window (ImmDisableIME(0) before its first top-level window),
  for input methods or remote sessions where a per-window detach was
  reported not to hold. Its windows then get no input method window.
- The fallback presenter window's thread gets no input method either.
- Keys and mouse buttons typed into the title's text entry dialog no
  longer reach the game (they moved the character while typing).

Checked in the game with Microsoft Pinyin on Windows 11 26300: no
candidate window in Chinese or English mode, after switching the input
language away and back, and after Alt+Tab; the character walks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 16:10:54 +00:00
The XGameUi button chooser (dialog::choose: Enter picks the default,
Esc cancels) was not counted as one of our dialogs being up, so with keys
or the mouse on (our GTA controls, MnK) the Enter that answered it also
reached the game. It now counts like the text entry does, through one
guard (DialogUp) both use.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With VICTORY_MNK=1 the native mouse camera's overlay decided its capture
from the window in front and the title's menus only: while the title's
text entry (or the button chooser) was up, the cursor stayed captured and
the mouse buttons still pressed the pad's triggers. The dialog now counts
as a menu there, as it already does for the keys and the MnK bindings.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot force-pushed github-bot/gh-4105 from 77aef795d8 to fe67c1d39c 2026-12-01 08:32:38 +00:00 Compare
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host/menu.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/4105/head:github-bot/gh-4105'
git switch 'github-bot/gh-4105'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-4105'
git switch 'github-bot/gh-4105'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-4105'
git switch 'github-bot/gh-4105'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-4105'
git switch 'main'
git merge --squash 'github-bot/gh-4105'
git switch 'main'
git merge --ff-only 'github-bot/gh-4105'
git switch 'main'
git merge 'github-bot/gh-4105'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!4105
No description provided.