Hi, Eli,

Thanks. I'll try it.


------------------ 原始邮件 ------------------
发件人: "Eli Zaretskii"<eliz@gnu.org>;
发送时间: 2020年4月13日(星期一) 下午3:05
收件人: "Albert"<georgealbert@qq.com>;
抄送: "emacs-devel"<emacs-devel@gnu.org>;
主题: Re: 回复: 回复: 回复: [PATCH] Add IME status change support on windows natively

Here's what I propose.

Change w32-set-ime-open-status to do this:

DEFUN ("w32-set-ime-open-status",
       Fw32_set_ime_open_status, Sw32_set_ime_open_status,
       1, 1, 0,
       doc: /* Set emacs IME open status on Windows. */)
  (Lisp_Object status)
{
    unsigned ime_status;
    if (NILP (status))
      ime_status = 0;
    else
      ime_status = 1;

    PostThreadMessage (dwWindowsThreadId, WM_EMACS_IME_STATUS,
                                          (WPARAM)ime_status, 0);

    return Qnil;
}

Then in w32fns.c do this to handle the WM_EMACS_IME_STATUS message:

            case WM_EMACS_IME_STATUS:
              if (!set_ime_open_status_fn)
                break;
              else
                {
  HIMC context = get_ime_context_fn (w32_system_caret_hwnd);
  if (!context)
    break;
  BOOL ime_status = get_ime_open_status_fn (context);
  BOOL new_status = (wParam != 0);
                  if (ime_status != new_status)
    set_ime_open_status_fn (context, new_status);
                  release_ime_context_fn (w32_system_caret_hwnd, context);
                }
              break;

Then you can get rid of the 2 static variables.

This is entirely untested, so please make sure it works as intended.