# HG changeset patch # User Jason Rumney # Date 1245555259 0 # Node ID d0e3ea40717c5b4a2d6c98104885828d69d1793f # Parent 247269056555634d9a3f35d98e5a89bff33a4f02 (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. diff -r 247269056555 -r d0e3ea40717c src/ChangeLog --- a/src/ChangeLog Sun Jun 21 01:39:43 2009 +0000 +++ b/src/ChangeLog Sun Jun 21 03:34:19 2009 +0000 @@ -1,3 +1,12 @@ +2009-06-21 Jason Rumney + + * w32term.c (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. + 2009-06-20 Ken Raeburn * process.c (status_message): Pass Faset index argument as a lisp diff -r 247269056555 -r d0e3ea40717c src/w32term.c --- a/src/w32term.c Sun Jun 21 01:39:43 2009 +0000 +++ b/src/w32term.c Sun Jun 21 03:34:19 2009 +0000 @@ -180,7 +180,6 @@ /* Mouse movement. */ /* Where the mouse was last time we reported a mouse event. */ - static RECT last_mouse_glyph; static FRAME_PTR last_mouse_glyph_frame; static Lisp_Object last_mouse_press_frame; @@ -215,12 +214,10 @@ along with the position query. So, we just keep track of the time of the last movement we received, and return that in hopes that it's somewhat accurate. */ - static Time last_mouse_movement_time; /* Incremented by w32_read_socket whenever it really tries to read events. */ - #ifdef __STDC__ static int volatile input_signal_count; #else @@ -234,9 +231,11 @@ #endif /* A mask of extra modifier bits to put into every keyboard char. */ - extern EMACS_INT extra_keyboard_modifiers; +/* Keyboard code page - may be changed by language-change events. */ +static int keyboard_codepage; + static void x_update_window_end P_ ((struct window *, int, int)); static void w32_handle_tool_bar_click P_ ((struct frame *, struct input_event *)); @@ -2908,6 +2907,15 @@ return value; } +static int codepage_for_locale(LCID locale) +{ + char cp[20]; + + if (GetLocaleInfo (locale, LOCALE_IDEFAULTANSICODEPAGE, cp, 20) > 0) + return atoi (cp); + else + return CP_ACP; +} /* Mouse clicks and mouse movement. Rah. */ @@ -4160,6 +4168,11 @@ /* Generate a language change event. */ f = x_window_to_frame (dpyinfo, msg.msg.hwnd); + /* lParam contains the input lang ID. Use it to update our + record of the keyboard codepage. */ + keyboard_codepage = codepage_for_locale ((LCID)(msg.msg.lParam + & 0xffff)); + if (f) { inev.kind = LANGUAGE_CHANGE_EVENT; @@ -4230,7 +4243,8 @@ { dbcs[0] = dbcs_lead; dbcs_lead = 0; - if (!MultiByteToWideChar (CP_ACP, 0, dbcs, 2, &code, 1)) + if (!MultiByteToWideChar (keyboard_codepage, 0, + dbcs, 2, &code, 1)) { /* Garbage */ DebPrint (("Invalid DBCS sequence: %d %d\n", @@ -4239,7 +4253,8 @@ break; } } - else if (IsDBCSLeadByteEx (CP_ACP, (BYTE) msg.msg.wParam)) + else if (IsDBCSLeadByteEx (keyboard_codepage, + (BYTE) msg.msg.wParam)) { dbcs_lead = (char) msg.msg.wParam; inev.kind = NO_EVENT; @@ -4247,8 +4262,8 @@ } else { - if (!MultiByteToWideChar (CP_ACP, 0, &dbcs[1], 1, - &code, 1)) + if (!MultiByteToWideChar (keyboard_codepage, 0, + &dbcs[1], 1, &code, 1)) { /* What to do with garbage? */ DebPrint (("Invalid character: %d\n", dbcs[1])); @@ -6345,8 +6360,13 @@ 8 bit character input, standard quit char. */ Fset_input_mode (Qnil, Qnil, make_number (2), Qnil); - /* Create the window thread - it will terminate itself or when the app terminates */ - + { + HKL input_locale_id = GetKeyboardLayout (0); + keyboard_codepage = codepage_for_locale (input_locale_id & 0xffff); + } + + /* Create the window thread - it will terminate itself when the app + terminates */ init_crit (); dwMainThreadId = GetCurrentThreadId (); @@ -6354,7 +6374,6 @@ GetCurrentProcess (), &hMainThread, 0, TRUE, DUPLICATE_SAME_ACCESS); /* Wait for thread to start */ - { MSG msg;