+2012-07-30 Eli Zaretskii <eliz@gnu.org>
+
+ * w32fns.c (w32_wnd_proc): Pass w32_keyboard_codepage to
+ w32_kbd_patch_key as the 2nd arg. (Bug#12082)
+
+ * w32term.c <w32_keyboard_codepage>: Renamed from
+ keyboard_codepage and now external. All users changed.
+
+ * w32term.h: Add declaration of w32_keyboard_codepage.
+
+ * 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.
+
2012-07-30 Paul Eggert <eggert@cs.ucla.edu>
Update .PHONY listings in makefiles.
key.uChar.AsciiChar = 0;
key.dwControlKeyState = modifiers;
- add = w32_kbd_patch_key (&key);
+ add = w32_kbd_patch_key (&key, w32_keyboard_codepage);
/* 0 means an unrecognized keycode, negative means
dead key. Ignore both. */
while (--add >= 0)
(hwnd, WM_CHAR,
(unsigned char) key.uChar.AsciiChar, lParam,
w32_get_key_modifiers (wParam, lParam));
- w32_kbd_patch_key (&key);
+ w32_kbd_patch_key (&key, w32_keyboard_codepage);
}
return 0;
}
}
#endif
-/* The return code indicates key code size. */
+/* The return code indicates key code size. cpID is the codepage to
+ use for translation to Unicode; -1 means use the current console
+ input codepage. */
int
-w32_kbd_patch_key (KEY_EVENT_RECORD *event)
+w32_kbd_patch_key (KEY_EVENT_RECORD *event, int cpId)
{
unsigned int key_code = event->wVirtualKeyCode;
unsigned int mods = event->dwControlKeyState;
keystate, buf, 128, 0);
if (isdead > 0)
{
- int cpId = GetConsoleCP ();
+ /* When we are called from the GUI message processing code,
+ we are passed the current keyboard codepage, a positive
+ number, to use below. */
+ if (cpId == -1)
+ cpId = GetConsoleCP ();
event->uChar.UnicodeChar = buf[isdead - 1];
isdead = WideCharToMultiByte (cpId, 0, buf, isdead,
base character (ie. translating the base key plus shift
modifier). */
else if (event->uChar.AsciiChar == 0)
- w32_kbd_patch_key (event);
+ w32_kbd_patch_key (event, -1);
}
if (event->uChar.AsciiChar == 0)
int last_scroll_bar_drag_pos;
+/* Keyboard code page - may be changed by language-change events. */
+int w32_keyboard_codepage;
+
/* Mouse movement. */
/* Where the mouse was last time we reported a mouse event. */
static int input_signal_count;
#endif
-/* Keyboard code page - may be changed by language-change events. */
-static int keyboard_codepage;
-
static void x_update_window_end (struct window *, int, int);
static void w32_handle_tool_bar_click (struct frame *,
struct input_event *);
/* lParam contains the input language ID in its low 16 bits.
Use it to update our record of the keyboard codepage. */
- keyboard_codepage = codepage_for_locale ((LCID)(msg.msg.lParam
- & 0xffff));
+ w32_keyboard_codepage = codepage_for_locale ((LCID)(msg.msg.lParam
+ & 0xffff));
if (f)
{
inev.kind = LANGUAGE_CHANGE_EVENT;
XSETFRAME (inev.frame_or_window, f);
- inev.code = keyboard_codepage;
+ inev.code = w32_keyboard_codepage;
inev.modifiers = msg.msg.lParam & 0xffff;
}
break;
{
dbcs[0] = dbcs_lead;
dbcs_lead = 0;
- if (!MultiByteToWideChar (keyboard_codepage, 0,
+ if (!MultiByteToWideChar (w32_keyboard_codepage, 0,
dbcs, 2, &code, 1))
{
/* Garbage */
break;
}
}
- else if (IsDBCSLeadByteEx (keyboard_codepage,
+ else if (IsDBCSLeadByteEx (w32_keyboard_codepage,
(BYTE) msg.msg.wParam))
{
dbcs_lead = (char) msg.msg.wParam;
}
else
{
- if (!MultiByteToWideChar (keyboard_codepage, 0,
+ if (!MultiByteToWideChar (w32_keyboard_codepage, 0,
&dbcs[1], 1, &code, 1))
{
/* What to do with garbage? */
{
DWORD input_locale_id = (DWORD) GetKeyboardLayout (0);
- keyboard_codepage = codepage_for_locale ((LCID) (input_locale_id & 0xffff));
+ w32_keyboard_codepage =
+ codepage_for_locale ((LCID) (input_locale_id & 0xffff));
}
/* Create the window thread - it will terminate itself when the app
#define RIGHT_WIN_PRESSED 0x4000
#define APPS_PRESSED 0x2000
+/* The current ANSI input codepage for GUI sessions. */
+extern int w32_keyboard_codepage;
+
/* When compiling on Windows 9x/ME and NT 3.x, the following are not defined
(even though they are supported on 98 and ME. */
#ifndef WM_MOUSELEAVE