Commit d30be705 authored by Eli Zaretskii's avatar Eli Zaretskii

Fix bug #10299 with Unicode characters sent on MS-Windows by MSKLC.

 src/w32fns.c (INIT_WINDOW_CLASS): New macro.
 (w32_init_class): Use it to initialize the Emacs class with either
 ANSI or Unicode API calls.
 (w32_msg_pump): Call GetMessageW and DispatchMessageW on NT and
 later.
 (w32_wnd_proc): If the character code sent by WM_CHAR or
 WM_SYSCHAR is above 255, post a WM_UNICHAR message, not the
 original message.  Call DefWindowProcW on NT and later.
parent 4b94e8cf
2012-08-10 Joakim Hårsman <joakim.harsman@gmail.com> (tiny patch)
Eli Zaretskii <eliz@gnu.org>
Fix bug #10299 with Unicode characters sent by customized
keyboards created by MSKLC.
* w32fns.c (INIT_WINDOW_CLASS): New macro.
(w32_init_class): Use it to initialize the Emacs class with either
ANSI or Unicode API calls.
(w32_msg_pump): Call GetMessageW and DispatchMessageW on NT and
later.
(w32_wnd_proc): If the character code sent by WM_CHAR or
WM_SYSCHAR is above 255, post a WM_UNICHAR message, not the
original message. Call DefWindowProcW on NT and later.
2012-08-10 Glenn Morris <rgm@gnu.org> 2012-08-10 Glenn Morris <rgm@gnu.org>
* Makefile.in (config_h): Fix conf_post.h out-of-tree build location. * Makefile.in (config_h): Fix conf_post.h out-of-tree build location.
......
...@@ -1780,23 +1780,37 @@ w32_load_cursor (LPCTSTR name) ...@@ -1780,23 +1780,37 @@ w32_load_cursor (LPCTSTR name)
static LRESULT CALLBACK w32_wnd_proc (HWND, UINT, WPARAM, LPARAM); static LRESULT CALLBACK w32_wnd_proc (HWND, UINT, WPARAM, LPARAM);
#define INIT_WINDOW_CLASS(WC) \
(WC).style = CS_HREDRAW | CS_VREDRAW; \
(WC).lpfnWndProc = (WNDPROC) w32_wnd_proc; \
(WC).cbClsExtra = 0; \
(WC).cbWndExtra = WND_EXTRA_BYTES; \
(WC).hInstance = hinst; \
(WC).hIcon = LoadIcon (hinst, EMACS_CLASS); \
(WC).hCursor = w32_load_cursor (IDC_ARROW); \
(WC).hbrBackground = NULL; \
(WC).lpszMenuName = NULL; \
static BOOL static BOOL
w32_init_class (HINSTANCE hinst) w32_init_class (HINSTANCE hinst)
{ {
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW; if (os_subtype == OS_NT)
wc.lpfnWndProc = (WNDPROC) w32_wnd_proc; {
wc.cbClsExtra = 0; WNDCLASSW uwc;
wc.cbWndExtra = WND_EXTRA_BYTES; INIT_WINDOW_CLASS(uwc);
wc.hInstance = hinst; uwc.lpszClassName = L"Emacs";
wc.hIcon = LoadIcon (hinst, EMACS_CLASS);
wc.hCursor = w32_load_cursor (IDC_ARROW); return RegisterClassW (&uwc);
wc.hbrBackground = NULL; /* GetStockObject (WHITE_BRUSH); */ }
wc.lpszMenuName = NULL; else
wc.lpszClassName = EMACS_CLASS; {
WNDCLASS wc;
INIT_WINDOW_CLASS(wc);
wc.lpszClassName = EMACS_CLASS;
return (RegisterClass (&wc)); return RegisterClassA (&wc);
}
} }
static HWND static HWND
...@@ -2246,7 +2260,7 @@ w32_msg_pump (deferred_msg * msg_buf) ...@@ -2246,7 +2260,7 @@ w32_msg_pump (deferred_msg * msg_buf)
msh_mousewheel = RegisterWindowMessage (MSH_MOUSEWHEEL); msh_mousewheel = RegisterWindowMessage (MSH_MOUSEWHEEL);
while (GetMessage (&msg, NULL, 0, 0)) while ((os_subtype == OS_NT ? GetMessageW : GetMessageA) (&msg, NULL, 0, 0))
{ {
if (msg.hwnd == NULL) if (msg.hwnd == NULL)
{ {
...@@ -2341,7 +2355,10 @@ w32_msg_pump (deferred_msg * msg_buf) ...@@ -2341,7 +2355,10 @@ w32_msg_pump (deferred_msg * msg_buf)
} }
else else
{ {
DispatchMessage (&msg); if (os_subtype == OS_NT)
DispatchMessageW (&msg);
else
DispatchMessageA (&msg);
} }
/* Exit nested loop when our deferred message has completed. */ /* Exit nested loop when our deferred message has completed. */
...@@ -2918,8 +2935,18 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ...@@ -2918,8 +2935,18 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_SYSCHAR: case WM_SYSCHAR:
case WM_CHAR: case WM_CHAR:
post_character_message (hwnd, msg, wParam, lParam, if (wParam > 255 )
w32_get_key_modifiers (wParam, lParam)); {
W32Msg wmsg;
wmsg.dwModifiers = w32_get_key_modifiers (wParam, lParam);
signal_user_input ();
my_post_msg (&wmsg, hwnd, WM_UNICHAR, wParam, lParam);
}
else
post_character_message (hwnd, msg, wParam, lParam,
w32_get_key_modifiers (wParam, lParam));
break; break;
case WM_UNICHAR: case WM_UNICHAR:
...@@ -3801,7 +3828,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ...@@ -3801,7 +3828,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
} }
dflt: dflt:
return DefWindowProc (hwnd, msg, wParam, lParam); return (os_subtype == OS_NT ? DefWindowProcW : DefWindowProcA) (hwnd, msg, wParam, lParam);
} }
/* The most common default return code for handled messages is 0. */ /* The most common default return code for handled messages is 0. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment