comparison src/w32term.c @ 103500:d0e3ea40717c EMACS_23_1_BASE

(keyboard_codepage): New static variable. (w32_read_socket) [WM_INPUTLANGCHANGE]: Update it. (w32_read_socket) [WM_CHAR]: Use it to decode character input (bug#3237). (w32_initialize): Initialize it. (codepage_for_locale): New function.
author Jason Rumney <jasonr@gnu.org>
date Sun, 21 Jun 2009 03:34:19 +0000
parents 30ed0fca4cdd
children b1792516bf99
comparison
equal deleted inserted replaced
103499:247269056555 103500:d0e3ea40717c
178 int last_scroll_bar_drag_pos; 178 int last_scroll_bar_drag_pos;
179 179
180 /* Mouse movement. */ 180 /* Mouse movement. */
181 181
182 /* Where the mouse was last time we reported a mouse event. */ 182 /* Where the mouse was last time we reported a mouse event. */
183
184 static RECT last_mouse_glyph; 183 static RECT last_mouse_glyph;
185 static FRAME_PTR last_mouse_glyph_frame; 184 static FRAME_PTR last_mouse_glyph_frame;
186 static Lisp_Object last_mouse_press_frame; 185 static Lisp_Object last_mouse_press_frame;
187 186
188 int w32_num_mouse_buttons; 187 int w32_num_mouse_buttons;
213 return the time associated with the position it returns, but there 212 return the time associated with the position it returns, but there
214 doesn't seem to be any way to wrest the time-stamp from the server 213 doesn't seem to be any way to wrest the time-stamp from the server
215 along with the position query. So, we just keep track of the time 214 along with the position query. So, we just keep track of the time
216 of the last movement we received, and return that in hopes that 215 of the last movement we received, and return that in hopes that
217 it's somewhat accurate. */ 216 it's somewhat accurate. */
218
219 static Time last_mouse_movement_time; 217 static Time last_mouse_movement_time;
220 218
221 /* Incremented by w32_read_socket whenever it really tries to read 219 /* Incremented by w32_read_socket whenever it really tries to read
222 events. */ 220 events. */
223
224 #ifdef __STDC__ 221 #ifdef __STDC__
225 static int volatile input_signal_count; 222 static int volatile input_signal_count;
226 #else 223 #else
227 static int input_signal_count; 224 static int input_signal_count;
228 #endif 225 #endif
232 #ifndef USE_CRT_DLL 229 #ifndef USE_CRT_DLL
233 extern int errno; 230 extern int errno;
234 #endif 231 #endif
235 232
236 /* A mask of extra modifier bits to put into every keyboard char. */ 233 /* A mask of extra modifier bits to put into every keyboard char. */
237
238 extern EMACS_INT extra_keyboard_modifiers; 234 extern EMACS_INT extra_keyboard_modifiers;
235
236 /* Keyboard code page - may be changed by language-change events. */
237 static int keyboard_codepage;
239 238
240 static void x_update_window_end P_ ((struct window *, int, int)); 239 static void x_update_window_end P_ ((struct window *, int, int));
241 static void w32_handle_tool_bar_click P_ ((struct frame *, 240 static void w32_handle_tool_bar_click P_ ((struct frame *,
242 struct input_event *)); 241 struct input_event *));
243 static void w32_define_cursor P_ ((Window, Cursor)); 242 static void w32_define_cursor P_ ((Window, Cursor));
2906 UNBLOCK_INPUT; 2905 UNBLOCK_INPUT;
2907 2906
2908 return value; 2907 return value;
2909 } 2908 }
2910 2909
2910 static int codepage_for_locale(LCID locale)
2911 {
2912 char cp[20];
2913
2914 if (GetLocaleInfo (locale, LOCALE_IDEFAULTANSICODEPAGE, cp, 20) > 0)
2915 return atoi (cp);
2916 else
2917 return CP_ACP;
2918 }
2911 2919
2912 2920
2913 /* Mouse clicks and mouse movement. Rah. */ 2921 /* Mouse clicks and mouse movement. Rah. */
2914 2922
2915 /* Parse a button MESSAGE. The button index is returned in PBUTTON, and 2923 /* Parse a button MESSAGE. The button index is returned in PBUTTON, and
4158 4166
4159 case WM_INPUTLANGCHANGE: 4167 case WM_INPUTLANGCHANGE:
4160 /* Generate a language change event. */ 4168 /* Generate a language change event. */
4161 f = x_window_to_frame (dpyinfo, msg.msg.hwnd); 4169 f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
4162 4170
4171 /* lParam contains the input lang ID. Use it to update our
4172 record of the keyboard codepage. */
4173 keyboard_codepage = codepage_for_locale ((LCID)(msg.msg.lParam
4174 & 0xffff));
4175
4163 if (f) 4176 if (f)
4164 { 4177 {
4165 inev.kind = LANGUAGE_CHANGE_EVENT; 4178 inev.kind = LANGUAGE_CHANGE_EVENT;
4166 XSETFRAME (inev.frame_or_window, f); 4179 XSETFRAME (inev.frame_or_window, f);
4167 inev.code = msg.msg.wParam; 4180 inev.code = msg.msg.wParam;
4228 4241
4229 if (dbcs_lead) 4242 if (dbcs_lead)
4230 { 4243 {
4231 dbcs[0] = dbcs_lead; 4244 dbcs[0] = dbcs_lead;
4232 dbcs_lead = 0; 4245 dbcs_lead = 0;
4233 if (!MultiByteToWideChar (CP_ACP, 0, dbcs, 2, &code, 1)) 4246 if (!MultiByteToWideChar (keyboard_codepage, 0,
4247 dbcs, 2, &code, 1))
4234 { 4248 {
4235 /* Garbage */ 4249 /* Garbage */
4236 DebPrint (("Invalid DBCS sequence: %d %d\n", 4250 DebPrint (("Invalid DBCS sequence: %d %d\n",
4237 dbcs[0], dbcs[1])); 4251 dbcs[0], dbcs[1]));
4238 inev.kind = NO_EVENT; 4252 inev.kind = NO_EVENT;
4239 break; 4253 break;
4240 } 4254 }
4241 } 4255 }
4242 else if (IsDBCSLeadByteEx (CP_ACP, (BYTE) msg.msg.wParam)) 4256 else if (IsDBCSLeadByteEx (keyboard_codepage,
4257 (BYTE) msg.msg.wParam))
4243 { 4258 {
4244 dbcs_lead = (char) msg.msg.wParam; 4259 dbcs_lead = (char) msg.msg.wParam;
4245 inev.kind = NO_EVENT; 4260 inev.kind = NO_EVENT;
4246 break; 4261 break;
4247 } 4262 }
4248 else 4263 else
4249 { 4264 {
4250 if (!MultiByteToWideChar (CP_ACP, 0, &dbcs[1], 1, 4265 if (!MultiByteToWideChar (keyboard_codepage, 0,
4251 &code, 1)) 4266 &dbcs[1], 1, &code, 1))
4252 { 4267 {
4253 /* What to do with garbage? */ 4268 /* What to do with garbage? */
4254 DebPrint (("Invalid character: %d\n", dbcs[1])); 4269 DebPrint (("Invalid character: %d\n", dbcs[1]));
4255 inev.kind = NO_EVENT; 4270 inev.kind = NO_EVENT;
4256 break; 4271 break;
6343 6358
6344 /* Initialize input mode: interrupt_input off, no flow control, allow 6359 /* Initialize input mode: interrupt_input off, no flow control, allow
6345 8 bit character input, standard quit char. */ 6360 8 bit character input, standard quit char. */
6346 Fset_input_mode (Qnil, Qnil, make_number (2), Qnil); 6361 Fset_input_mode (Qnil, Qnil, make_number (2), Qnil);
6347 6362
6348 /* Create the window thread - it will terminate itself or when the app terminates */ 6363 {
6349 6364 HKL input_locale_id = GetKeyboardLayout (0);
6365 keyboard_codepage = codepage_for_locale (input_locale_id & 0xffff);
6366 }
6367
6368 /* Create the window thread - it will terminate itself when the app
6369 terminates */
6350 init_crit (); 6370 init_crit ();
6351 6371
6352 dwMainThreadId = GetCurrentThreadId (); 6372 dwMainThreadId = GetCurrentThreadId ();
6353 DuplicateHandle (GetCurrentProcess (), GetCurrentThread (), 6373 DuplicateHandle (GetCurrentProcess (), GetCurrentThread (),
6354 GetCurrentProcess (), &hMainThread, 0, TRUE, DUPLICATE_SAME_ACCESS); 6374 GetCurrentProcess (), &hMainThread, 0, TRUE, DUPLICATE_SAME_ACCESS);
6355 6375
6356 /* Wait for thread to start */ 6376 /* Wait for thread to start */
6357
6358 { 6377 {
6359 MSG msg; 6378 MSG msg;
6360 6379
6361 PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE); 6380 PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE);
6362 6381