diff options
| author | Eli Zaretskii | 2012-07-30 20:07:33 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2012-07-30 20:07:33 +0300 |
| commit | 302fc036e8b6305a45aca868e0001dd8fb3ed123 (patch) | |
| tree | ecd4e1e272b80fa0751e124393700793e7c02a59 /src | |
| parent | 0aee69126fd23d3b86fae5e4812b62bbe7c59b27 (diff) | |
| download | emacs-302fc036e8b6305a45aca868e0001dd8fb3ed123.tar.gz emacs-302fc036e8b6305a45aca868e0001dd8fb3ed123.zip | |
Fix bug #12082 with input of Meta-non-ASCII-characters on MS-Windows.
src/w32fns.c (w32_wnd_proc): Pass w32_keyboard_codepage to
w32_kbd_patch_key as the 2nd arg.
src/w32term.c <w32_keyboard_codepage>: Renamed from
keyboard_codepage and now external. All users changed.
src/w32term.h: Add declaration of w32_keyboard_codepage.
src/w32inevt.c (w32_kbd_patch_key): Accept an additional argument --
the codepage to translate keys to Unicode. If this argument is
-1, use the value returned by GetConsoleCP. All callers changed.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 14 | ||||
| -rw-r--r-- | src/w32fns.c | 4 | ||||
| -rw-r--r-- | src/w32inevt.c | 14 | ||||
| -rw-r--r-- | src/w32term.c | 21 | ||||
| -rw-r--r-- | src/w32term.h | 3 |
5 files changed, 40 insertions, 16 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 792dc10f88c..be60f3d22b3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,17 @@ | |||
| 1 | 2012-07-30 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * w32fns.c (w32_wnd_proc): Pass w32_keyboard_codepage to | ||
| 4 | w32_kbd_patch_key as the 2nd arg. (Bug#12082) | ||
| 5 | |||
| 6 | * w32term.c <w32_keyboard_codepage>: Renamed from | ||
| 7 | keyboard_codepage and now external. All users changed. | ||
| 8 | |||
| 9 | * w32term.h: Add declaration of w32_keyboard_codepage. | ||
| 10 | |||
| 11 | * w32inevt.c (w32_kbd_patch_key): Accept an additional argument -- | ||
| 12 | the codepage to translate keys to Unicode. If this argument is | ||
| 13 | -1, use the value returned by GetConsoleCP. All callers changed. | ||
| 14 | |||
| 1 | 2012-07-30 Paul Eggert <eggert@cs.ucla.edu> | 15 | 2012-07-30 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 16 | ||
| 3 | Update .PHONY listings in makefiles. | 17 | Update .PHONY listings in makefiles. |
diff --git a/src/w32fns.c b/src/w32fns.c index 97b7001a3fa..91744e2691f 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -2882,7 +2882,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) | |||
| 2882 | key.uChar.AsciiChar = 0; | 2882 | key.uChar.AsciiChar = 0; |
| 2883 | key.dwControlKeyState = modifiers; | 2883 | key.dwControlKeyState = modifiers; |
| 2884 | 2884 | ||
| 2885 | add = w32_kbd_patch_key (&key); | 2885 | add = w32_kbd_patch_key (&key, w32_keyboard_codepage); |
| 2886 | /* 0 means an unrecognized keycode, negative means | 2886 | /* 0 means an unrecognized keycode, negative means |
| 2887 | dead key. Ignore both. */ | 2887 | dead key. Ignore both. */ |
| 2888 | while (--add >= 0) | 2888 | while (--add >= 0) |
| @@ -2892,7 +2892,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) | |||
| 2892 | (hwnd, WM_CHAR, | 2892 | (hwnd, WM_CHAR, |
| 2893 | (unsigned char) key.uChar.AsciiChar, lParam, | 2893 | (unsigned char) key.uChar.AsciiChar, lParam, |
| 2894 | w32_get_key_modifiers (wParam, lParam)); | 2894 | w32_get_key_modifiers (wParam, lParam)); |
| 2895 | w32_kbd_patch_key (&key); | 2895 | w32_kbd_patch_key (&key, w32_keyboard_codepage); |
| 2896 | } | 2896 | } |
| 2897 | return 0; | 2897 | return 0; |
| 2898 | } | 2898 | } |
diff --git a/src/w32inevt.c b/src/w32inevt.c index 6d869727d2f..731dd6715dc 100644 --- a/src/w32inevt.c +++ b/src/w32inevt.c | |||
| @@ -185,9 +185,11 @@ is_dead_key (int wparam) | |||
| 185 | } | 185 | } |
| 186 | #endif | 186 | #endif |
| 187 | 187 | ||
| 188 | /* The return code indicates key code size. */ | 188 | /* The return code indicates key code size. cpID is the codepage to |
| 189 | use for translation to Unicode; -1 means use the current console | ||
| 190 | input codepage. */ | ||
| 189 | int | 191 | int |
| 190 | w32_kbd_patch_key (KEY_EVENT_RECORD *event) | 192 | w32_kbd_patch_key (KEY_EVENT_RECORD *event, int cpId) |
| 191 | { | 193 | { |
| 192 | unsigned int key_code = event->wVirtualKeyCode; | 194 | unsigned int key_code = event->wVirtualKeyCode; |
| 193 | unsigned int mods = event->dwControlKeyState; | 195 | unsigned int mods = event->dwControlKeyState; |
| @@ -243,7 +245,11 @@ w32_kbd_patch_key (KEY_EVENT_RECORD *event) | |||
| 243 | keystate, buf, 128, 0); | 245 | keystate, buf, 128, 0); |
| 244 | if (isdead > 0) | 246 | if (isdead > 0) |
| 245 | { | 247 | { |
| 246 | int cpId = GetConsoleCP (); | 248 | /* When we are called from the GUI message processing code, |
| 249 | we are passed the current keyboard codepage, a positive | ||
| 250 | number, to use below. */ | ||
| 251 | if (cpId == -1) | ||
| 252 | cpId = GetConsoleCP (); | ||
| 247 | 253 | ||
| 248 | event->uChar.UnicodeChar = buf[isdead - 1]; | 254 | event->uChar.UnicodeChar = buf[isdead - 1]; |
| 249 | isdead = WideCharToMultiByte (cpId, 0, buf, isdead, | 255 | isdead = WideCharToMultiByte (cpId, 0, buf, isdead, |
| @@ -442,7 +448,7 @@ key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev, int *isdead) | |||
| 442 | base character (ie. translating the base key plus shift | 448 | base character (ie. translating the base key plus shift |
| 443 | modifier). */ | 449 | modifier). */ |
| 444 | else if (event->uChar.AsciiChar == 0) | 450 | else if (event->uChar.AsciiChar == 0) |
| 445 | w32_kbd_patch_key (event); | 451 | w32_kbd_patch_key (event, -1); |
| 446 | } | 452 | } |
| 447 | 453 | ||
| 448 | if (event->uChar.AsciiChar == 0) | 454 | if (event->uChar.AsciiChar == 0) |
diff --git a/src/w32term.c b/src/w32term.c index f02d101cea3..7c4860d5139 100644 --- a/src/w32term.c +++ b/src/w32term.c | |||
| @@ -155,6 +155,9 @@ int vertical_scroll_bar_bottom_border; | |||
| 155 | 155 | ||
| 156 | int last_scroll_bar_drag_pos; | 156 | int last_scroll_bar_drag_pos; |
| 157 | 157 | ||
| 158 | /* Keyboard code page - may be changed by language-change events. */ | ||
| 159 | int w32_keyboard_codepage; | ||
| 160 | |||
| 158 | /* Mouse movement. */ | 161 | /* Mouse movement. */ |
| 159 | 162 | ||
| 160 | /* Where the mouse was last time we reported a mouse event. */ | 163 | /* Where the mouse was last time we reported a mouse event. */ |
| @@ -188,9 +191,6 @@ static int volatile input_signal_count; | |||
| 188 | static int input_signal_count; | 191 | static int input_signal_count; |
| 189 | #endif | 192 | #endif |
| 190 | 193 | ||
| 191 | /* Keyboard code page - may be changed by language-change events. */ | ||
| 192 | static int keyboard_codepage; | ||
| 193 | |||
| 194 | static void x_update_window_end (struct window *, int, int); | 194 | static void x_update_window_end (struct window *, int, int); |
| 195 | static void w32_handle_tool_bar_click (struct frame *, | 195 | static void w32_handle_tool_bar_click (struct frame *, |
| 196 | struct input_event *); | 196 | struct input_event *); |
| @@ -4235,14 +4235,14 @@ w32_read_socket (struct terminal *terminal, int expected, | |||
| 4235 | 4235 | ||
| 4236 | /* lParam contains the input language ID in its low 16 bits. | 4236 | /* lParam contains the input language ID in its low 16 bits. |
| 4237 | Use it to update our record of the keyboard codepage. */ | 4237 | Use it to update our record of the keyboard codepage. */ |
| 4238 | keyboard_codepage = codepage_for_locale ((LCID)(msg.msg.lParam | 4238 | w32_keyboard_codepage = codepage_for_locale ((LCID)(msg.msg.lParam |
| 4239 | & 0xffff)); | 4239 | & 0xffff)); |
| 4240 | 4240 | ||
| 4241 | if (f) | 4241 | if (f) |
| 4242 | { | 4242 | { |
| 4243 | inev.kind = LANGUAGE_CHANGE_EVENT; | 4243 | inev.kind = LANGUAGE_CHANGE_EVENT; |
| 4244 | XSETFRAME (inev.frame_or_window, f); | 4244 | XSETFRAME (inev.frame_or_window, f); |
| 4245 | inev.code = keyboard_codepage; | 4245 | inev.code = w32_keyboard_codepage; |
| 4246 | inev.modifiers = msg.msg.lParam & 0xffff; | 4246 | inev.modifiers = msg.msg.lParam & 0xffff; |
| 4247 | } | 4247 | } |
| 4248 | break; | 4248 | break; |
| @@ -4308,7 +4308,7 @@ w32_read_socket (struct terminal *terminal, int expected, | |||
| 4308 | { | 4308 | { |
| 4309 | dbcs[0] = dbcs_lead; | 4309 | dbcs[0] = dbcs_lead; |
| 4310 | dbcs_lead = 0; | 4310 | dbcs_lead = 0; |
| 4311 | if (!MultiByteToWideChar (keyboard_codepage, 0, | 4311 | if (!MultiByteToWideChar (w32_keyboard_codepage, 0, |
| 4312 | dbcs, 2, &code, 1)) | 4312 | dbcs, 2, &code, 1)) |
| 4313 | { | 4313 | { |
| 4314 | /* Garbage */ | 4314 | /* Garbage */ |
| @@ -4318,7 +4318,7 @@ w32_read_socket (struct terminal *terminal, int expected, | |||
| 4318 | break; | 4318 | break; |
| 4319 | } | 4319 | } |
| 4320 | } | 4320 | } |
| 4321 | else if (IsDBCSLeadByteEx (keyboard_codepage, | 4321 | else if (IsDBCSLeadByteEx (w32_keyboard_codepage, |
| 4322 | (BYTE) msg.msg.wParam)) | 4322 | (BYTE) msg.msg.wParam)) |
| 4323 | { | 4323 | { |
| 4324 | dbcs_lead = (char) msg.msg.wParam; | 4324 | dbcs_lead = (char) msg.msg.wParam; |
| @@ -4327,7 +4327,7 @@ w32_read_socket (struct terminal *terminal, int expected, | |||
| 4327 | } | 4327 | } |
| 4328 | else | 4328 | else |
| 4329 | { | 4329 | { |
| 4330 | if (!MultiByteToWideChar (keyboard_codepage, 0, | 4330 | if (!MultiByteToWideChar (w32_keyboard_codepage, 0, |
| 4331 | &dbcs[1], 1, &code, 1)) | 4331 | &dbcs[1], 1, &code, 1)) |
| 4332 | { | 4332 | { |
| 4333 | /* What to do with garbage? */ | 4333 | /* What to do with garbage? */ |
| @@ -6426,7 +6426,8 @@ w32_initialize (void) | |||
| 6426 | 6426 | ||
| 6427 | { | 6427 | { |
| 6428 | DWORD input_locale_id = (DWORD) GetKeyboardLayout (0); | 6428 | DWORD input_locale_id = (DWORD) GetKeyboardLayout (0); |
| 6429 | keyboard_codepage = codepage_for_locale ((LCID) (input_locale_id & 0xffff)); | 6429 | w32_keyboard_codepage = |
| 6430 | codepage_for_locale ((LCID) (input_locale_id & 0xffff)); | ||
| 6430 | } | 6431 | } |
| 6431 | 6432 | ||
| 6432 | /* Create the window thread - it will terminate itself when the app | 6433 | /* Create the window thread - it will terminate itself when the app |
diff --git a/src/w32term.h b/src/w32term.h index b49104dde8b..c0a958ba5e5 100644 --- a/src/w32term.h +++ b/src/w32term.h | |||
| @@ -667,6 +667,9 @@ extern void x_delete_display (struct w32_display_info *dpyinfo); | |||
| 667 | #define RIGHT_WIN_PRESSED 0x4000 | 667 | #define RIGHT_WIN_PRESSED 0x4000 |
| 668 | #define APPS_PRESSED 0x2000 | 668 | #define APPS_PRESSED 0x2000 |
| 669 | 669 | ||
| 670 | /* The current ANSI input codepage for GUI sessions. */ | ||
| 671 | extern int w32_keyboard_codepage; | ||
| 672 | |||
| 670 | /* When compiling on Windows 9x/ME and NT 3.x, the following are not defined | 673 | /* When compiling on Windows 9x/ME and NT 3.x, the following are not defined |
| 671 | (even though they are supported on 98 and ME. */ | 674 | (even though they are supported on 98 and ME. */ |
| 672 | #ifndef WM_MOUSELEAVE | 675 | #ifndef WM_MOUSELEAVE |