aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Rumney2009-06-21 03:34:19 +0000
committerJason Rumney2009-06-21 03:34:19 +0000
commit13087e59257ca4b90aa93dfa2b5cee6a50e6df5b (patch)
tree59494c5dab4379865f7725ad94245cc01deb6f90
parentc4ea8f00497998895c170cafbdfb42aedf678a3a (diff)
downloademacs-13087e59257ca4b90aa93dfa2b5cee6a50e6df5b.tar.gz
emacs-13087e59257ca4b90aa93dfa2b5cee6a50e6df5b.zip
(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.
-rw-r--r--src/ChangeLog9
-rw-r--r--src/w32term.c39
2 files changed, 38 insertions, 10 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 4ae24ee851c..840a0b7b1f6 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
12009-06-21 Jason Rumney <jasonr@gnu.org>
2
3 * w32term.c (keyboard_codepage): New static variable.
4 (w32_read_socket) [WM_INPUTLANGCHANGE]: Update it.
5 (w32_read_socket) [WM_CHAR]: Use it to decode character
6 input (bug#3237).
7 (w32_initialize): Initialize it.
8 (codepage_for_locale): New function.
9
12009-06-20 Ken Raeburn <raeburn@raeburn.org> 102009-06-20 Ken Raeburn <raeburn@raeburn.org>
2 11
3 * process.c (status_message): Pass Faset index argument as a lisp 12 * process.c (status_message): Pass Faset index argument as a lisp
diff --git a/src/w32term.c b/src/w32term.c
index f38895b6312..b24da6cad5e 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -180,7 +180,6 @@ int last_scroll_bar_drag_pos;
180/* Mouse movement. */ 180/* Mouse movement. */
181 181
182/* Where the mouse was last time we reported a mouse event. */ 182/* Where the mouse was last time we reported a mouse event. */
183
184static RECT last_mouse_glyph; 183static RECT last_mouse_glyph;
185static FRAME_PTR last_mouse_glyph_frame; 184static FRAME_PTR last_mouse_glyph_frame;
186static Lisp_Object last_mouse_press_frame; 185static Lisp_Object last_mouse_press_frame;
@@ -215,12 +214,10 @@ static int last_mouse_scroll_bar_pos;
215 along with the position query. So, we just keep track of the time 214 along with the position query. So, we just keep track of the time
216 of the last movement we received, and return that in hopes that 215 of the last movement we received, and return that in hopes that
217 it's somewhat accurate. */ 216 it's somewhat accurate. */
218
219static Time last_mouse_movement_time; 217static Time last_mouse_movement_time;
220 218
221/* Incremented by w32_read_socket whenever it really tries to read 219/* Incremented by w32_read_socket whenever it really tries to read
222 events. */ 220 events. */
223
224#ifdef __STDC__ 221#ifdef __STDC__
225static int volatile input_signal_count; 222static int volatile input_signal_count;
226#else 223#else
@@ -234,9 +231,11 @@ extern int errno;
234#endif 231#endif
235 232
236/* A mask of extra modifier bits to put into every keyboard char. */ 233/* A mask of extra modifier bits to put into every keyboard char. */
237
238extern EMACS_INT extra_keyboard_modifiers; 234extern EMACS_INT extra_keyboard_modifiers;
239 235
236/* Keyboard code page - may be changed by language-change events. */
237static int keyboard_codepage;
238
240static void x_update_window_end P_ ((struct window *, int, int)); 239static void x_update_window_end P_ ((struct window *, int, int));
241static void w32_handle_tool_bar_click P_ ((struct frame *, 240static void w32_handle_tool_bar_click P_ ((struct frame *,
242 struct input_event *)); 241 struct input_event *));
@@ -2908,6 +2907,15 @@ x_get_keysym_name (keysym)
2908 return value; 2907 return value;
2909} 2908}
2910 2909
2910static int codepage_for_locale(LCID locale)
2911{
2912 char cp[20];
2913
2914 if (GetLocaleInfo (locale, LOCALE_IDEFAULTANSICODEPAGE, cp, 20) > 0)
2915 return atoi (cp);
2916 else
2917 return CP_ACP;
2918}
2911 2919
2912 2920
2913/* Mouse clicks and mouse movement. Rah. */ 2921/* Mouse clicks and mouse movement. Rah. */
@@ -4160,6 +4168,11 @@ w32_read_socket (sd, expected, hold_quit)
4160 /* Generate a language change event. */ 4168 /* Generate a language change event. */
4161 f = x_window_to_frame (dpyinfo, msg.msg.hwnd); 4169 f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
4162 4170
4171 /* lParam contains the input lang ID. Use it to update our
4172 record of the keyboard codepage. */
4173 keyboard_codepage = codepage_for_locale ((LCID)(msg.msg.lParam
4174 & 0xffff));
4175
4163 if (f) 4176 if (f)
4164 { 4177 {
4165 inev.kind = LANGUAGE_CHANGE_EVENT; 4178 inev.kind = LANGUAGE_CHANGE_EVENT;
@@ -4230,7 +4243,8 @@ w32_read_socket (sd, expected, hold_quit)
4230 { 4243 {
4231 dbcs[0] = dbcs_lead; 4244 dbcs[0] = dbcs_lead;
4232 dbcs_lead = 0; 4245 dbcs_lead = 0;
4233 if (!MultiByteToWideChar (CP_ACP, 0, dbcs, 2, &code, 1)) 4246 if (!MultiByteToWideChar (keyboard_codepage, 0,
4247 dbcs, 2, &code, 1))
4234 { 4248 {
4235 /* Garbage */ 4249 /* Garbage */
4236 DebPrint (("Invalid DBCS sequence: %d %d\n", 4250 DebPrint (("Invalid DBCS sequence: %d %d\n",
@@ -4239,7 +4253,8 @@ w32_read_socket (sd, expected, hold_quit)
4239 break; 4253 break;
4240 } 4254 }
4241 } 4255 }
4242 else if (IsDBCSLeadByteEx (CP_ACP, (BYTE) msg.msg.wParam)) 4256 else if (IsDBCSLeadByteEx (keyboard_codepage,
4257 (BYTE) msg.msg.wParam))
4243 { 4258 {
4244 dbcs_lead = (char) msg.msg.wParam; 4259 dbcs_lead = (char) msg.msg.wParam;
4245 inev.kind = NO_EVENT; 4260 inev.kind = NO_EVENT;
@@ -4247,8 +4262,8 @@ w32_read_socket (sd, expected, hold_quit)
4247 } 4262 }
4248 else 4263 else
4249 { 4264 {
4250 if (!MultiByteToWideChar (CP_ACP, 0, &dbcs[1], 1, 4265 if (!MultiByteToWideChar (keyboard_codepage, 0,
4251 &code, 1)) 4266 &dbcs[1], 1, &code, 1))
4252 { 4267 {
4253 /* What to do with garbage? */ 4268 /* What to do with garbage? */
4254 DebPrint (("Invalid character: %d\n", dbcs[1])); 4269 DebPrint (("Invalid character: %d\n", dbcs[1]));
@@ -6345,8 +6360,13 @@ w32_initialize ()
6345 8 bit character input, standard quit char. */ 6360 8 bit character input, standard quit char. */
6346 Fset_input_mode (Qnil, Qnil, make_number (2), Qnil); 6361 Fset_input_mode (Qnil, Qnil, make_number (2), Qnil);
6347 6362
6348 /* Create the window thread - it will terminate itself or when the app terminates */ 6363 {
6364 HKL input_locale_id = GetKeyboardLayout (0);
6365 keyboard_codepage = codepage_for_locale (input_locale_id & 0xffff);
6366 }
6349 6367
6368 /* Create the window thread - it will terminate itself when the app
6369 terminates */
6350 init_crit (); 6370 init_crit ();
6351 6371
6352 dwMainThreadId = GetCurrentThreadId (); 6372 dwMainThreadId = GetCurrentThreadId ();
@@ -6354,7 +6374,6 @@ w32_initialize ()
6354 GetCurrentProcess (), &hMainThread, 0, TRUE, DUPLICATE_SAME_ACCESS); 6374 GetCurrentProcess (), &hMainThread, 0, TRUE, DUPLICATE_SAME_ACCESS);
6355 6375
6356 /* Wait for thread to start */ 6376 /* Wait for thread to start */
6357
6358 { 6377 {
6359 MSG msg; 6378 MSG msg;
6360 6379