aboutsummaryrefslogtreecommitdiffstats
path: root/src/w32fns.c
diff options
context:
space:
mode:
authorJason Rumney2009-07-22 16:03:39 +0000
committerJason Rumney2009-07-22 16:03:39 +0000
commitc902b9205ba37aa2db7b9ee855fdca2a13e8076a (patch)
tree8148bf8ada45819a89019da5270455395262b887 /src/w32fns.c
parent855b42a23dff7a633d728da3f8f562500472c89f (diff)
downloademacs-c902b9205ba37aa2db7b9ee855fdca2a13e8076a.tar.gz
emacs-c902b9205ba37aa2db7b9ee855fdca2a13e8076a.zip
* 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.
Diffstat (limited to 'src/w32fns.c')
-rw-r--r--src/w32fns.c45
1 files changed, 45 insertions, 0 deletions
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)
252typedef LONG (WINAPI * ImmGetCompositionString_Proc) 252typedef LONG (WINAPI * ImmGetCompositionString_Proc)
253 (IN HIMC context, IN DWORD index, OUT LPVOID buffer, IN DWORD bufLen); 253 (IN HIMC context, IN DWORD index, OUT LPVOID buffer, IN DWORD bufLen);
254typedef HIMC (WINAPI * ImmGetContext_Proc) (IN HWND window); 254typedef HIMC (WINAPI * ImmGetContext_Proc) (IN HWND window);
255typedef HWND (WINAPI * ImmReleaseContext_Proc) (IN HWND wnd, IN HIMC context);
256typedef HWND (WINAPI * ImmSetCompositionWindow_Proc) (IN HIMC context,
257 IN COMPOSITIONFORM *form);
255typedef HMONITOR (WINAPI * MonitorFromPoint_Proc) (IN POINT pt, IN DWORD flags); 258typedef HMONITOR (WINAPI * MonitorFromPoint_Proc) (IN POINT pt, IN DWORD flags);
256typedef BOOL (WINAPI * GetMonitorInfo_Proc) 259typedef BOOL (WINAPI * GetMonitorInfo_Proc)
257 (IN HMONITOR monitor, OUT struct MONITOR_INFO* info); 260 (IN HMONITOR monitor, OUT struct MONITOR_INFO* info);
@@ -260,6 +263,8 @@ TrackMouseEvent_Proc track_mouse_event_fn = NULL;
260ClipboardSequence_Proc clipboard_sequence_fn = NULL; 263ClipboardSequence_Proc clipboard_sequence_fn = NULL;
261ImmGetCompositionString_Proc get_composition_string_fn = NULL; 264ImmGetCompositionString_Proc get_composition_string_fn = NULL;
262ImmGetContext_Proc get_ime_context_fn = NULL; 265ImmGetContext_Proc get_ime_context_fn = NULL;
266ImmReleaseContext_Proc release_ime_context_fn = NULL;
267ImmSetCompositionWindow_Proc set_ime_composition_window_fn = NULL;
263MonitorFromPoint_Proc monitor_from_point_fn = NULL; 268MonitorFromPoint_Proc monitor_from_point_fn = NULL;
264GetMonitorInfo_Proc get_monitor_info_fn = NULL; 269GetMonitorInfo_Proc get_monitor_info_fn = NULL;
265 270
@@ -3158,6 +3163,8 @@ w32_wnd_proc (hwnd, msg, wParam, lParam)
3158 buffer = alloca(size); 3163 buffer = alloca(size);
3159 size = get_composition_string_fn (context, GCS_RESULTSTR, 3164 size = get_composition_string_fn (context, GCS_RESULTSTR,
3160 buffer, size); 3165 buffer, size);
3166 release_ime_context_fn (hwnd, context);
3167
3161 signal_user_input (); 3168 signal_user_input ();
3162 for (i = 0; i < size / sizeof (wchar_t); i++) 3169 for (i = 0; i < size / sizeof (wchar_t); i++)
3163 { 3170 {
@@ -3173,6 +3180,40 @@ w32_wnd_proc (hwnd, msg, wParam, lParam)
3173 3180
3174 break; 3181 break;
3175 3182
3183 case WM_IME_STARTCOMPOSITION:
3184 if (!set_ime_composition_window_fn)
3185 goto dflt;
3186 else
3187 {
3188 COMPOSITIONFORM form;
3189 HIMC context;
3190 struct window *w;
3191
3192 if (!context)
3193 break;
3194
3195 f = x_window_to_frame (dpyinfo, hwnd);
3196 w = XWINDOW (FRAME_SELECTED_WINDOW (f));
3197
3198 form.dwStyle = CFS_RECT;
3199 form.ptCurrentPos.x = w32_system_caret_x;
3200 form.ptCurrentPos.y = w32_system_caret_y;
3201
3202 form.rcArea.left = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, 0);
3203 form.rcArea.top = (WINDOW_TOP_EDGE_Y (w)
3204 + WINDOW_HEADER_LINE_HEIGHT (w));
3205 form.rcArea.right = (WINDOW_BOX_RIGHT_EDGE_X (w)
3206 - WINDOW_RIGHT_MARGIN_WIDTH (w)
3207 - WINDOW_RIGHT_FRINGE_WIDTH (w));
3208 form.rcArea.bottom = (WINDOW_BOTTOM_EDGE_Y (w)
3209 - WINDOW_MODE_LINE_HEIGHT (w));
3210
3211 context = get_ime_context_fn (hwnd);
3212 set_ime_composition_window_fn (context, &form);
3213 release_ime_context_fn (hwnd, context);
3214 }
3215 break;
3216
3176 case WM_IME_ENDCOMPOSITION: 3217 case WM_IME_ENDCOMPOSITION:
3177 ignore_ime_char = 0; 3218 ignore_ime_char = 0;
3178 goto dflt; 3219 goto dflt;
@@ -7278,6 +7319,10 @@ globals_of_w32fns ()
7278 GetProcAddress (imm32_lib, "ImmGetCompositionStringW"); 7319 GetProcAddress (imm32_lib, "ImmGetCompositionStringW");
7279 get_ime_context_fn = (ImmGetContext_Proc) 7320 get_ime_context_fn = (ImmGetContext_Proc)
7280 GetProcAddress (imm32_lib, "ImmGetContext"); 7321 GetProcAddress (imm32_lib, "ImmGetContext");
7322 release_ime_context_fn = (ImmReleaseContext_Proc)
7323 GetProcAddress (imm32_lib, "ImmReleaseContext");
7324 set_ime_composition_window_fn = (ImmSetCompositionWindow_Proc)
7325 GetProcAddress (imm32_lib, "ImmSetCompositionWindow");
7281 } 7326 }
7282 DEFVAR_INT ("w32-ansi-code-page", 7327 DEFVAR_INT ("w32-ansi-code-page",
7283 &w32_ansi_code_page, 7328 &w32_ansi_code_page,