comparison src/w32fns.c @ 104030:91b945d54645

* 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.
author Jason Rumney <jasonr@gnu.org>
date Wed, 22 Jul 2009 16:03:39 +0000
parents 1867be80e595
children 9cce4a353df7
comparison
equal deleted inserted replaced
104029:55ba5af4bf3a 104030:91b945d54645
250 typedef BOOL (WINAPI * TrackMouseEvent_Proc) 250 typedef BOOL (WINAPI * TrackMouseEvent_Proc)
251 (IN OUT LPTRACKMOUSEEVENT lpEventTrack); 251 (IN OUT LPTRACKMOUSEEVENT lpEventTrack);
252 typedef LONG (WINAPI * ImmGetCompositionString_Proc) 252 typedef 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);
254 typedef HIMC (WINAPI * ImmGetContext_Proc) (IN HWND window); 254 typedef HIMC (WINAPI * ImmGetContext_Proc) (IN HWND window);
255 typedef HWND (WINAPI * ImmReleaseContext_Proc) (IN HWND wnd, IN HIMC context);
256 typedef HWND (WINAPI * ImmSetCompositionWindow_Proc) (IN HIMC context,
257 IN COMPOSITIONFORM *form);
255 typedef HMONITOR (WINAPI * MonitorFromPoint_Proc) (IN POINT pt, IN DWORD flags); 258 typedef HMONITOR (WINAPI * MonitorFromPoint_Proc) (IN POINT pt, IN DWORD flags);
256 typedef BOOL (WINAPI * GetMonitorInfo_Proc) 259 typedef BOOL (WINAPI * GetMonitorInfo_Proc)
257 (IN HMONITOR monitor, OUT struct MONITOR_INFO* info); 260 (IN HMONITOR monitor, OUT struct MONITOR_INFO* info);
258 261
259 TrackMouseEvent_Proc track_mouse_event_fn = NULL; 262 TrackMouseEvent_Proc track_mouse_event_fn = NULL;
260 ClipboardSequence_Proc clipboard_sequence_fn = NULL; 263 ClipboardSequence_Proc clipboard_sequence_fn = NULL;
261 ImmGetCompositionString_Proc get_composition_string_fn = NULL; 264 ImmGetCompositionString_Proc get_composition_string_fn = NULL;
262 ImmGetContext_Proc get_ime_context_fn = NULL; 265 ImmGetContext_Proc get_ime_context_fn = NULL;
266 ImmReleaseContext_Proc release_ime_context_fn = NULL;
267 ImmSetCompositionWindow_Proc set_ime_composition_window_fn = NULL;
263 MonitorFromPoint_Proc monitor_from_point_fn = NULL; 268 MonitorFromPoint_Proc monitor_from_point_fn = NULL;
264 GetMonitorInfo_Proc get_monitor_info_fn = NULL; 269 GetMonitorInfo_Proc get_monitor_info_fn = NULL;
265 270
266 extern AppendMenuW_Proc unicode_append_menu; 271 extern AppendMenuW_Proc unicode_append_menu;
267 272
3156 /* Get buffer size. */ 3161 /* Get buffer size. */
3157 size = get_composition_string_fn (context, GCS_RESULTSTR, buffer, 0); 3162 size = get_composition_string_fn (context, GCS_RESULTSTR, buffer, 0);
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 {
3164 my_post_msg (&wmsg, hwnd, WM_UNICHAR, (WPARAM) buffer[i], 3171 my_post_msg (&wmsg, hwnd, WM_UNICHAR, (WPARAM) buffer[i],
3165 lParam); 3172 lParam);
3169 ignore_ime_char = (size / sizeof (wchar_t)) - 1; 3176 ignore_ime_char = (size / sizeof (wchar_t)) - 1;
3170 } 3177 }
3171 else 3178 else
3172 ignore_ime_char--; 3179 ignore_ime_char--;
3173 3180
3181 break;
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 }
3174 break; 3215 break;
3175 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;
7276 HMODULE imm32_lib = GetModuleHandle ("imm32.dll"); 7317 HMODULE imm32_lib = GetModuleHandle ("imm32.dll");
7277 get_composition_string_fn = (ImmGetCompositionString_Proc) 7318 get_composition_string_fn = (ImmGetCompositionString_Proc)
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,
7284 doc: /* The ANSI code page used by the system. */); 7329 doc: /* The ANSI code page used by the system. */);
7285 w32_ansi_code_page = GetACP (); 7330 w32_ansi_code_page = GetACP ();