Subject: bug#10299: Emacs doesn't handle Unicode characters in keyboard layout on MS Windows

From: Stefan Monnier <[email-masked]>
Date: Mon, 16 Jan 2012 09:03:17 -0500

Note: I know very little about w32.

> -      SetWindowText (FRAME_W32_WINDOW (f), SDATA (name));
> +      if (os_subtype == OS_NT)
> +        SetWindowTextW (FRAME_W32_WINDOW (f), SDATA (name));
> +      else
> +        SetWindowText (FRAME_W32_WINDOW (f), SDATA (name));

Can we move the test elsewhere by defining (or #defining) our own
SetWindowText which uses either of the two?

> @@ -1785,20 +1791,39 @@
>  static BOOL
>  w32_init_class (HINSTANCE hinst)
>  {
> -  WNDCLASS 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; /* GetStockObject (WHITE_BRUSH);  */
> -  wc.lpszMenuName = NULL;
> -  wc.lpszClassName = EMACS_CLASS;
> -
> -  return (RegisterClass (&wc));
> +  WNDCLASSW uwc;
> +  WNDCLASS  wc;
> +
> +  if (os_subtype == OS_NT)
> +    {
> +      uwc.style = CS_HREDRAW | CS_VREDRAW;
> +      uwc.lpfnWndProc = (WNDPROC) w32_wnd_proc;
> +      uwc.cbClsExtra = 0;
> +      uwc.cbWndExtra = WND_EXTRA_BYTES;
> +      uwc.hInstance = hinst;
> +      uwc.hIcon = LoadIcon (hinst, EMACS_CLASS);
> +      uwc.hCursor = w32_load_cursor (IDC_ARROW);
> +      uwc.hbrBackground = NULL; /* GetStockObject (WHITE_BRUSH);  */
> +      uwc.lpszMenuName = NULL;
> +      uwc.lpszClassName = L"Emacs";
> +
> +      return (RegisterClassW (&uwc));
> +    }
> +  else
> +    {
> +      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; /* GetStockObject (WHITE_BRUSH);  */
> +      wc.lpszMenuName = NULL;
> +      wc.lpszClassName = EMACS_CLASS;
> +
> +      return (RegisterClass (&wc));
> +    }
>  }

The two var declarations (WNDCLASSW uwc and WNDCLASS wc) should be moved
within their respective branch.  And it'd be better if we could share
some code between the two branches, e.g. using a macro.

        Stefan