From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Joakim =?UTF-8?Q?H=C3=A5rsman?= Newsgroups: gmane.emacs.bugs Subject: bug#10299: Emacs doesn't handle Unicode characters in keyboard layout on MS Windows Date: Sat, 17 Dec 2011 13:52:29 +0100 Message-ID: References: <8739clgapc.fsf@gnu.org> <83zket20xw.fsf@gnu.org> <83vcph0w9t.fsf@gnu.org> <83obv821wv.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1324126414 3371 80.91.229.12 (17 Dec 2011 12:53:34 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 17 Dec 2011 12:53:34 +0000 (UTC) Cc: 10299@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Dec 17 13:53:29 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RbtlX-0006jS-Kv for geb-bug-gnu-emacs@m.gmane.org; Sat, 17 Dec 2011 13:53:27 +0100 Original-Received: from localhost ([::1]:53181 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RbtlX-00033L-0o for geb-bug-gnu-emacs@m.gmane.org; Sat, 17 Dec 2011 07:53:27 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:60815) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RbtlT-000333-MC for bug-gnu-emacs@gnu.org; Sat, 17 Dec 2011 07:53:25 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RbtlS-0007uT-2Z for bug-gnu-emacs@gnu.org; Sat, 17 Dec 2011 07:53:23 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:40981) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RbtlS-0007uN-0e for bug-gnu-emacs@gnu.org; Sat, 17 Dec 2011 07:53:22 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1Rbtn4-0003xy-8f for bug-gnu-emacs@gnu.org; Sat, 17 Dec 2011 07:55:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Joakim =?UTF-8?Q?H=C3=A5rsman?= Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 17 Dec 2011 12:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10299 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 10299-submit@debbugs.gnu.org id=B10299.132412645415191 (code B ref 10299); Sat, 17 Dec 2011 12:55:02 +0000 Original-Received: (at 10299) by debbugs.gnu.org; 17 Dec 2011 12:54:14 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RbtmH-0003wy-Ld for submit@debbugs.gnu.org; Sat, 17 Dec 2011 07:54:13 -0500 Original-Received: from mail-ee0-f44.google.com ([74.125.83.44]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RbtmF-0003wq-DI for 10299@debbugs.gnu.org; Sat, 17 Dec 2011 07:54:12 -0500 Original-Received: by eekc14 with SMTP id c14so2849634eek.3 for <10299@debbugs.gnu.org>; Sat, 17 Dec 2011 04:52:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=fJhsYphTGfJgenRPIzNGuRppQ0hG7OgpkQuSPm+kod0=; b=sHFC9x/ZrFoUvc95Skb9fPfehn70pS/P4PmaAWD7AEkS2u0rxy9PvAPolFjSCwkoJ8 6l6VEduMOYVlIyzkU7lGoFEspHk6nQJw5HCBF8FiLZUsF/xaATaOSBw69KK3Yccmbvo5 zRaB/n0Z9MVqhPYmhyOPBmfzxDzJExoAiT83Y= Original-Received: by 10.14.50.206 with SMTP id z54mr1225230eeb.46.1324126349834; Sat, 17 Dec 2011 04:52:29 -0800 (PST) Original-Received: by 10.204.58.209 with HTTP; Sat, 17 Dec 2011 04:52:29 -0800 (PST) In-Reply-To: <83obv821wv.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sat, 17 Dec 2011 07:55:02 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:55034 Archived-At: On 16 December 2011 12:26, Eli Zaretskii wrote: >> Date: Fri, 16 Dec 2011 12:14:50 +0100 >> From: Dani Moncayo >> Cc: Eli Zaretskii , 10299@debbugs.gnu.org >> >> > I think I have a MSYS sh.exe somewhere in my path which caused the >> > build to fail if I didn't explicitly set SHELL. >> >> Maybe if you try "mingw32-make" instead of "make", you will be able to >> build Emacs successfully (see >> http://lists.gnu.org/archive/html/emacs-devel/2011-12/msg00025.html) > > If his make.exe reacts correctly to SHELL=3Dcmd.exe, it is most probably > a MinGW Make, just renamed to make.exe. =A0(FWIW, my MinGW compiled Make > is also called make.exe.) Ok, I tried switching to RegisterClassW, but that didn't really help, after calling TranslateMessage I still got WM_CHAR with a question mark. So I tried switching to CreateWindowW and GetMessageW as well, and that did the trick. Here's my changes: D:\Dev_projects\emacs\trunk\nt>bzr diff =3D=3D=3D modified file 'src/w32fns.c' --- src/w32fns.c 2011-12-04 08:02:42 +0000 +++ src/w32fns.c 2011-12-17 11:39:10 +0000 @@ -1785,7 +1785,7 @@ static BOOL w32_init_class (HINSTANCE hinst) { - WNDCLASS wc; + WNDCLASSW wc; wc.style =3D CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc =3D (WNDPROC) w32_wnd_proc; @@ -1796,9 +1796,9 @@ wc.hCursor =3D w32_load_cursor (IDC_ARROW); wc.hbrBackground =3D NULL; /* GetStockObject (WHITE_BRUSH); */ wc.lpszMenuName =3D NULL; - wc.lpszClassName =3D EMACS_CLASS; + wc.lpszClassName =3D L"Emacs"; - return (RegisterClass (&wc)); + return (RegisterClassW (&wc)); } static HWND @@ -1853,7 +1853,7 @@ } FRAME_W32_WINDOW (f) =3D hwnd - =3D CreateWindow (EMACS_CLASS, + =3D CreateWindowW (L"Emacs", f->namebuf, f->output_data.w32->dwStyle | WS_CLIPCHILDREN, EQ (left, Qunbound) ? CW_USEDEFAULT : XINT (left), @@ -2248,7 +2248,7 @@ msh_mousewheel =3D RegisterWindowMessage (MSH_MOUSEWHEEL); - while (GetMessage (&msg, NULL, 0, 0)) + while (GetMessageW (&msg, NULL, 0, 0)) { if (msg.hwnd =3D=3D NULL) { @@ -2507,7 +2507,7 @@ message that has no particular effect. */ { int c =3D wParam; - if (isalpha (c) && wmsg.dwModifiers =3D=3D ctrl_modifier) + if (iswalpha (c) && wmsg.dwModifiers =3D=3D ctrl_modifier) c =3D make_ctrl_char (c) & 0377; if (c =3D=3D quit_char || (wmsg.dwModifiers =3D=3D 0 && I had to switch to iswalpha because isalpha segfaulted when sent values larger than 255. wParam isn't really the Unicode code point here either, it's encoded as UTF-16. With this change, Emacs no longer prints a question mark when I press the special keys, it doesn't print anything at all. I figured this is beacause wParam isn't a valid Unicode codepoint here, like it is when you get a WM_UNICHAR, so I tried a quick hack converting from UTF-16 and re-posting as a WM_UNICHAR even. I changed the handling of WM_CHAR in w32_wnd_proc: case WM_CHAR: if (wParam > 255 ) { /* Hacky conversion from UTF-16 to UCS-4. Doesn't handle surrogate pairs. */ unsigned short lo =3D wParam & 0x0000FFFF; unsigned short hi =3D (wParam & 0xFFFF0000) >> 8; wParam =3D hi | lo; W32Msg wmsg; wmsg.dwModifiers =3D 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)); This fixed it! I can now enter the characters with a custom keyboard layout so I'm happy. There's loads of bugs still (e.g. the frame title is "e" instead of "Emacs@host" because I just pass the frame's namebuf to CreateWindowW without converting it to a wide string), but at least the main issue is fixed. I guess these changes need to only happen when running on NT for Emacs to still work on Windows 95 or does Emacs use MSLU? Maybe they should depend on some lisp variable being set? Here's my changes in full so far: =3D=3D=3D modified file 'src/w32fns.c' --- src/w32fns.c 2011-12-04 08:02:42 +0000 +++ src/w32fns.c 2011-12-17 12:47:44 +0000 @@ -1785,7 +1785,7 @@ static BOOL w32_init_class (HINSTANCE hinst) { - WNDCLASS wc; + WNDCLASSW wc; wc.style =3D CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc =3D (WNDPROC) w32_wnd_proc; @@ -1796,9 +1796,9 @@ wc.hCursor =3D w32_load_cursor (IDC_ARROW); wc.hbrBackground =3D NULL; /* GetStockObject (WHITE_BRUSH); */ wc.lpszMenuName =3D NULL; - wc.lpszClassName =3D EMACS_CLASS; + wc.lpszClassName =3D L"Emacs"; - return (RegisterClass (&wc)); + return (RegisterClassW (&wc)); } static HWND @@ -1853,7 +1853,7 @@ } FRAME_W32_WINDOW (f) =3D hwnd - =3D CreateWindow (EMACS_CLASS, + =3D CreateWindowW (L"Emacs", f->namebuf, f->output_data.w32->dwStyle | WS_CLIPCHILDREN, EQ (left, Qunbound) ? CW_USEDEFAULT : XINT (left), @@ -2248,7 +2248,7 @@ msh_mousewheel =3D RegisterWindowMessage (MSH_MOUSEWHEEL); - while (GetMessage (&msg, NULL, 0, 0)) + while (GetMessageW (&msg, NULL, 0, 0)) { if (msg.hwnd =3D=3D NULL) { @@ -2507,7 +2507,7 @@ message that has no particular effect. */ { int c =3D wParam; - if (isalpha (c) && wmsg.dwModifiers =3D=3D ctrl_modifier) + if (iswalpha (c) && wmsg.dwModifiers =3D=3D ctrl_modifier) c =3D make_ctrl_char (c) & 0377; if (c =3D=3D quit_char || (wmsg.dwModifiers =3D=3D 0 && @@ -2915,8 +2915,23 @@ case WM_SYSCHAR: case WM_CHAR: - post_character_message (hwnd, msg, wParam, lParam, - w32_get_key_modifiers (wParam, lParam)); + if (wParam > 255 ) + { + /* Hacky conversion from UTF-16 to UCS-4. + Doesn't handle surrogate pairs. */ + unsigned short lo =3D wParam & 0x0000FFFF; + unsigned short hi =3D (wParam & 0xFFFF0000) >> 8; + wParam =3D hi | lo; + + W32Msg wmsg; + wmsg.dwModifiers =3D 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; case WM_UNICHAR: