From 7ffd947830193977c70b0e6a561362f3365ff40a Mon Sep 17 00:00:00 2001 From: nanahi <130121847+na-na-hi@users.noreply.github.com> Date: Fri, 15 Dec 2023 11:29:56 -0500 Subject: [PATCH] win32: move IME candidate window to video window By default the IME candidate window appears on the top left corner of the monitor. Move it to the video window for sane behavior. --- meson.build | 1 + test/meson.build | 1 + video/out/w32_common.c | 9 +++++++++ 3 files changed, 11 insertions(+) diff --git a/meson.build b/meson.build index ad6f9dde08..3a5bcaed65 100644 --- a/meson.build +++ b/meson.build @@ -489,6 +489,7 @@ if features['win32-desktop'] win32_desktop_libs = [cc.find_library('avrt'), cc.find_library('dwmapi'), cc.find_library('gdi32'), + cc.find_library('imm32'), cc.find_library('ole32'), cc.find_library('uuid'), cc.find_library('uxtheme'), diff --git a/test/meson.build b/test/meson.build index ebd4395c71..32796fad34 100644 --- a/test/meson.build +++ b/test/meson.build @@ -50,6 +50,7 @@ if not features['win32-threads'] endif if features['win32-desktop'] + test_utils_deps += cc.find_library('imm32') test_utils_deps += cc.find_library('winmm') endif test_utils_objects = libmpv.extract_objects(test_utils_files) diff --git a/video/out/w32_common.c b/video/out/w32_common.c index 717430bb1f..d2972f9193 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -1551,6 +1551,15 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, ((LPNCCALCSIZE_PARAMS) lParam)->rgrc[0].top -= get_title_bar_height(w32); } break; + case WM_IME_STARTCOMPOSITION: { + HIMC imc = ImmGetContext(w32->window); + if (imc) { + COMPOSITIONFORM cf = {.dwStyle = CFS_POINT, .ptCurrentPos = {0, 0}}; + ImmSetCompositionWindow(imc, &cf); + ImmReleaseContext(w32->window, imc); + } + break; + } } if (message == w32->tbtn_created_msg) {