]> code.delx.au - gnu-emacs/commitdiff
Fix bug #12082 with input of Meta-non-ASCII-characters on MS-Windows.
authorEli Zaretskii <eliz@gnu.org>
Mon, 30 Jul 2012 17:07:33 +0000 (20:07 +0300)
committerEli Zaretskii <eliz@gnu.org>
Mon, 30 Jul 2012 17:07:33 +0000 (20:07 +0300)
 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.

src/ChangeLog
src/w32fns.c
src/w32inevt.c
src/w32term.c
src/w32term.h

index 792dc10f88c8d4bed2bdae2aaadef427541660e8..be60f3d22b318e954a5a64b21a3205ff7aeb1106 100644 (file)
@@ -1,3 +1,17 @@
+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.
index 97b7001a3faf69bea0154317fb13399484ac2ec9..91744e2691f3cc835d3afec1b471a97a546175a0 100644 (file)
@@ -2882,7 +2882,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
                      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)
@@ -2892,7 +2892,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
                            (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;
                    }
index 6d869727d2f5755ad58b43a197fa76c999c4c4e4..731dd6715dc241d0af4ec28eee2b97934c602c3e 100644 (file)
@@ -185,9 +185,11 @@ is_dead_key (int wparam)
 }
 #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;
@@ -243,7 +245,11 @@ w32_kbd_patch_key (KEY_EVENT_RECORD *event)
                          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,
@@ -442,7 +448,7 @@ key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev, int *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)
index f02d101cea39a17deaf19664634919739b527869..7c4860d51393cd4dd71ee79daf6f2e8687535a0c 100644 (file)
@@ -155,6 +155,9 @@ int vertical_scroll_bar_bottom_border;
 
 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.  */
@@ -188,9 +191,6 @@ static int volatile input_signal_count;
 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 *);
@@ -4235,14 +4235,14 @@ w32_read_socket (struct terminal *terminal, int expected,
 
          /* 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;
@@ -4308,7 +4308,7 @@ w32_read_socket (struct terminal *terminal, int expected,
                     {
                       dbcs[0] = dbcs_lead;
                       dbcs_lead = 0;
-                      if (!MultiByteToWideChar (keyboard_codepage, 0,
+                      if (!MultiByteToWideChar (w32_keyboard_codepage, 0,
                                                dbcs, 2, &code, 1))
                         {
                           /* Garbage */
@@ -4318,7 +4318,7 @@ w32_read_socket (struct terminal *terminal, int expected,
                           break;
                         }
                     }
-                  else if (IsDBCSLeadByteEx (keyboard_codepage,
+                  else if (IsDBCSLeadByteEx (w32_keyboard_codepage,
                                             (BYTE) msg.msg.wParam))
                     {
                       dbcs_lead = (char) msg.msg.wParam;
@@ -4327,7 +4327,7 @@ w32_read_socket (struct terminal *terminal, int expected,
                     }
                   else
                     {
-                      if (!MultiByteToWideChar (keyboard_codepage, 0,
+                      if (!MultiByteToWideChar (w32_keyboard_codepage, 0,
                                                &dbcs[1], 1, &code, 1))
                         {
                           /* What to do with garbage? */
@@ -6426,7 +6426,8 @@ w32_initialize (void)
 
   {
     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
index b49104dde8b3682e7aafbcb3d5d3f2e9a76ecdba..c0a958ba5e5f2150cb059a570e7c868fc8fdeaf7 100644 (file)
@@ -667,6 +667,9 @@ extern void x_delete_display (struct w32_display_info *dpyinfo);
 #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