Skip to content

Disable local Windows IME on the streaming window - #2108

Closed
hinatamaxxx wants to merge 1 commit into
moonlight-stream:masterfrom
hinatamaxxx:fix-windows-streaming-ime
Closed

hinatamaxxx wants to merge 1 commit into
moonlight-stream:masterfrom
hinatamaxxx:fix-windows-streaming-ime

Conversation

@hinatamaxxx

Copy link
Copy Markdown

Problem

On Windows (especially with sdl2-compat / SDL3), Japanese IME typing during a stream can drop or repeat characters because the local Windows IME remains attached to the streaming window.

Root Cause

Session::initialize() calls SDL_StopTextInput() before creating the hidden decoder probe window (testWindow) and the actual streaming window (m_Window).

In SDL3's Windows keyboard backend (src/video/windows/SDL_windowskeyboard.c), IME_Init() latches ime_hwnd_main onto the first created window (testWindow), and IME_Disable() only calls ImmAssociateContext(..., 0) when ime_hwnd_current == ime_hwnd_main. As a result, subsequent windows (and windows recreated after fullscreen transitions or decoder initialization) retain an active local HIMC even though SDL_IsTextInputActive() is false, allowing the client's local IME to intercept keystrokes meant for the host.

Fix

  • Add a small Windows-only helper (WindowsKeyboardInput::disableLocalIme()) that detaches the local IME context directly from the streaming window's HWND via ImmAssociateContextEx(hwnd, nullptr, 0).
  • Call it when the streaming window is assigned (SdlInputHandler::setWindow()), on focus gain (notifyFocusGained()), after fullscreen transitions (Session::toggleFullscreen(), Session::exec()), and after decoder initialization (chooseDecoder()), since those transitions can recreate the native HWND.
  • Link imm32.lib on Windows in app/app.pro.

This does not touch the Qt UI windows, does not enable Raw Input, and has no effect on non-Windows platforms.

Testing

Tested on Windows 11 client (Japanese JIS keyboard, Microsoft IME) streaming to a Windows 11 host (Sunshine):

  • Long Japanese typing, conversion, commit, and BackSpace: no dropped or repeated characters.
  • Fullscreen toggling (Ctrl+Alt+Shift+F) and Alt+Tab focus loss/gain: local IME stays detached and Japanese typing remains normal.
  • Modifier shortcuts (Ctrl+C, Ctrl+V, Ctrl+A, Shift+Arrow): normal.

@cgutman

cgutman commented Nov 27, 2026

Copy link
Copy Markdown
Member

This should be upstreamed to SDL3 rather than hacking around the issue here.

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.

2 participants