From 1c7409e0a12765282a121779ac59168c94de6ef5 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Mon, 15 Sep 2014 09:44:35 +0000 Subject: Add methods to enable and disable the system's input methods. This needs to be done from FLTK as it affects the window interaction, which FLTK is largely responsible for. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10314 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_win32.cxx | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/Fl_win32.cxx') diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx index 776bce1c0..ff6da442d 100644 --- a/src/Fl_win32.cxx +++ b/src/Fl_win32.cxx @@ -119,6 +119,8 @@ static HMODULE get_wsock_mod() { * size and link dependencies. */ static HMODULE s_imm_module = 0; +typedef BOOL (WINAPI* flTypeImmAssociateContextEx)(HWND, HIMC, DWORD); +static flTypeImmAssociateContextEx flImmAssociateContextEx = 0; typedef HIMC (WINAPI* flTypeImmGetContext)(HWND); static flTypeImmGetContext flImmGetContext = 0; typedef BOOL (WINAPI* flTypeImmSetCompositionWindow)(HIMC, LPCOMPOSITIONFORM); @@ -131,6 +133,7 @@ static void get_imm_module() { if (!s_imm_module) Fl::fatal("FLTK Lib Error: IMM32.DLL file not found!\n\n" "Please check your input method manager library accessibility."); + flImmAssociateContextEx = (flTypeImmAssociateContextEx)GetProcAddress(s_imm_module, "ImmAssociateContextEx"); flImmGetContext = (flTypeImmGetContext)GetProcAddress(s_imm_module, "ImmGetContext"); flImmSetCompositionWindow = (flTypeImmSetCompositionWindow)GetProcAddress(s_imm_module, "ImmSetCompositionWindow"); flImmReleaseContext = (flTypeImmReleaseContext)GetProcAddress(s_imm_module, "ImmReleaseContext"); @@ -460,6 +463,32 @@ public: }; static Fl_Win32_At_Exit win32_at_exit; +static char im_enabled = 1; + +void Fl::enable_im() { + fl_open_display(); + + Fl_X* i = Fl_X::first; + while (i) { + flImmAssociateContextEx(i->xid, 0, IACE_DEFAULT); + i = i->next; + } + + im_enabled = 1; +} + +void Fl::disable_im() { + fl_open_display(); + + Fl_X* i = Fl_X::first; + while (i) { + flImmAssociateContextEx(i->xid, 0, 0); + i = i->next; + } + + im_enabled = 0; +} + //////////////////////////////////////////////////////////////// int Fl::x() @@ -1878,6 +1907,9 @@ Fl_X* Fl_X::make(Fl_Window* w) { // Register all windows for potential drag'n'drop operations RegisterDragDrop(x->xid, flIDropTarget); + if (!im_enabled) + flImmAssociateContextEx(x->xid, 0, 0); + return x; } -- cgit v1.2.3