aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2012-08-10 09:54:37 +0300
committerEli Zaretskii2012-08-10 09:54:37 +0300
commitd30be705dfb9a14e6ac07df9e8b61f09ed96d95e (patch)
tree1ceb8ebe75f221e0c730cf00050b090c12a25457 /src
parent4b94e8cfe59df775a3eb510ec67764e22c91ebd5 (diff)
downloademacs-d30be705dfb9a14e6ac07df9e8b61f09ed96d95e.tar.gz
emacs-d30be705dfb9a14e6ac07df9e8b61f09ed96d95e.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog14
-rw-r--r--src/w32fns.c61
2 files changed, 58 insertions, 17 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index bd43b7ba05e..a537c07b769 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,17 @@
12012-08-10 Joakim HÃ¥rsman <joakim.harsman@gmail.com> (tiny patch)
2 Eli Zaretskii <eliz@gnu.org>
3
4 Fix bug #10299 with Unicode characters sent by customized
5 keyboards created by MSKLC.
6 * w32fns.c (INIT_WINDOW_CLASS): New macro.
7 (w32_init_class): Use it to initialize the Emacs class with either
8 ANSI or Unicode API calls.
9 (w32_msg_pump): Call GetMessageW and DispatchMessageW on NT and
10 later.
11 (w32_wnd_proc): If the character code sent by WM_CHAR or
12 WM_SYSCHAR is above 255, post a WM_UNICHAR message, not the
13 original message. Call DefWindowProcW on NT and later.
14
12012-08-10 Glenn Morris <rgm@gnu.org> 152012-08-10 Glenn Morris <rgm@gnu.org>
2 16
3 * Makefile.in (config_h): Fix conf_post.h out-of-tree build location. 17 * Makefile.in (config_h): Fix conf_post.h out-of-tree build location.
diff --git a/src/w32fns.c b/src/w32fns.c
index 3c40361ca86..62b4272f236 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -1780,23 +1780,37 @@ w32_load_cursor (LPCTSTR name)
1780 1780
1781static LRESULT CALLBACK w32_wnd_proc (HWND, UINT, WPARAM, LPARAM); 1781static LRESULT CALLBACK w32_wnd_proc (HWND, UINT, WPARAM, LPARAM);
1782 1782
1783#define INIT_WINDOW_CLASS(WC) \
1784 (WC).style = CS_HREDRAW | CS_VREDRAW; \
1785 (WC).lpfnWndProc = (WNDPROC) w32_wnd_proc; \
1786 (WC).cbClsExtra = 0; \
1787 (WC).cbWndExtra = WND_EXTRA_BYTES; \
1788 (WC).hInstance = hinst; \
1789 (WC).hIcon = LoadIcon (hinst, EMACS_CLASS); \
1790 (WC).hCursor = w32_load_cursor (IDC_ARROW); \
1791 (WC).hbrBackground = NULL; \
1792 (WC).lpszMenuName = NULL; \
1793
1783static BOOL 1794static BOOL
1784w32_init_class (HINSTANCE hinst) 1795w32_init_class (HINSTANCE hinst)
1785{ 1796{
1786 WNDCLASS wc;
1787 1797
1788 wc.style = CS_HREDRAW | CS_VREDRAW; 1798 if (os_subtype == OS_NT)
1789 wc.lpfnWndProc = (WNDPROC) w32_wnd_proc; 1799 {
1790 wc.cbClsExtra = 0; 1800 WNDCLASSW uwc;
1791 wc.cbWndExtra = WND_EXTRA_BYTES; 1801 INIT_WINDOW_CLASS(uwc);
1792 wc.hInstance = hinst; 1802 uwc.lpszClassName = L"Emacs";
1793 wc.hIcon = LoadIcon (hinst, EMACS_CLASS); 1803
1794 wc.hCursor = w32_load_cursor (IDC_ARROW); 1804 return RegisterClassW (&uwc);
1795 wc.hbrBackground = NULL; /* GetStockObject (WHITE_BRUSH); */ 1805 }
1796 wc.lpszMenuName = NULL; 1806 else
1797 wc.lpszClassName = EMACS_CLASS; 1807 {
1808 WNDCLASS wc;
1809 INIT_WINDOW_CLASS(wc);
1810 wc.lpszClassName = EMACS_CLASS;
1798 1811
1799 return (RegisterClass (&wc)); 1812 return RegisterClassA (&wc);
1813 }
1800} 1814}
1801 1815
1802static HWND 1816static HWND
@@ -2246,7 +2260,7 @@ w32_msg_pump (deferred_msg * msg_buf)
2246 2260
2247 msh_mousewheel = RegisterWindowMessage (MSH_MOUSEWHEEL); 2261 msh_mousewheel = RegisterWindowMessage (MSH_MOUSEWHEEL);
2248 2262
2249 while (GetMessage (&msg, NULL, 0, 0)) 2263 while ((os_subtype == OS_NT ? GetMessageW : GetMessageA) (&msg, NULL, 0, 0))
2250 { 2264 {
2251 if (msg.hwnd == NULL) 2265 if (msg.hwnd == NULL)
2252 { 2266 {
@@ -2341,7 +2355,10 @@ w32_msg_pump (deferred_msg * msg_buf)
2341 } 2355 }
2342 else 2356 else
2343 { 2357 {
2344 DispatchMessage (&msg); 2358 if (os_subtype == OS_NT)
2359 DispatchMessageW (&msg);
2360 else
2361 DispatchMessageA (&msg);
2345 } 2362 }
2346 2363
2347 /* Exit nested loop when our deferred message has completed. */ 2364 /* 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 2935
2919 case WM_SYSCHAR: 2936 case WM_SYSCHAR:
2920 case WM_CHAR: 2937 case WM_CHAR:
2921 post_character_message (hwnd, msg, wParam, lParam, 2938 if (wParam > 255 )
2922 w32_get_key_modifiers (wParam, lParam)); 2939 {
2940 W32Msg wmsg;
2941
2942 wmsg.dwModifiers = w32_get_key_modifiers (wParam, lParam);
2943 signal_user_input ();
2944 my_post_msg (&wmsg, hwnd, WM_UNICHAR, wParam, lParam);
2945
2946 }
2947 else
2948 post_character_message (hwnd, msg, wParam, lParam,
2949 w32_get_key_modifiers (wParam, lParam));
2923 break; 2950 break;
2924 2951
2925 case WM_UNICHAR: 2952 case WM_UNICHAR:
@@ -3801,7 +3828,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
3801 } 3828 }
3802 3829
3803 dflt: 3830 dflt:
3804 return DefWindowProc (hwnd, msg, wParam, lParam); 3831 return (os_subtype == OS_NT ? DefWindowProcW : DefWindowProcA) (hwnd, msg, wParam, lParam);
3805 } 3832 }
3806 3833
3807 /* The most common default return code for handled messages is 0. */ 3834 /* The most common default return code for handled messages is 0. */