diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-06-19 10:23:24 +0200 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-06-19 10:23:24 +0200 |
| commit | 02870242eea8b729b3dbd6d23eb77372f61c6318 (patch) | |
| tree | 1c754a9b01c71b3e68aa795469c30b6c32074e17 /src/Fl_win32.cxx | |
| parent | 232743c3a5d903be813f6c4445f3f96bab25cae0 (diff) | |
Move input method support to Fl_Screen_Driver from Fl_Graphics_Driver
Diffstat (limited to 'src/Fl_win32.cxx')
| -rw-r--r-- | src/Fl_win32.cxx | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx index 51d122aeb..6480aabd4 100644 --- a/src/Fl_win32.cxx +++ b/src/Fl_win32.cxx @@ -193,13 +193,13 @@ static int get_wsock_mod() { */ static HMODULE s_imm_module = 0; typedef BOOL(WINAPI *flTypeImmAssociateContextEx)(HWND, HIMC, DWORD); -flTypeImmAssociateContextEx flImmAssociateContextEx = 0; +static flTypeImmAssociateContextEx flImmAssociateContextEx = 0; typedef HIMC(WINAPI *flTypeImmGetContext)(HWND); -flTypeImmGetContext flImmGetContext = 0; +static flTypeImmGetContext flImmGetContext = 0; typedef BOOL(WINAPI *flTypeImmSetCompositionWindow)(HIMC, LPCOMPOSITIONFORM); -flTypeImmSetCompositionWindow flImmSetCompositionWindow = 0; +static flTypeImmSetCompositionWindow flImmSetCompositionWindow = 0; typedef BOOL(WINAPI *flTypeImmReleaseContext)(HWND, HIMC); -flTypeImmReleaseContext flImmReleaseContext = 0; +static flTypeImmReleaseContext flImmReleaseContext = 0; static void get_imm_module() { s_imm_module = LoadLibrary("IMM32.DLL"); @@ -655,6 +655,33 @@ void Fl_WinAPI_Screen_Driver::disable_im() { im_enabled = 0; } +void Fl_WinAPI_Screen_Driver::set_spot(int font, int size, int X, int Y, int W, int H, Fl_Window *win) +{ + if (!win) return; + Fl_Window* tw = win->top_window(); + + if (!tw->shown()) + return; + + HIMC himc = flImmGetContext(fl_xid(tw)); + + if (himc) { + COMPOSITIONFORM cfs; + float s = Fl_Graphics_Driver::default_driver().scale(); + cfs.dwStyle = CFS_POINT; + cfs.ptCurrentPos.x = int(X * s); + cfs.ptCurrentPos.y = int(Y * s) - int(tw->labelsize() * s); + // Attempt to have temporary text entered by input method use scaled font. + // Does good, but still not always effective. + Fl_GDI_Font_Descriptor *desc = (Fl_GDI_Font_Descriptor*)Fl_Graphics_Driver::default_driver().font_descriptor(); + if (desc) SelectObject((HDC)Fl_Graphics_Driver::default_driver().gc(), desc->fid); + MapWindowPoints(fl_xid(win), fl_xid(tw), &cfs.ptCurrentPos, 1); + flImmSetCompositionWindow(himc, &cfs); + flImmReleaseContext(fl_xid(tw), himc); + } +} + + //////////////////////////////////////////////////////////////// int Fl_WinAPI_Screen_Driver::get_mouse_unscaled(int &mx, int &my) { |
