Module: wine Branch: master Commit: e2cd4dcf8b6bf05a5ccc2e180348ab662ed59d94 URL: https://gitlab.winehq.org/wine/wine/-/commit/e2cd4dcf8b6bf05a5ccc2e180348ab6...
Author: Rémi Bernon rbernon@codeweavers.com Date: Tue May 9 15:12:01 2023 +0200
comctl32/edit: Notify IME on caret position, format_rect and font changes.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53860
---
dlls/comctl32/edit.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
diff --git a/dlls/comctl32/edit.c b/dlls/comctl32/edit.c index 883dd5d9145..352143f8159 100644 --- a/dlls/comctl32/edit.c +++ b/dlls/comctl32/edit.c @@ -38,6 +38,7 @@ #include "windef.h" #include "winbase.h" #include "winnt.h" +#include "wingdi.h" #include "imm.h" #include "usp10.h" #include "commctrl.h" @@ -1697,6 +1698,20 @@ static LRESULT EDIT_EM_Scroll(EDITSTATE *es, INT action) }
+static void EDIT_UpdateImmCompositionWindow(EDITSTATE *es, UINT x, UINT y) +{ + COMPOSITIONFORM form = + { + .dwStyle = CFS_RECT, + .ptCurrentPos = {.x = x, .y = y}, + .rcArea = es->format_rect, + }; + HIMC himc = ImmGetContext(es->hwndSelf); + ImmSetCompositionWindow(himc, &form); + ImmReleaseContext(es->hwndSelf, himc); +} + + /********************************************************************* * * EDIT_SetCaretPos @@ -1712,6 +1727,7 @@ static void EDIT_SetCaretPos(EDITSTATE *es, INT pos, res = EDIT_EM_PosFromChar(es, pos, after_wrap); TRACE("%d - %dx%d\n", pos, (short)LOWORD(res), (short)HIWORD(res)); SetCaretPos((short)LOWORD(res), (short)HIWORD(res)); + EDIT_UpdateImmCompositionWindow(es, (short)LOWORD(res), (short)HIWORD(res)); } }
@@ -3728,6 +3744,15 @@ static DWORD get_font_margins(HDC hdc, const TEXTMETRICW *tm) return MAKELONG(left, right); }
+static void EDIT_UpdateImmCompositionFont(EDITSTATE *es) +{ + LOGFONTW composition_font; + HIMC himc = ImmGetContext(es->hwndSelf); + GetObjectW(es->font, sizeof(LOGFONTW), &composition_font); + ImmSetCompositionFontW(himc, &composition_font); + ImmReleaseContext(es->hwndSelf, himc); +} + /********************************************************************* * * WM_SETFONT @@ -3779,6 +3804,8 @@ static void EDIT_WM_SetFont(EDITSTATE *es, HFONT font, BOOL redraw) es->flags & EF_AFTER_WRAP); ShowCaret(es->hwndSelf); } + + EDIT_UpdateImmCompositionFont(es); }
@@ -4593,6 +4620,7 @@ static LRESULT CALLBACK EDIT_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR EDITSTATE *es = (EDITSTATE *)GetWindowLongPtrW(hwnd, 0); LRESULT result = 0; RECT *rect; + POINT pt;
TRACE("hwnd %p, msg %#x, wparam %Ix, lparam %Ix\n", hwnd, msg, wParam, lParam);
@@ -5048,6 +5076,9 @@ static LRESULT CALLBACK EDIT_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR
/* IME messages to make the edit control IME aware */ case WM_IME_SETCONTEXT: + GetCaretPos(&pt); + EDIT_UpdateImmCompositionWindow(es, pt.x, pt.y); + EDIT_UpdateImmCompositionFont(es); break;
case WM_IME_STARTCOMPOSITION: