From: Jason Rumney Date: Wed, 22 Jul 2009 16:03:39 +0000 (+0000) Subject: * w32fns.c (w32_wnd_proc) [WM_IME_STARTCOMPOSITION]: Position X-Git-Tag: emacs-pretest-23.1.90~2060 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c902b9205ba37aa2db7b9ee855fdca2a13e8076a;p=emacs.git * w32fns.c (w32_wnd_proc) [WM_IME_STARTCOMPOSITION]: Position IME window at cursor (Bug#2570). (w32_wnd_proc) [WM_IME_CHAR]: Release context when finished. (globals_of_w32fns): Dynamically load functions required above. * w32term.c (w32_draw_window_cursor): Send message to reposition any IME window. --- diff --git a/src/ChangeLog b/src/ChangeLog index e15c3e7937f..e5c2c730d56 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2009-07-22 Jason Rumney + + * w32fns.c (w32_wnd_proc) [WM_IME_STARTCOMPOSITION]: Position + IME window at cursor (Bug#2570). + (w32_wnd_proc) [WM_IME_CHAR]: Release context when finished. + (globals_of_w32fns): Dynamically load functions required above. + + * w32term.c (w32_draw_window_cursor): Send message to reposition + any IME window. + 2009-07-21 Chong Yidong * fileio.c: Revert 2009-07-16 changes. diff --git a/src/w32fns.c b/src/w32fns.c index 8ecf3ccb206..8b6c6c21cd2 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -252,6 +252,9 @@ typedef BOOL (WINAPI * TrackMouseEvent_Proc) typedef LONG (WINAPI * ImmGetCompositionString_Proc) (IN HIMC context, IN DWORD index, OUT LPVOID buffer, IN DWORD bufLen); typedef HIMC (WINAPI * ImmGetContext_Proc) (IN HWND window); +typedef HWND (WINAPI * ImmReleaseContext_Proc) (IN HWND wnd, IN HIMC context); +typedef HWND (WINAPI * ImmSetCompositionWindow_Proc) (IN HIMC context, + IN COMPOSITIONFORM *form); typedef HMONITOR (WINAPI * MonitorFromPoint_Proc) (IN POINT pt, IN DWORD flags); typedef BOOL (WINAPI * GetMonitorInfo_Proc) (IN HMONITOR monitor, OUT struct MONITOR_INFO* info); @@ -260,6 +263,8 @@ TrackMouseEvent_Proc track_mouse_event_fn = NULL; ClipboardSequence_Proc clipboard_sequence_fn = NULL; ImmGetCompositionString_Proc get_composition_string_fn = NULL; ImmGetContext_Proc get_ime_context_fn = NULL; +ImmReleaseContext_Proc release_ime_context_fn = NULL; +ImmSetCompositionWindow_Proc set_ime_composition_window_fn = NULL; MonitorFromPoint_Proc monitor_from_point_fn = NULL; GetMonitorInfo_Proc get_monitor_info_fn = NULL; @@ -3158,6 +3163,8 @@ w32_wnd_proc (hwnd, msg, wParam, lParam) buffer = alloca(size); size = get_composition_string_fn (context, GCS_RESULTSTR, buffer, size); + release_ime_context_fn (hwnd, context); + signal_user_input (); for (i = 0; i < size / sizeof (wchar_t); i++) { @@ -3173,6 +3180,40 @@ w32_wnd_proc (hwnd, msg, wParam, lParam) break; + case WM_IME_STARTCOMPOSITION: + if (!set_ime_composition_window_fn) + goto dflt; + else + { + COMPOSITIONFORM form; + HIMC context; + struct window *w; + + if (!context) + break; + + f = x_window_to_frame (dpyinfo, hwnd); + w = XWINDOW (FRAME_SELECTED_WINDOW (f)); + + form.dwStyle = CFS_RECT; + form.ptCurrentPos.x = w32_system_caret_x; + form.ptCurrentPos.y = w32_system_caret_y; + + form.rcArea.left = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, 0); + form.rcArea.top = (WINDOW_TOP_EDGE_Y (w) + + WINDOW_HEADER_LINE_HEIGHT (w)); + form.rcArea.right = (WINDOW_BOX_RIGHT_EDGE_X (w) + - WINDOW_RIGHT_MARGIN_WIDTH (w) + - WINDOW_RIGHT_FRINGE_WIDTH (w)); + form.rcArea.bottom = (WINDOW_BOTTOM_EDGE_Y (w) + - WINDOW_MODE_LINE_HEIGHT (w)); + + context = get_ime_context_fn (hwnd); + set_ime_composition_window_fn (context, &form); + release_ime_context_fn (hwnd, context); + } + break; + case WM_IME_ENDCOMPOSITION: ignore_ime_char = 0; goto dflt; @@ -7278,6 +7319,10 @@ globals_of_w32fns () GetProcAddress (imm32_lib, "ImmGetCompositionStringW"); get_ime_context_fn = (ImmGetContext_Proc) GetProcAddress (imm32_lib, "ImmGetContext"); + release_ime_context_fn = (ImmReleaseContext_Proc) + GetProcAddress (imm32_lib, "ImmReleaseContext"); + set_ime_composition_window_fn = (ImmSetCompositionWindow_Proc) + GetProcAddress (imm32_lib, "ImmSetCompositionWindow"); } DEFVAR_INT ("w32-ansi-code-page", &w32_ansi_code_page, diff --git a/src/w32term.c b/src/w32term.c index dde006bbdef..b7642b46891 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -32,6 +32,7 @@ along with GNU Emacs. If not, see . */ #include #include #include +#include #include "charset.h" #include "character.h" @@ -5128,6 +5129,8 @@ w32_draw_window_cursor (w, glyph_row, x, y, cursor_type, cursor_width, on_p, act = (WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y) + glyph_row->ascent - w->phys_cursor_ascent); + PostMessage (hwnd, WM_IME_STARTCOMPOSITION, 0, 0); + /* If the size of the active cursor changed, destroy the old system caret. */ if (w32_system_caret_hwnd