From 1f87069e504290ad01e695e84a9e3fd8f0adf023 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 31 Oct 2026 11:38:24 +0800 Subject: [PATCH] Detach the game window from the input method A Chinese IME switched on over the game attached to the window, then showed its candidate window and took the keys it composes although there is nothing to type into here; Shift, which a player may have bound as the walk key, is one of the keys such an IME takes. The software keyboard's edit box is a window of its own and keeps the IME it needs, so only the game's window is detached. --- runtime/gfx_window.c | 6 ++++++ tools/build_game.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/runtime/gfx_window.c b/runtime/gfx_window.c index 021c53c0..50286292 100644 --- a/runtime/gfx_window.c +++ b/runtime/gfx_window.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "cfg.h" #include "flight.h" @@ -484,6 +485,11 @@ static DWORD WINAPI window_main(void *arg) { rt_log("gfx: CreateWindowEx failed (%lu)", GetLastError()); g_wnd_failed = 1; } else { + // An IME switched on over the game attaches to this window and then shows its candidate window and eats the keys + // it composes, although there is nothing here to type into (Shift, which a player may have bound as the walk key, + // is one of the keys a Chinese IME takes). Detaching the game's window leaves the software keyboard alone: its + // edit box is a window of its own and gets the IME it needs. + ImmAssociateContext(g_hwnd, NULL); // The frame was measured at the system DPI; the window may have opened on a monitor at another scale. InterlockedExchange(&g_dpi, (LONG)GetDpiForWindow(g_hwnd)); outer_size(g_hwnd, cw, ch, &ow, &oh); diff --git a/tools/build_game.py b/tools/build_game.py index 22eb9581..1085bb5c 100644 --- a/tools/build_game.py +++ b/tools/build_game.py @@ -81,10 +81,10 @@ GEN_FLAGS = ['-O1', '-fno-strict-aliasing', '-Wno-return-type', '-Wno-unused-lab RT_FLAGS = ['-O2', '-g', '-Wall', '-fno-strict-aliasing', '-march=x86-64-v3', '-D_WIN32_WINNT=0x0A00'] # -Xlinker passes the map path as one argument; -Wl, would split it at any comma in the build dir path LINK_FLAGS = ['-fuse-ld=lld', '-Wl,--stack,16777216', '-Xlinker', '"--Map=$builddir/totk.map"'] # the map feeds tools/prof_report.py -LINK_LIBS = ['-lpsapi', '-lbcrypt', '-lvulkan-1', '-luser32', '-lgdi32', '-ldwmapi', '-lwinmm', '-lSDL3', '-lopus', '-l:libvpx.a', '-l:libzstd.a', '-l:libstdc++.a', '-l:libwinpthread.a'] # Vulkan back end; libvpx static (movies); libzstd static (resolution.c) +LINK_LIBS = ['-lpsapi', '-lbcrypt', '-lvulkan-1', '-luser32', '-lgdi32', '-ldwmapi', '-limm32', '-lwinmm', '-lSDL3', '-lopus', '-l:libvpx.a', '-l:libzstd.a', '-l:libstdc++.a', '-l:libwinpthread.a'] # Vulkan back end; libvpx static (movies); libzstd static (resolution.c) VMA_INCLUDE = UCRT.parent / 'include' / 'vma' # vk_mem_alloc.h; MSYS2 package vulkan-memory-allocator # --toolchain: an llvm-mingw tree. The libraries, headers and DLLs MSYS2 supplies come from the deps directory instead. -LLVM_LINK_LIBS = ['-lpsapi', '-lbcrypt', '-luser32', '-lgdi32', '-ldwmapi', '-lwinmm', '-lvulkan-1', '-lSDL3', '-lopus', +LLVM_LINK_LIBS = ['-lpsapi', '-lbcrypt', '-luser32', '-lgdi32', '-ldwmapi', '-limm32', '-lwinmm', '-lvulkan-1', '-lSDL3', '-lopus', '-l:libvpx.a', '-l:libzstd.a', '-l:libc++.a', '-l:libc++abi.a', '-l:libunwind.a', '-l:libwinpthread.a'] DEFAULT_DEPS = ROOT / 'toolchain' / 'deps-mingw' # Runtime sources compiled per install, not in the library: romfs.c includes romfs_config.h, patches.c and ov_zstd.c