emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs/src ChangeLog w32term.c


From: Jason Rumney
Subject: [Emacs-diffs] emacs/src ChangeLog w32term.c
Date: Sun, 21 Jun 2009 03:34:21 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Jason Rumney <jasonr>   09/06/21 03:34:21

Modified files:
        src            : ChangeLog w32term.c 

Log message:
        (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.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/src/ChangeLog?cvsroot=emacs&r1=1.7585&r2=1.7586
http://cvs.savannah.gnu.org/viewcvs/emacs/src/w32term.c?cvsroot=emacs&r1=1.324&r2=1.325

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/src/ChangeLog,v
retrieving revision 1.7585
retrieving revision 1.7586
diff -u -b -r1.7585 -r1.7586
--- ChangeLog   20 Jun 2009 23:23:55 -0000      1.7585
+++ ChangeLog   21 Jun 2009 03:34:19 -0000      1.7586
@@ -1,3 +1,12 @@
+2009-06-21  Jason Rumney  <address@hidden>
+
+       * 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  <address@hidden>
 
        * process.c (status_message): Pass Faset index argument as a lisp

Index: w32term.c
===================================================================
RCS file: /sources/emacs/emacs/src/w32term.c,v
retrieving revision 1.324
retrieving revision 1.325
diff -u -b -r1.324 -r1.325
--- w32term.c   19 Apr 2009 15:09:26 -0000      1.324
+++ w32term.c   21 Jun 2009 03:34:20 -0000      1.325
@@ -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;
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]