unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] Add IME status change support on windows natively
@ 2020-04-13  4:09 Albert
  2020-04-13  4:53 ` Eli Zaretskii
  0 siblings, 1 reply; 31+ messages in thread
From: Albert @ 2020-04-13  4:09 UTC (permalink / raw)
  To: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 1449 bytes --]

Hi,
    I added some code on src/w32fns.c and src/w32term.h to add IME status change support on windows natively like gVim did. gVim can change IME status to chinese mode  in insert mode and switch back to english mode when in normal mode natively.



   IME status can be changed by dynamic call imm32.dll's function ImmSetOpenStatus_Proc, but we can't change IME status by elisp code only. Because calling imm32.dll's function ImmSetOpenStatus_Proc from lisp thread is not allowed by Windows, IME is attached to window thread and lisp code is executed in lisp thread. We have to set a flag in lisp thread and set a user-defined message to window thread, then processes that message in w32_msg_pump(). I added a function w32-set-ime-open-status which is called by lisp code.


Following is lisp to use w32-set-ime-open-status after evil mode changed



(if (fboundp 'w32-set-ime-open-status)
    (progn
      (defun emacs-ime-disable ()
        (w32-set-ime-open-status nil))

      (defun emacs-ime-enable ()
        (w32-set-ime-open-status t))

      (add-hook 'evil-insert-state-entry-hook 'emacs-ime-enable)
      (add-hook 'evil-insert-state-exit-hook 'emacs-ime-disable)
      ))

[-- Attachment #1.2: Type: text/html, Size: 1630 bytes --]

[-- Attachment #2: w32fns.c.patch --]
[-- Type: application/octet-stream, Size: 5516 bytes --]

diff --git a/src/w32fns.c b/src/w32fns.c
index 8d714f0b8d..341cbb4fcd 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -166,6 +166,10 @@ DECLARE_HANDLE(HMONITOR);
 typedef BOOL (WINAPI * ImmReleaseContext_Proc) (IN HWND wnd, IN HIMC context);
 typedef BOOL (WINAPI * ImmSetCompositionWindow_Proc) (IN HIMC context,
 						      IN COMPOSITIONFORM *form);
+/* for ime switch */
+typedef BOOL (WINAPI * ImmGetOpenStatus_Proc) (IN HIMC);
+typedef BOOL (WINAPI * ImmSetOpenStatus_Proc) (IN HIMC, IN BOOL);
+
 typedef HMONITOR (WINAPI * MonitorFromPoint_Proc) (IN POINT pt, IN DWORD flags);
 typedef BOOL (WINAPI * GetMonitorInfo_Proc)
   (IN HMONITOR monitor, OUT struct MONITOR_INFO* info);
@@ -185,6 +189,8 @@ DECLARE_HANDLE(HMONITOR);
 TrackMouseEvent_Proc track_mouse_event_fn = NULL;
 ImmGetCompositionString_Proc get_composition_string_fn = NULL;
 ImmGetContext_Proc get_ime_context_fn = NULL;
+ImmGetOpenStatus_Proc get_ime_open_status_fn = NULL;
+ImmSetOpenStatus_Proc set_ime_open_status_fn = NULL;
 ImmReleaseContext_Proc release_ime_context_fn = NULL;
 ImmSetCompositionWindow_Proc set_ime_composition_window_fn = NULL;
 MonitorFromPoint_Proc monitor_from_point_fn = NULL;
@@ -295,6 +301,10 @@ #define WS_EX_NOACTIVATE 0x08000000L
 
 static struct w32_display_info *w32_display_info_for_name (Lisp_Object);
 
+/* emacs ime status change flag, used in mainThread and windowsThread */
+static int w32_ime_status_changed = 0;
+static int w32_emacs_ime_status = 0;
+
 /* Let the user specify a display with a frame.
    nil stands for the selected frame--or, if that is not a w32 frame,
    the first display on the list.  */
@@ -2421,6 +2431,7 @@ w32_createhscrollbar (struct frame *f, struct scroll_bar * bar)
 		       FRAME_W32_WINDOW (f), NULL, hinst, NULL);
 }
 
+
 static void
 w32_createwindow (struct frame *f, int *coords)
 {
@@ -3305,6 +3316,7 @@ #define M(msg) { msg, # msg }
       M (WM_EMACS_SETCURSOR),
       M (WM_EMACS_SHOWCURSOR),
       M (WM_EMACS_PAINT),
+      M (WM_EMACS_IME_STATUS),
       M (WM_CHAR),
 #undef M
       { 0, 0 }
@@ -3442,6 +3454,25 @@ w32_msg_pump (deferred_msg * msg_buf)
 		  emacs_abort ();
 	      }
 	      break;
+            case WM_EMACS_IME_STATUS:
+              if (!set_ime_open_status_fn)
+                break;
+              else
+                {
+                  if (w32_ime_status_changed)
+                    {
+                      w32_ime_status_changed = 0;
+                      HIMC context;
+                      context = get_ime_context_fn (w32_system_caret_hwnd);
+                      if (!context)
+                          break;
+
+                      set_ime_open_status_fn (context, w32_emacs_ime_status);
+                      release_ime_context_fn (w32_system_caret_hwnd, context);
+                    }
+                }
+              break;
+
 #ifdef MSG_DEBUG
 	      /* Broadcast messages make it here, so you need to be looking
 		 for something in particular for this to be useful.  */
@@ -10218,6 +10249,43 @@ DEFUN ("w32-notification-close",
 
 #endif	/* WINDOWSNT && !HAVE_DBUS */
 
+DEFUN ("w32-get-ime-open-status",
+       Fw32_get_ime_open_status, Sw32_get_ime_open_status,
+       0, 0, 0,
+       doc: /* Return ime open status on Windows. */)
+  (void)
+{
+  int retval;
+
+  HIMC context = get_ime_context_fn (w32_system_caret_hwnd);
+  if (context != NULL)
+    {
+      retval = get_ime_open_status_fn (context);
+      release_ime_context_fn (w32_system_caret_hwnd, context);
+
+      return make_fixnum(retval);
+    }
+
+  return Qnil;
+}
+
+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)
+{
+    w32_ime_status_changed = 1;
+    if (NILP (status))
+      w32_emacs_ime_status = 0;
+    else
+      w32_emacs_ime_status = 1;
+
+    PostThreadMessage (dwWindowsThreadId, WM_EMACS_IME_STATUS, 0, 0);
+
+    return Qnil;
+}
+
 \f
 #ifdef WINDOWSNT
 /***********************************************************************
@@ -10744,6 +10812,8 @@ syms_of_w32fns (void)
   defsubr (&Sw32_notification_notify);
   defsubr (&Sw32_notification_close);
 #endif
+  defsubr (&Sw32_get_ime_open_status);
+  defsubr (&Sw32_set_ime_open_status);
 
 #ifdef WINDOWSNT
   defsubr (&Sw32_read_registry);
@@ -11032,6 +11102,11 @@ globals_of_w32fns (void)
       get_proc_addr (imm32_lib, "ImmReleaseContext");
     set_ime_composition_window_fn = (ImmSetCompositionWindow_Proc)
       get_proc_addr (imm32_lib, "ImmSetCompositionWindow");
+
+    get_ime_open_status_fn = (ImmGetOpenStatus_Proc)
+      get_proc_addr (imm32_lib, "ImmGetOpenStatus");
+    set_ime_open_status_fn = (ImmSetOpenStatus_Proc)
+      get_proc_addr (imm32_lib, "ImmSetOpenStatus");
   }
 
   HMODULE hm_kernel32 = GetModuleHandle ("kernel32.dll");
diff --git a/src/w32term.h b/src/w32term.h
index f8a8a727e8..4e9234f239 100644
--- a/src/w32term.h
+++ b/src/w32term.h
@@ -670,7 +670,8 @@ #define WM_EMACS_PAINT                 (WM_EMACS_START + 22)
 #define WM_EMACS_BRINGTOTOP            (WM_EMACS_START + 23)
 #define WM_EMACS_INPUT_READY           (WM_EMACS_START + 24)
 #define WM_EMACS_FILENOTIFY            (WM_EMACS_START + 25)
-#define WM_EMACS_END                   (WM_EMACS_START + 26)
+#define WM_EMACS_IME_STATUS            (WM_EMACS_START + 26)
+#define WM_EMACS_END                   (WM_EMACS_START + 27)
 
 #define WND_FONTWIDTH_INDEX    (0)
 #define WND_LINEHEIGHT_INDEX   (4)

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH] Add IME status change support on windows natively
  2020-04-13  4:09 [PATCH] Add IME status change support on windows natively Albert
@ 2020-04-13  4:53 ` Eli Zaretskii
  2020-04-13  5:47   ` Eli Zaretskii
                     ` (2 more replies)
  0 siblings, 3 replies; 31+ messages in thread
From: Eli Zaretskii @ 2020-04-13  4:53 UTC (permalink / raw)
  To: Albert; +Cc: emacs-devel

> From: "Albert" <georgealbert@qq.com>
> Date: Mon, 13 Apr 2020 12:09:00 +0800
> 
>     I added some code on src/w32fns.c and src/w32term.h to add IME status change support on windows
> natively like gVim did. gVim can change IME status to chinese mode  in insert mode and switch back to
> english mode when in normal mode natively.

Thanks.  Can you please tell more about the uses of this feature?  How
would a user of Emacs use this, and what is the effect of using this
on editing inside Emacs?

I'm asking because we probably need to say something about this in the
manual.

>       (add-hook 'evil-insert-state-entry-hook 'emacs-ime-enable)
>       (add-hook 'evil-insert-state-exit-hook 'emacs-ime-disable)

I don't use Evil, so I'm not sure I understand what this does.  If you
describe the typical uses of this feature, I will probably understand
better.  In particular, why is this placed on a hook?

> +/* emacs ime status change flag, used in mainThread and windowsThread */
> +static int w32_ime_status_changed = 0;
> +static int w32_emacs_ime_status = 0;

Can we do this without static variables?  E.g., can you use the 2
parameters of the PostThreadMessage API to pass these flags?  I think
that would be cleaner.

> +DEFUN ("w32-get-ime-open-status",
> +       Fw32_get_ime_open_status, Sw32_get_ime_open_status,
> +       0, 0, 0,
> +       doc: /* Return ime open status on Windows. */)

The doc string is too terse, it should say something about the
returned status and its significance.

> +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. */)

Likewise here.  AFAIU, this function doesn't "set the status", it
actually opens or closes the IME.  If so, the doc string should say
that, and it should explicitly mention the argument of the function
and its significance.

Thank you for working on this.



^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] Add IME status change support on windows natively
  2020-04-13  4:53 ` Eli Zaretskii
@ 2020-04-13  5:47   ` Eli Zaretskii
  2020-04-13  6:06     ` =?gb18030?B?u9i4tKO6IFtQQVRDSF0gQWRkIElNRSBzdGF0dXMgY2hhbmdlIHN1cHBvcnQgb24gd2luZG93cyBuYXRpdmVseQ==?= =?gb18030?B?QWxiZXJ0?=
  2020-04-13  6:12   ` =?gb18030?B?u9i4tKO6IFtQQVRDSF0gQWRkIElNRSBzdGF0dXMgY2hhbmdlIHN1cHBvcnQgb24gd2luZG93cyBuYXRpdmVseQ==?= =?gb18030?B?QWxiZXJ0?=
  2020-04-14  2:13   ` [PATCH] Add IME status change support on windows natively Richard Stallman
  2 siblings, 1 reply; 31+ messages in thread
From: Eli Zaretskii @ 2020-04-13  5:47 UTC (permalink / raw)
  To: georgealbert; +Cc: emacs-devel

> Date: Mon, 13 Apr 2020 07:53:00 +0300
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: emacs-devel@gnu.org
> 
> Thanks.  Can you please tell more about the uses of this feature?  How
> would a user of Emacs use this, and what is the effect of using this
> on editing inside Emacs?
> 
> I'm asking because we probably need to say something about this in the
> manual.
> 
> >       (add-hook 'evil-insert-state-entry-hook 'emacs-ime-enable)
> >       (add-hook 'evil-insert-state-exit-hook 'emacs-ime-disable)

Hmm, the answer seems to be that the changes you proposed allow to
turn the IMM on and off at will.  E.g., the above setup turns IMM on
when Evil enters the "insert" mode.  However, Emacs is always in the
"insert" mode, so I wonder why and under what circumstances would an
Emacs user want to turn IMM off?  Perhaps that should happen
automatically in buffers where character keys do not insert
themselves, but are bound to commands, like Dired buffers and buffers
in view-mode and its derivatives?



^ permalink raw reply	[flat|nested] 31+ messages in thread

* =?gb18030?B?u9i4tKO6IFtQQVRDSF0gQWRkIElNRSBzdGF0dXMgY2hhbmdlIHN1cHBvcnQgb24gd2luZG93cyBuYXRpdmVseQ==?=
  2020-04-13  5:47   ` Eli Zaretskii
@ 2020-04-13  6:06     ` =?gb18030?B?QWxiZXJ0?=
  2020-04-13  6:13       ` =?gb18030?B?u9i4tKO6?= [PATCH] Add IME status change support on windows natively Eli Zaretskii
  0 siblings, 1 reply; 31+ messages in thread
From: =?gb18030?B?QWxiZXJ0?= @ 2020-04-13  6:06 UTC (permalink / raw)
  To: =?gb18030?B?RWxpIFphcmV0c2tpaQ==?=; +Cc: =?gb18030?B?ZW1hY3MtZGV2ZWw=?=

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb18030", Size: 2261 bytes --]

Hi, Eli,


Evil is an extensible vi layer for Emacs. It emulates the main features of Vim, and provides facilities for writing custom extensions. I use Evil in emacs. When I press i&nbsp; key or a key in normal mode, evil will change to insert mode, I can input something. When I press <ECS&gt;, evil will change to normal mode, I can move the cursor by press h/j/k/l and some other commands like yank some lines.


Sometimes I need to input some chinese by open IME in evil insert mode when I press <SHIFT&gt; to enable IME, when I press <ESC&gt; to normal mode, IME is still open for chinese input, I have to press <SHIFT&gt; to disable IME otherwise IME will still works for chinese input which stops me from do some commands like move the cursor in evil.



------------------&nbsp;ԭʼÓʼþ&nbsp;------------------
·¢¼þÈË:&nbsp;"Eli Zaretskii"<eliz@gnu.org&gt;;
·¢ËÍʱ¼ä:&nbsp;2020Äê4ÔÂ13ÈÕ(ÐÇÆÚÒ») ÖÐÎç1:47
ÊÕ¼þÈË:&nbsp;"Albert"<georgealbert@qq.com&gt;;
³­ËÍ:&nbsp;"emacs-devel"<emacs-devel@gnu.org&gt;;
Ö÷Ìâ:&nbsp;Re: [PATCH] Add IME status change support on windows natively



&gt; Date: Mon, 13 Apr 2020 07:53:00 +0300
&gt; From: Eli Zaretskii <eliz@gnu.org&gt;
&gt; Cc: emacs-devel@gnu.org
&gt; 
&gt; Thanks.&nbsp; Can you please tell more about the uses of this feature?&nbsp; How
&gt; would a user of Emacs use this, and what is the effect of using this
&gt; on editing inside Emacs?
&gt; 
&gt; I'm asking because we probably need to say something about this in the
&gt; manual.
&gt; 
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (add-hook 'evil-insert-state-entry-hook 'emacs-ime-enable)
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (add-hook 'evil-insert-state-exit-hook 'emacs-ime-disable)

Hmm, the answer seems to be that the changes you proposed allow to
turn the IMM on and off at will.&nbsp; E.g., the above setup turns IMM on
when Evil enters the "insert" mode.&nbsp; However, Emacs is always in the
"insert" mode, so I wonder why and under what circumstances would an
Emacs user want to turn IMM off?&nbsp; Perhaps that should happen
automatically in buffers where character keys do not insert
themselves, but are bound to commands, like Dired buffers and buffers
in view-mode and its derivatives?

[-- Attachment #2: Type: text/html, Size: 2883 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* =?gb18030?B?u9i4tKO6IFtQQVRDSF0gQWRkIElNRSBzdGF0dXMgY2hhbmdlIHN1cHBvcnQgb24gd2luZG93cyBuYXRpdmVseQ==?=
  2020-04-13  4:53 ` Eli Zaretskii
  2020-04-13  5:47   ` Eli Zaretskii
@ 2020-04-13  6:12   ` =?gb18030?B?QWxiZXJ0?=
  2020-04-13  6:24     ` =?gb18030?B?u9i4tKO6?= [PATCH] Add IME status change support on windows natively Eli Zaretskii
  2020-04-14  2:13   ` [PATCH] Add IME status change support on windows natively Richard Stallman
  2 siblings, 1 reply; 31+ messages in thread
From: =?gb18030?B?QWxiZXJ0?= @ 2020-04-13  6:12 UTC (permalink / raw)
  To: =?gb18030?B?RWxpIFphcmV0c2tpaQ==?=; +Cc: =?gb18030?B?ZW1hY3MtZGV2ZWw=?=

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb18030", Size: 3469 bytes --]

Hi, Eli,


 `ImmGetOpenStatus` and `ImmGetOpenStatus` are functions uesd for internationalization for Windows Applications.



Function `w32-get-ime-open-status` determines whether the IME is open or closed, If return 1, IME is open. If return 0, IME is closed.


Function `w32-set-ime-open-status` opens or closes the IME. This function has one argument. 

If the argument is not nil, open or enable IME, we can type some words, IME will translate them into native language like chinese.
If the argument is nil, close IME, we can type some words in english, IME will not translate them into chinese.



I try to figure out how to do this without static variables. Static variable is the simplest way to do the job between window thread and lisp thread right now.
------------------&nbsp;ԭʼÓʼþ&nbsp;------------------
·¢¼þÈË:&nbsp;"Eli Zaretskii"<eliz@gnu.org&gt;;
·¢ËÍʱ¼ä:&nbsp;2020Äê4ÔÂ13ÈÕ(ÐÇÆÚÒ») ÖÐÎç12:53
ÊÕ¼þÈË:&nbsp;"Albert"<georgealbert@qq.com&gt;;
³­ËÍ:&nbsp;"emacs-devel"<emacs-devel@gnu.org&gt;;
Ö÷Ìâ:&nbsp;Re: [PATCH] Add IME status change support on windows natively



&gt; From: "Albert" <georgealbert@qq.com&gt;
&gt; Date: Mon, 13 Apr 2020 12:09:00 +0800
&gt; 
&gt;&nbsp;&nbsp;&nbsp;&nbsp; I added some code on src/w32fns.c and src/w32term.h to add IME status change support on windows
&gt; natively like gVim did. gVim can change IME status to chinese mode&nbsp; in insert mode and switch back to
&gt; english mode when in normal mode natively.

Thanks.&nbsp; Can you please tell more about the uses of this feature?&nbsp; How
would a user of Emacs use this, and what is the effect of using this
on editing inside Emacs?

I'm asking because we probably need to say something about this in the
manual.

&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (add-hook 'evil-insert-state-entry-hook 'emacs-ime-enable)
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (add-hook 'evil-insert-state-exit-hook 'emacs-ime-disable)

I don't use Evil, so I'm not sure I understand what this does.&nbsp; If you
describe the typical uses of this feature, I will probably understand
better.&nbsp; In particular, why is this placed on a hook?

&gt; +/* emacs ime status change flag, used in mainThread and windowsThread */
&gt; +static int w32_ime_status_changed = 0;
&gt; +static int w32_emacs_ime_status = 0;

Can we do this without static variables?&nbsp; E.g., can you use the 2
parameters of the PostThreadMessage API to pass these flags?&nbsp; I think
that would be cleaner.

&gt; +DEFUN ("w32-get-ime-open-status",
&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Fw32_get_ime_open_status, Sw32_get_ime_open_status,
&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0, 0, 0,
&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; doc: /* Return ime open status on Windows. */)

The doc string is too terse, it should say something about the
returned status and its significance.

&gt; +DEFUN ("w32-set-ime-open-status",
&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Fw32_set_ime_open_status, Sw32_set_ime_open_status,
&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1, 1, 0,
&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; doc: /* Set emacs IME open status on Windows. */)

Likewise here.&nbsp; AFAIU, this function doesn't "set the status", it
actually opens or closes the IME.&nbsp; If so, the doc string should say
that, and it should explicitly mention the argument of the function
and its significance.

Thank you for working on this.

[-- Attachment #2: Type: text/html, Size: 17488 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: =?gb18030?B?u9i4tKO6?= [PATCH] Add IME status change support on windows natively
  2020-04-13  6:06     ` =?gb18030?B?u9i4tKO6IFtQQVRDSF0gQWRkIElNRSBzdGF0dXMgY2hhbmdlIHN1cHBvcnQgb24gd2luZG93cyBuYXRpdmVseQ==?= =?gb18030?B?QWxiZXJ0?=
@ 2020-04-13  6:13       ` Eli Zaretskii
  2020-04-13  8:50         ` 回复: " Valtteri Vuorikoski
  0 siblings, 1 reply; 31+ messages in thread
From: Eli Zaretskii @ 2020-04-13  6:13 UTC (permalink / raw)
  To: Albert; +Cc: emacs-devel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=gb18030, Size: 680 bytes --]

> From: "Albert" <georgealbert@qq.com>
> Date: Mon, 13 Apr 2020 14:06:09 +0800
> Cc: emacs-devel <emacs-devel@gnu.org>
> 
> Sometimes I need to input some chinese by open IME in evil insert mode when I press <SHIFT> to enable
> IME, when I press <ESC> to normal mode, IME is still open for chinese input, I have to press <SHIFT> to
> disable IME otherwise IME will still works for chinese input which stops me from do some commands like
> move the cursor in evil.

I see.  Do you envision situations where Emacs users that don't use
Evil or other Vi emulations would want to turn off IMM?  For example,
what about modes like view-mode and log-view-mode (and their
derivatives)?



^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: =?gb18030?B?u9i4tKO6?= [PATCH] Add IME status change support on windows natively
  2020-04-13  6:12   ` =?gb18030?B?u9i4tKO6IFtQQVRDSF0gQWRkIElNRSBzdGF0dXMgY2hhbmdlIHN1cHBvcnQgb24gd2luZG93cyBuYXRpdmVseQ==?= =?gb18030?B?QWxiZXJ0?=
@ 2020-04-13  6:24     ` Eli Zaretskii
  2020-04-13  6:27       ` =?gb18030?B?u9i4tKO6ILvYuLSjuiBbUEFUQ0hdIEFkZCBJTUUgc3RhdHVzIGNoYW5nZSBzdXBwb3J0IG9uIHdpbmRvd3MgbmF0aXZlbHk=?= =?gb18030?B?QWxiZXJ0?=
  0 siblings, 1 reply; 31+ messages in thread
From: Eli Zaretskii @ 2020-04-13  6:24 UTC (permalink / raw)
  To: Albert; +Cc: emacs-devel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=gb18030, Size: 402 bytes --]

> From: "Albert" <georgealbert@qq.com>
> Cc: "emacs-devel" <emacs-devel@gnu.org>
> Date: Mon, 13 Apr 2020 14:12:25 +0800
> 
> I try to figure out how to do this without static variables. Static variable is the simplest way to do the job
> between window thread and lisp thread right now.

I suggested to pass the information via the 2 last arguments of
PostThreadMessage.  Did you try that?

Thanks.



^ permalink raw reply	[flat|nested] 31+ messages in thread

* =?gb18030?B?u9i4tKO6ILvYuLSjuiBbUEFUQ0hdIEFkZCBJTUUgc3RhdHVzIGNoYW5nZSBzdXBwb3J0IG9uIHdpbmRvd3MgbmF0aXZlbHk=?=
  2020-04-13  6:24     ` =?gb18030?B?u9i4tKO6?= [PATCH] Add IME status change support on windows natively Eli Zaretskii
@ 2020-04-13  6:27       ` =?gb18030?B?QWxiZXJ0?=
  2020-04-13  6:32         ` =?gb18030?B?u9i4tKO6ILvYuLSjuiBbUEFUQ0hdIEFkZCBJTUUgc3RhdHVzIGNoYW5nZSBzdXBwb3J0IG9uIHdpbmRvd3MgbmF0aXZlbHk=?= =?gb18030?B?QWxiZXJ0?=
  2020-04-13  6:43         ` =?gb18030?B?u9i4tKO6ILvYuLSjug==?= [PATCH] Add IME status change support on windows natively Eli Zaretskii
  0 siblings, 2 replies; 31+ messages in thread
From: =?gb18030?B?QWxiZXJ0?= @ 2020-04-13  6:27 UTC (permalink / raw)
  To: =?gb18030?B?RWxpIFphcmV0c2tpaQ==?=; +Cc: =?gb18030?B?ZW1hY3MtZGV2ZWw=?=

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb18030", Size: 875 bytes --]

Hi, Eli,


Not yet, I'm working on it. I'm not good at windows w32 gui programming.





------------------&nbsp;ԭʼÓʼþ&nbsp;------------------
·¢¼þÈË:&nbsp;"Eli Zaretskii"<eliz@gnu.org&gt;;
·¢ËÍʱ¼ä:&nbsp;2020Äê4ÔÂ13ÈÕ(ÐÇÆÚÒ») ÏÂÎç2:24
ÊÕ¼þÈË:&nbsp;"Albert"<georgealbert@qq.com&gt;;
³­ËÍ:&nbsp;"emacs-devel"<emacs-devel@gnu.org&gt;;
Ö÷Ìâ:&nbsp;Re: »Ø¸´£º [PATCH] Add IME status change support on windows natively



&gt; From: "Albert" <georgealbert@qq.com&gt;
&gt; Cc: "emacs-devel" <emacs-devel@gnu.org&gt;
&gt; Date: Mon, 13 Apr 2020 14:12:25 +0800
&gt; 
&gt; I try to figure out how to do this without static variables. Static variable is the simplest way to do the job
&gt; between window thread and lisp thread right now.

I suggested to pass the information via the 2 last arguments of
PostThreadMessage.&nbsp; Did you try that?

Thanks.

[-- Attachment #2: Type: text/html, Size: 1293 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* =?gb18030?B?u9i4tKO6ILvYuLSjuiBbUEFUQ0hdIEFkZCBJTUUgc3RhdHVzIGNoYW5nZSBzdXBwb3J0IG9uIHdpbmRvd3MgbmF0aXZlbHk=?=
  2020-04-13  6:27       ` =?gb18030?B?u9i4tKO6ILvYuLSjuiBbUEFUQ0hdIEFkZCBJTUUgc3RhdHVzIGNoYW5nZSBzdXBwb3J0IG9uIHdpbmRvd3MgbmF0aXZlbHk=?= =?gb18030?B?QWxiZXJ0?=
@ 2020-04-13  6:32         ` =?gb18030?B?QWxiZXJ0?=
  2020-04-13  6:43         ` =?gb18030?B?u9i4tKO6ILvYuLSjug==?= [PATCH] Add IME status change support on windows natively Eli Zaretskii
  1 sibling, 0 replies; 31+ messages in thread
From: =?gb18030?B?QWxiZXJ0?= @ 2020-04-13  6:32 UTC (permalink / raw)
  To: =?gb18030?B?RWxpIFphcmV0c2tpaQ==?=; +Cc: =?gb18030?B?ZW1hY3MtZGV2ZWw=?=

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb18030", Size: 1528 bytes --]

Hi, Eli,


My source code is on branch feature/native-comp on windows, I have to figure out some merge conflicts with latest feature/native-comp on windows when I pulled the latest code from branch feature/native-comp.


I'll try pass the information via the 2 last arguments of PostThreadMessage later.





------------------&nbsp;ԭʼÓʼþ&nbsp;------------------
·¢¼þÈË:&nbsp;"Albert"<georgealbert@qq.com&gt;;
·¢ËÍʱ¼ä:&nbsp;2020Äê4ÔÂ13ÈÕ(ÐÇÆÚÒ») ÏÂÎç2:27
ÊÕ¼þÈË:&nbsp;"Eli Zaretskii"<eliz@gnu.org&gt;;
³­ËÍ:&nbsp;"emacs-devel"<emacs-devel@gnu.org&gt;;
Ö÷Ìâ:&nbsp;»Ø¸´£º »Ø¸´£º [PATCH] Add IME status change support on windows natively



Hi, Eli,


Not yet, I'm working on it. I'm not good at windows w32 gui programming.





------------------ ԭʼÓʼþ ------------------
·¢¼þÈË:&nbsp;"Eli Zaretskii"<eliz@gnu.org&gt;;
·¢ËÍʱ¼ä:&nbsp;2020Äê4ÔÂ13ÈÕ(ÐÇÆÚÒ») ÏÂÎç2:24
ÊÕ¼þÈË:&nbsp;"Albert"<georgealbert@qq.com&gt;;
³­ËÍ:&nbsp;"emacs-devel"<emacs-devel@gnu.org&gt;;
Ö÷Ìâ:&nbsp;Re: »Ø¸´£º [PATCH] Add IME status change support on windows natively



&gt; From: "Albert" <georgealbert@qq.com&gt;
&gt; Cc: "emacs-devel" <emacs-devel@gnu.org&gt;
&gt; Date: Mon, 13 Apr 2020 14:12:25 +0800
&gt; 
&gt; I try to figure out how to do this without static variables. Static variable is the simplest way to do the job
&gt; between window thread and lisp thread right now.

I suggested to pass the information via the 2 last arguments of
PostThreadMessage.&nbsp; Did you try that?

Thanks.

[-- Attachment #2: Type: text/html, Size: 2285 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: =?gb18030?B?u9i4tKO6ILvYuLSjug==?= [PATCH] Add IME status change support on windows natively
  2020-04-13  6:27       ` =?gb18030?B?u9i4tKO6ILvYuLSjuiBbUEFUQ0hdIEFkZCBJTUUgc3RhdHVzIGNoYW5nZSBzdXBwb3J0IG9uIHdpbmRvd3MgbmF0aXZlbHk=?= =?gb18030?B?QWxiZXJ0?=
  2020-04-13  6:32         ` =?gb18030?B?u9i4tKO6ILvYuLSjuiBbUEFUQ0hdIEFkZCBJTUUgc3RhdHVzIGNoYW5nZSBzdXBwb3J0IG9uIHdpbmRvd3MgbmF0aXZlbHk=?= =?gb18030?B?QWxiZXJ0?=
@ 2020-04-13  6:43         ` Eli Zaretskii
  2020-04-13  6:47           ` =?gb18030?B?u9i4tKO6ILvYuLSjuiC72Li0o7ogW1BBVENIXSBBZGQgSU1FIHN0YXR1cyBjaGFuZ2Ugc3VwcG9ydCBvbiB3aW5kb3dzIG5hdGl2ZWx5?= =?gb18030?B?QWxiZXJ0?=
  1 sibling, 1 reply; 31+ messages in thread
From: Eli Zaretskii @ 2020-04-13  6:43 UTC (permalink / raw)
  To: Albert; +Cc: emacs-devel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=gb18030, Size: 483 bytes --]

> From: "Albert" <georgealbert@qq.com>
> Cc: "emacs-devel" <emacs-devel@gnu.org>
> Date: Mon, 13 Apr 2020 14:27:06 +0800
> 
> Not yet, I'm working on it. I'm not good at windows w32 gui programming.

I'm not a w32 GUI expert either, but I'm happy to help as much as I
can.  However, I cannot test this code on my Windows systems, as they
don't have IME installed.  So I can suggest how to code this, but you
will have to test those suggestions and correct them as needed.

Thanks.



^ permalink raw reply	[flat|nested] 31+ messages in thread

* =?gb18030?B?u9i4tKO6ILvYuLSjuiC72Li0o7ogW1BBVENIXSBBZGQgSU1FIHN0YXR1cyBjaGFuZ2Ugc3VwcG9ydCBvbiB3aW5kb3dzIG5hdGl2ZWx5?=
  2020-04-13  6:43         ` =?gb18030?B?u9i4tKO6ILvYuLSjug==?= [PATCH] Add IME status change support on windows natively Eli Zaretskii
@ 2020-04-13  6:47           ` =?gb18030?B?QWxiZXJ0?=
  2020-04-13  7:05             ` 回复: 回复: 回复: [PATCH] Add IME status change support on windows natively Eli Zaretskii
  0 siblings, 1 reply; 31+ messages in thread
From: =?gb18030?B?QWxiZXJ0?= @ 2020-04-13  6:47 UTC (permalink / raw)
  To: =?gb18030?B?RWxpIFphcmV0c2tpaQ==?=; +Cc: =?gb18030?B?ZW1hY3MtZGV2ZWw=?=

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb18030", Size: 904 bytes --]

Hi, Eli,

Got it.


Thanks.

------------------&nbsp;ԭʼÓʼþ&nbsp;------------------
·¢¼þÈË:&nbsp;"Eli Zaretskii"<eliz@gnu.org&gt;;
·¢ËÍʱ¼ä:&nbsp;2020Äê4ÔÂ13ÈÕ(ÐÇÆÚÒ») ÏÂÎç2:43
ÊÕ¼þÈË:&nbsp;"Albert"<georgealbert@qq.com&gt;;
³­ËÍ:&nbsp;"emacs-devel"<emacs-devel@gnu.org&gt;;
Ö÷Ìâ:&nbsp;Re: »Ø¸´£º »Ø¸´£º [PATCH] Add IME status change support on windows natively



&gt; From: "Albert" <georgealbert@qq.com&gt;
&gt; Cc: "emacs-devel" <emacs-devel@gnu.org&gt;
&gt; Date: Mon, 13 Apr 2020 14:27:06 +0800
&gt; 
&gt; Not yet, I'm working on it. I'm not good at windows w32 gui programming.

I'm not a w32 GUI expert either, but I'm happy to help as much as I
can.&nbsp; However, I cannot test this code on my Windows systems, as they
don't have IME installed.&nbsp; So I can suggest how to code this, but you
will have to test those suggestions and correct them as needed.

Thanks.

[-- Attachment #2: Type: text/html, Size: 1244 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: 回复: 回复: 回复: [PATCH] Add IME status change support on windows natively
  2020-04-13  6:47           ` =?gb18030?B?u9i4tKO6ILvYuLSjuiC72Li0o7ogW1BBVENIXSBBZGQgSU1FIHN0YXR1cyBjaGFuZ2Ugc3VwcG9ydCBvbiB3aW5kb3dzIG5hdGl2ZWx5?= =?gb18030?B?QWxiZXJ0?=
@ 2020-04-13  7:05             ` Eli Zaretskii
  2020-04-13  7:07               ` =?gb18030?B?u9i4tKO6ILvYuLSjuiC72Li0o7ogu9i4tKO6IFtQQVRDSF0gQWRkIElNRSBzdGF0dXMgY2hhbmdlIHN1cHBvcnQgb24gd2luZG93cyBuYXRpdmVseQ==?= =?gb18030?B?QWxiZXJ0?=
  0 siblings, 1 reply; 31+ messages in thread
From: Eli Zaretskii @ 2020-04-13  7:05 UTC (permalink / raw)
  To: Albert; +Cc: emacs-devel

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.



^ permalink raw reply	[flat|nested] 31+ messages in thread

* =?gb18030?B?u9i4tKO6ILvYuLSjuiC72Li0o7ogu9i4tKO6IFtQQVRDSF0gQWRkIElNRSBzdGF0dXMgY2hhbmdlIHN1cHBvcnQgb24gd2luZG93cyBuYXRpdmVseQ==?=
  2020-04-13  7:05             ` 回复: 回复: 回复: [PATCH] Add IME status change support on windows natively Eli Zaretskii
@ 2020-04-13  7:07               ` =?gb18030?B?QWxiZXJ0?=
  2020-04-13  7:21                 ` =?gb18030?B?u9i4tKO6ILvYuLSjuiC72Li0o7ogu9i4tKO6?= [PATCH] Add IME status change support on windows natively Eli Zaretskii
  0 siblings, 1 reply; 31+ messages in thread
From: =?gb18030?B?QWxiZXJ0?= @ 2020-04-13  7:07 UTC (permalink / raw)
  To: =?gb18030?B?RWxpIFphcmV0c2tpaQ==?=; +Cc: =?gb18030?B?ZW1hY3MtZGV2ZWw=?=

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb18030", Size: 2801 bytes --]

Hi, Eli,


Thanks. I'll try it.





------------------&nbsp;ԭʼÓʼþ&nbsp;------------------
·¢¼þÈË:&nbsp;"Eli Zaretskii"<eliz@gnu.org&gt;;
·¢ËÍʱ¼ä:&nbsp;2020Äê4ÔÂ13ÈÕ(ÐÇÆÚÒ») ÏÂÎç3:05
ÊÕ¼þÈË:&nbsp;"Albert"<georgealbert@qq.com&gt;;
³­ËÍ:&nbsp;"emacs-devel"<emacs-devel@gnu.org&gt;;
Ö÷Ìâ:&nbsp;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",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Fw32_set_ime_open_status, Sw32_set_ime_open_status,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1, 1, 0,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; doc: /* Set emacs IME open status on Windows. */)
&nbsp; (Lisp_Object status)
{
&nbsp;&nbsp;&nbsp; unsigned ime_status;
&nbsp;&nbsp;&nbsp; if (NILP (status))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ime_status = 0;
&nbsp;&nbsp;&nbsp; else
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ime_status = 1;

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

&nbsp;&nbsp;&nbsp; return Qnil;
}

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

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

Then you can get rid of the 2 static variables.

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

[-- Attachment #2: Type: text/html, Size: 3277 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: =?gb18030?B?u9i4tKO6ILvYuLSjuiC72Li0o7ogu9i4tKO6?= [PATCH] Add IME status change support on windows natively
  2020-04-13  7:07               ` =?gb18030?B?u9i4tKO6ILvYuLSjuiC72Li0o7ogu9i4tKO6IFtQQVRDSF0gQWRkIElNRSBzdGF0dXMgY2hhbmdlIHN1cHBvcnQgb24gd2luZG93cyBuYXRpdmVseQ==?= =?gb18030?B?QWxiZXJ0?=
@ 2020-04-13  7:21                 ` Eli Zaretskii
  2020-04-13  7:25                   ` Eli Zaretskii
  2020-04-13  7:26                   ` =?gb18030?B?u9i4tKO6ILvYuLSjuiC72Li0o7ogu9i4tKO6ILvYuLSjuiBbUEFUQ0hdIEFkZCBJTUUgc3RhdHVzIGNoYW5nZSBzdXBwb3J0IG9uIHdpbmRvd3MgbmF0aXZlbHk=?= =?gb18030?B?QWxiZXJ0?=
  0 siblings, 2 replies; 31+ messages in thread
From: Eli Zaretskii @ 2020-04-13  7:21 UTC (permalink / raw)
  To: Albert; +Cc: emacs-devel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=gb18030, Size: 590 bytes --]

> From: "Albert" <georgealbert@qq.com>
> Cc: "emacs-devel" <emacs-devel@gnu.org>
> Date: Mon, 13 Apr 2020 15:07:19 +0800
> 
> Thanks. I'll try it.

I'm also worried by your use of w32_system_caret_hwnd as the handle of
the window for which to retrieve the input context.
w32_system_caret_hwnd is not guaranteed to be a valid handle if the
system caret is not used, i.e. if w32-use-visible-system-caret is nil
(which is the default).

So perhaps instead of using w32_system_caret_hwnd, you should use the
return value of GetFocus function, similar to what we do elsewhere in
w32_msg_pump.



^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: =?gb18030?B?u9i4tKO6ILvYuLSjuiC72Li0o7ogu9i4tKO6?= [PATCH] Add IME status change support on windows natively
  2020-04-13  7:21                 ` =?gb18030?B?u9i4tKO6ILvYuLSjuiC72Li0o7ogu9i4tKO6?= [PATCH] Add IME status change support on windows natively Eli Zaretskii
@ 2020-04-13  7:25                   ` Eli Zaretskii
  2020-04-13  7:26                   ` =?gb18030?B?u9i4tKO6ILvYuLSjuiC72Li0o7ogu9i4tKO6ILvYuLSjuiBbUEFUQ0hdIEFkZCBJTUUgc3RhdHVzIGNoYW5nZSBzdXBwb3J0IG9uIHdpbmRvd3MgbmF0aXZlbHk=?= =?gb18030?B?QWxiZXJ0?=
  1 sibling, 0 replies; 31+ messages in thread
From: Eli Zaretskii @ 2020-04-13  7:25 UTC (permalink / raw)
  To: georgealbert; +Cc: emacs-devel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=gb18030, Size: 368 bytes --]

> Date: Mon, 13 Apr 2020 10:21:50 +0300
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: emacs-devel@gnu.org
> 
> So perhaps instead of using w32_system_caret_hwnd, you should use the
> return value of GetFocus function, similar to what we do elsewhere in
> w32_msg_pump.

And if GetFocus returns NULL, skip the processing, like you do if
get_ime_context_fn returns NULL.



^ permalink raw reply	[flat|nested] 31+ messages in thread

* =?gb18030?B?u9i4tKO6ILvYuLSjuiC72Li0o7ogu9i4tKO6ILvYuLSjuiBbUEFUQ0hdIEFkZCBJTUUgc3RhdHVzIGNoYW5nZSBzdXBwb3J0IG9uIHdpbmRvd3MgbmF0aXZlbHk=?=
  2020-04-13  7:21                 ` =?gb18030?B?u9i4tKO6ILvYuLSjuiC72Li0o7ogu9i4tKO6?= [PATCH] Add IME status change support on windows natively Eli Zaretskii
  2020-04-13  7:25                   ` Eli Zaretskii
@ 2020-04-13  7:26                   ` =?gb18030?B?QWxiZXJ0?=
  2020-04-13  9:22                     ` =?gb18030?B?u9i4tKO6ILvYuLSjuiC72Li0o7ogu9i4tKO6ILvYuLSjuiBbUEFUQ0hdIEFkZCBJTUUgc3RhdHVzIGNoYW5nZSBzdXBwb3J0IG9uIHdpbmRvd3MgbmF0aXZlbHk=?= =?gb18030?B?QWxiZXJ0?=
  1 sibling, 1 reply; 31+ messages in thread
From: =?gb18030?B?QWxiZXJ0?= @ 2020-04-13  7:26 UTC (permalink / raw)
  To: =?gb18030?B?RWxpIFphcmV0c2tpaQ==?=; +Cc: =?gb18030?B?ZW1hY3MtZGV2ZWw=?=

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb18030", Size: 1205 bytes --]

Hi, Eli,


I can't get the main window handle as emacs doesn't save the main window handle after invoking createWindow(). I just found w32_system_caret_hwnd did work. I will modify the code by using GetFocus().




------------------&nbsp;ԭʼÓʼþ&nbsp;------------------
·¢¼þÈË:&nbsp;"Eli Zaretskii"<eliz@gnu.org&gt;;
·¢ËÍʱ¼ä:&nbsp;2020Äê4ÔÂ13ÈÕ(ÐÇÆÚÒ») ÏÂÎç3:21
ÊÕ¼þÈË:&nbsp;"Albert"<georgealbert@qq.com&gt;;
³­ËÍ:&nbsp;"emacs-devel"<emacs-devel@gnu.org&gt;;
Ö÷Ìâ:&nbsp;Re: »Ø¸´£º »Ø¸´£º »Ø¸´£º »Ø¸´£º [PATCH] Add IME status change support on windows natively



&gt; From: "Albert" <georgealbert@qq.com&gt;
&gt; Cc: "emacs-devel" <emacs-devel@gnu.org&gt;
&gt; Date: Mon, 13 Apr 2020 15:07:19 +0800
&gt; 
&gt; Thanks. I'll try it.

I'm also worried by your use of w32_system_caret_hwnd as the handle of
the window for which to retrieve the input context.
w32_system_caret_hwnd is not guaranteed to be a valid handle if the
system caret is not used, i.e. if w32-use-visible-system-caret is nil
(which is the default).

So perhaps instead of using w32_system_caret_hwnd, you should use the
return value of GetFocus function, similar to what we do elsewhere in
w32_msg_pump.

[-- Attachment #2: Type: text/html, Size: 1629 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: 回复: [PATCH] Add IME status change support on windows natively
  2020-04-13  6:13       ` =?gb18030?B?u9i4tKO6?= [PATCH] Add IME status change support on windows natively Eli Zaretskii
@ 2020-04-13  8:50         ` Valtteri Vuorikoski
  2020-04-13  9:06           ` Eli Zaretskii
  0 siblings, 1 reply; 31+ messages in thread
From: Valtteri Vuorikoski @ 2020-04-13  8:50 UTC (permalink / raw)
  To: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> From: "Albert" <georgealbert@qq.com>
>> Sometimes I need to input some chinese by open IME in evil insert mode when I press <SHIFT> to enable
>> IME, when I press <ESC> to normal mode, IME is still open for chinese input, I have to press <SHIFT> to
>> disable IME otherwise IME will still works for chinese input which stops me from do some commands like
>> move the cursor in evil.
>
> I see.  Do you envision situations where Emacs users that don't use
> Evil or other Vi emulations would want to turn off IMM?  For example,
> what about modes like view-mode and log-view-mode (and their
> derivatives)?

It's not a huge use case, but FWIW I could use something like this for
multiplatform key bindings, i.e. for having one Emacs binding which:

  * On Windows, toggles the native IME.
  * On Linux, toggles (for example) the ddskk elisp IME.

Mapping the same key with system native shortcuts may be difficult on
Windows. Meanwhile on Linux installing a systemwide CJK IME is somewhat
painful, so it's often convenient to use an elisp IME if CJK input is
needed only now and then. Hence having the toggle happen through Emacs
would be a nice convenience.

 -Valtteri
 



^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: 回复: [PATCH] Add IME status change support on windows natively
  2020-04-13  8:50         ` 回复: " Valtteri Vuorikoski
@ 2020-04-13  9:06           ` Eli Zaretskii
  2020-04-13  9:18             ` Valtteri Vuorikoski
  0 siblings, 1 reply; 31+ messages in thread
From: Eli Zaretskii @ 2020-04-13  9:06 UTC (permalink / raw)
  To: Valtteri Vuorikoski; +Cc: emacs-devel

> From: Valtteri Vuorikoski <vuori@notcom.org>
> Date: Mon, 13 Apr 2020 11:50:41 +0300
> 
> It's not a huge use case, but FWIW I could use something like this for
> multiplatform key bindings, i.e. for having one Emacs binding which:
> 
>   * On Windows, toggles the native IME.
>   * On Linux, toggles (for example) the ddskk elisp IME.
> 
> Mapping the same key with system native shortcuts may be difficult on
> Windows. Meanwhile on Linux installing a systemwide CJK IME is somewhat
> painful, so it's often convenient to use an elisp IME if CJK input is
> needed only now and then. Hence having the toggle happen through Emacs
> would be a nice convenience.

By ddskk do you mean a variant of the Japanese input method we have as
part of Emacs, whose dictionary is produced from SKK-DIC?  If so, you
probably toggle it with C-\ or C-u C-\.  But a native IME will have to
be toggled by a different key, and the question is then what key would
be a natural for such a binding?



^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: 回复: [PATCH] Add IME status change support on windows natively
  2020-04-13  9:06           ` Eli Zaretskii
@ 2020-04-13  9:18             ` Valtteri Vuorikoski
  0 siblings, 0 replies; 31+ messages in thread
From: Valtteri Vuorikoski @ 2020-04-13  9:18 UTC (permalink / raw)
  To: emacs-devel

On 2020-04-13 12:06, Eli Zaretskii wrote:
>> From: Valtteri Vuorikoski <vuori@notcom.org>
>> Date: Mon, 13 Apr 2020 11:50:41 +0300
>>
>> It's not a huge use case, but FWIW I could use something like this for
>> multiplatform key bindings, i.e. for having one Emacs binding which:
>>
>>    * On Windows, toggles the native IME.
>>    * On Linux, toggles (for example) the ddskk elisp IME.
>>
>> Mapping the same key with system native shortcuts may be difficult on
>> Windows. Meanwhile on Linux installing a systemwide CJK IME is somewhat
>> painful, so it's often convenient to use an elisp IME if CJK input is
>> needed only now and then. Hence having the toggle happen through Emacs
>> would be a nice convenience.
> 
> By ddskk do you mean a variant of the Japanese input method we have as
> part of Emacs, whose dictionary is produced from SKK-DIC?  If so, you
> probably toggle it with C-\ or C-u C-\.  But a native IME will have to
> be toggled by a different key, and the question is then what key would
> be a natural for such a binding?

Yes, I already have such a binding for ddskk. If I understand Albert's 
proposal correctly, with his patch I could bind C-\ to a lambda that 
checks system-type and toggles the native IME instead of ddskk when 
running on Windows (I prefer the native IME completion method to SKK).

  -Valtteri



^ permalink raw reply	[flat|nested] 31+ messages in thread

* =?gb18030?B?u9i4tKO6ILvYuLSjuiC72Li0o7ogu9i4tKO6ILvYuLSjuiBbUEFUQ0hdIEFkZCBJTUUgc3RhdHVzIGNoYW5nZSBzdXBwb3J0IG9uIHdpbmRvd3MgbmF0aXZlbHk=?=
  2020-04-13  7:26                   ` =?gb18030?B?u9i4tKO6ILvYuLSjuiC72Li0o7ogu9i4tKO6ILvYuLSjuiBbUEFUQ0hdIEFkZCBJTUUgc3RhdHVzIGNoYW5nZSBzdXBwb3J0IG9uIHdpbmRvd3MgbmF0aXZlbHk=?= =?gb18030?B?QWxiZXJ0?=
@ 2020-04-13  9:22                     ` =?gb18030?B?QWxiZXJ0?=
  2020-04-13  9:33                       ` [PATCH] Add IME status change support on windows natively Eli Zaretskii
  0 siblings, 1 reply; 31+ messages in thread
From: =?gb18030?B?QWxiZXJ0?= @ 2020-04-13  9:22 UTC (permalink / raw)
  To: =?gb18030?B?RWxpIFphcmV0c2tpaQ==?=; +Cc: =?gb18030?B?ZW1hY3MtZGV2ZWw=?=


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1: Type: text/plain; charset="gb18030", Size: 2073 bytes --]

Hi, Eli,


I modifed the code following your instruction.&nbsp; I added some more comments on functions. Test is done, IME status changes as expected.



I used GetFocus() in w32_msg_pump() now.


But I can't invoke GetFocus() in w32-get-ime-open-status(), because w32-get-ime-open-status() is invoked in lisp thread. I just use w32_system_caret_hwnd instead, if get_ime_context_fn(w32-get-ime-open-status) returns NULL, w32-get-ime-open-status() return nil.


Attachement is the modifed patch.



------------------&nbsp;ԭʼÓʼþ&nbsp;------------------
·¢¼þÈË:&nbsp;"Albert"<georgealbert@qq.com&gt;;
·¢ËÍʱ¼ä:&nbsp;2020Äê4ÔÂ13ÈÕ(ÐÇÆÚÒ») ÏÂÎç3:26
ÊÕ¼þÈË:&nbsp;"Eli Zaretskii"<eliz@gnu.org&gt;;
³­ËÍ:&nbsp;"emacs-devel"<emacs-devel@gnu.org&gt;;
Ö÷Ìâ:&nbsp;»Ø¸´£º »Ø¸´£º »Ø¸´£º »Ø¸´£º »Ø¸´£º [PATCH] Add IME status change support on windows natively



Hi, Eli,


I can't get the main window handle as emacs doesn't save the main window handle after invoking createWindow(). I just found w32_system_caret_hwnd did work. I will modify the code by using GetFocus().




------------------ ԭʼÓʼþ ------------------
·¢¼þÈË:&nbsp;"Eli Zaretskii"<eliz@gnu.org&gt;;
·¢ËÍʱ¼ä:&nbsp;2020Äê4ÔÂ13ÈÕ(ÐÇÆÚÒ») ÏÂÎç3:21
ÊÕ¼þÈË:&nbsp;"Albert"<georgealbert@qq.com&gt;;
³­ËÍ:&nbsp;"emacs-devel"<emacs-devel@gnu.org&gt;;
Ö÷Ìâ:&nbsp;Re: »Ø¸´£º »Ø¸´£º »Ø¸´£º »Ø¸´£º [PATCH] Add IME status change support on windows natively



&gt; From: "Albert" <georgealbert@qq.com&gt;
&gt; Cc: "emacs-devel" <emacs-devel@gnu.org&gt;
&gt; Date: Mon, 13 Apr 2020 15:07:19 +0800
&gt; 
&gt; Thanks. I'll try it.

I'm also worried by your use of w32_system_caret_hwnd as the handle of
the window for which to retrieve the input context.
w32_system_caret_hwnd is not guaranteed to be a valid handle if the
system caret is not used, i.e. if w32-use-visible-system-caret is nil
(which is the default).

So perhaps instead of using w32_system_caret_hwnd, you should use the
return value of GetFocus function, similar to what we do elsewhere in
w32_msg_pump.

[-- Attachment #1.2: Type: text/html, Size: 2867 bytes --]

[-- Attachment #2: w32fns.c.patch --]
[-- Type: application/octet-stream, Size: 5267 bytes --]

diff --git a/src/w32fns.c b/src/w32fns.c
index 8d714f0b8d..04de124e42 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -166,6 +166,10 @@ DECLARE_HANDLE(HMONITOR);
 typedef BOOL (WINAPI * ImmReleaseContext_Proc) (IN HWND wnd, IN HIMC context);
 typedef BOOL (WINAPI * ImmSetCompositionWindow_Proc) (IN HIMC context,
 						      IN COMPOSITIONFORM *form);
+/* for ime switch */
+typedef BOOL (WINAPI * ImmGetOpenStatus_Proc) (IN HIMC);
+typedef BOOL (WINAPI * ImmSetOpenStatus_Proc) (IN HIMC, IN BOOL);
+
 typedef HMONITOR (WINAPI * MonitorFromPoint_Proc) (IN POINT pt, IN DWORD flags);
 typedef BOOL (WINAPI * GetMonitorInfo_Proc)
   (IN HMONITOR monitor, OUT struct MONITOR_INFO* info);
@@ -185,6 +189,8 @@ DECLARE_HANDLE(HMONITOR);
 TrackMouseEvent_Proc track_mouse_event_fn = NULL;
 ImmGetCompositionString_Proc get_composition_string_fn = NULL;
 ImmGetContext_Proc get_ime_context_fn = NULL;
+ImmGetOpenStatus_Proc get_ime_open_status_fn = NULL;
+ImmSetOpenStatus_Proc set_ime_open_status_fn = NULL;
 ImmReleaseContext_Proc release_ime_context_fn = NULL;
 ImmSetCompositionWindow_Proc set_ime_composition_window_fn = NULL;
 MonitorFromPoint_Proc monitor_from_point_fn = NULL;
@@ -3305,6 +3311,7 @@ #define M(msg) { msg, # msg }
       M (WM_EMACS_SETCURSOR),
       M (WM_EMACS_SHOWCURSOR),
       M (WM_EMACS_PAINT),
+      M (WM_EMACS_IME_STATUS),
       M (WM_CHAR),
 #undef M
       { 0, 0 }
@@ -3442,6 +3449,31 @@ w32_msg_pump (deferred_msg * msg_buf)
 		  emacs_abort ();
 	      }
 	      break;
+            case WM_EMACS_IME_STATUS:
+              focus_window = GetFocus ();
+              if (focus_window == NULL)
+                break;
+
+              if (!set_ime_open_status_fn)
+                break;
+              else
+                {
+                  HIMC context;
+                  context = get_ime_context_fn (focus_window);
+                  if (!context)
+                      break;
+
+                  BOOL wParam = (BOOL) msg.wParam;
+                  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, wParam);
+                       release_ime_context_fn (focus_window, context);
+                    }
+                }
+              break;
+
 #ifdef MSG_DEBUG
 	      /* Broadcast messages make it here, so you need to be looking
 		 for something in particular for this to be useful.  */
@@ -10218,6 +10250,51 @@ DEFUN ("w32-notification-close",
 
 #endif	/* WINDOWSNT && !HAVE_DBUS */
 
+DEFUN ("w32-get-ime-open-status",
+       Fw32_get_ime_open_status, Sw32_get_ime_open_status,
+       0, 0, 0,
+       doc: /* Determines whether the IME is open or closed.
+
+This function doesn't has an argument.
+If return 1, IME is open.
+If return 0, IME is closed.*/)
+  (void)
+{
+  int retval;
+
+  HIMC context = get_ime_context_fn (w32_system_caret_hwnd);
+  if (context != NULL)
+    {
+      retval = get_ime_open_status_fn (context);
+      release_ime_context_fn (w32_system_caret_hwnd, context);
+
+      return make_fixnum (retval);
+    }
+
+  return Qnil;
+}
+
+DEFUN ("w32-set-ime-open-status",
+       Fw32_set_ime_open_status, Sw32_set_ime_open_status,
+       1, 1, 0,
+       doc: /* Opens or closes the IME on Windows.
+
+This function has one argument.
+If the argument is not nil, open or enable IME.
+If the argument is nil, close or disable IME. */)
+  (Lisp_Object status)
+{
+    unsigned ime_status;
+    if (NILP (status))
+      ime_status = 0;
+    else
+      ime_status = 1;
+
+    PostThreadMessage (dwWindowsThreadId, WM_EMACS_IME_STATUS, ime_status, 0);
+
+    return Qnil;
+}
+
 \f
 #ifdef WINDOWSNT
 /***********************************************************************
@@ -10744,6 +10821,8 @@ syms_of_w32fns (void)
   defsubr (&Sw32_notification_notify);
   defsubr (&Sw32_notification_close);
 #endif
+  defsubr (&Sw32_get_ime_open_status);
+  defsubr (&Sw32_set_ime_open_status);
 
 #ifdef WINDOWSNT
   defsubr (&Sw32_read_registry);
@@ -11032,6 +11111,11 @@ globals_of_w32fns (void)
       get_proc_addr (imm32_lib, "ImmReleaseContext");
     set_ime_composition_window_fn = (ImmSetCompositionWindow_Proc)
       get_proc_addr (imm32_lib, "ImmSetCompositionWindow");
+
+    get_ime_open_status_fn = (ImmGetOpenStatus_Proc)
+      get_proc_addr (imm32_lib, "ImmGetOpenStatus");
+    set_ime_open_status_fn = (ImmSetOpenStatus_Proc)
+      get_proc_addr (imm32_lib, "ImmSetOpenStatus");
   }
 
   HMODULE hm_kernel32 = GetModuleHandle ("kernel32.dll");
diff --git a/src/w32term.h b/src/w32term.h
index f8a8a727e8..4e9234f239 100644
--- a/src/w32term.h
+++ b/src/w32term.h
@@ -670,7 +670,8 @@ #define WM_EMACS_PAINT                 (WM_EMACS_START + 22)
 #define WM_EMACS_BRINGTOTOP            (WM_EMACS_START + 23)
 #define WM_EMACS_INPUT_READY           (WM_EMACS_START + 24)
 #define WM_EMACS_FILENOTIFY            (WM_EMACS_START + 25)
-#define WM_EMACS_END                   (WM_EMACS_START + 26)
+#define WM_EMACS_IME_STATUS            (WM_EMACS_START + 26)
+#define WM_EMACS_END                   (WM_EMACS_START + 27)
 
 #define WND_FONTWIDTH_INDEX    (0)
 #define WND_LINEHEIGHT_INDEX   (4)

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH] Add IME status change support on windows natively
  2020-04-13  9:22                     ` =?gb18030?B?u9i4tKO6ILvYuLSjuiC72Li0o7ogu9i4tKO6ILvYuLSjuiBbUEFUQ0hdIEFkZCBJTUUgc3RhdHVzIGNoYW5nZSBzdXBwb3J0IG9uIHdpbmRvd3MgbmF0aXZlbHk=?= =?gb18030?B?QWxiZXJ0?=
@ 2020-04-13  9:33                       ` Eli Zaretskii
  2020-04-13 10:02                         ` =?gb18030?B?u9i4tKO6IFtQQVRDSF0gQWRkIElNRSBzdGF0dXMgY2hhbmdlIHN1cHBvcnQgb24gd2luZG93cyBuYXRpdmVseQ==?= =?gb18030?B?QWxiZXJ0?=
  0 siblings, 1 reply; 31+ messages in thread
From: Eli Zaretskii @ 2020-04-13  9:33 UTC (permalink / raw)
  To: Albert; +Cc: emacs-devel

> From: "Albert" <georgealbert@qq.com>
> Cc: "emacs-devel" <emacs-devel@gnu.org>
> Date: Mon, 13 Apr 2020 17:22:35 +0800
> 
> I modifed the code following your instruction.  I added some more comments on functions. Test is done, IME
> status changes as expected.
> 
> I used GetFocus() in w32_msg_pump() now.

Thanks.

> But I can't invoke GetFocus() in w32-get-ime-open-status(), because w32-get-ime-open-status() is invoked
> in lisp thread. I just use w32_system_caret_hwnd instead, if get_ime_context_fn(w32-get-ime-open-status)
> returns NULL, w32-get-ime-open-status() return nil.

Do we actually need w32-get-ime-open-status?  Maybe we should simply
delete that function?  When will it be useful?

If we do need to use it, does it work to use this to find a suitable
window handle:

  HWND current_window = FRAME_W32_WINDOW (SELECTED_FRAME ());

> Attachement is the modifed patch.

Thanks.



^ permalink raw reply	[flat|nested] 31+ messages in thread

* =?gb18030?B?u9i4tKO6IFtQQVRDSF0gQWRkIElNRSBzdGF0dXMgY2hhbmdlIHN1cHBvcnQgb24gd2luZG93cyBuYXRpdmVseQ==?=
  2020-04-13  9:33                       ` [PATCH] Add IME status change support on windows natively Eli Zaretskii
@ 2020-04-13 10:02                         ` =?gb18030?B?QWxiZXJ0?=
  2020-04-13 13:10                           ` [PATCH] Add IME status change support on windows natively Eli Zaretskii
  0 siblings, 1 reply; 31+ messages in thread
From: =?gb18030?B?QWxiZXJ0?= @ 2020-04-13 10:02 UTC (permalink / raw)
  To: =?gb18030?B?RWxpIFphcmV0c2tpaQ==?=; +Cc: =?gb18030?B?ZW1hY3MtZGV2ZWw=?=


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1: Type: text/plain; charset="gb18030", Size: 1659 bytes --]

Hi, Eli,


I modified the code processing WM_EMACS_IME_STATUS,&nbsp; no need to get status of IME, just change IME status by the argument. If the user want to get status of IME to control IME status, he can write some lisp to do it.


and I modifed w32-get-ime-open-status(), get hwnd from FRAME_W32_WINDOW (SELECTED_FRAME ()).




------------------&nbsp;ԭʼÓʼþ&nbsp;------------------
·¢¼þÈË:&nbsp;"Eli Zaretskii"<eliz@gnu.org&gt;;
·¢ËÍʱ¼ä:&nbsp;2020Äê4ÔÂ13ÈÕ(ÐÇÆÚÒ») ÏÂÎç5:33
ÊÕ¼þÈË:&nbsp;"Albert"<georgealbert@qq.com&gt;;
³­ËÍ:&nbsp;"emacs-devel"<emacs-devel@gnu.org&gt;;
Ö÷Ìâ:&nbsp;Re: [PATCH] Add IME status change support on windows natively



&gt; From: "Albert" <georgealbert@qq.com&gt;
&gt; Cc: "emacs-devel" <emacs-devel@gnu.org&gt;
&gt; Date: Mon, 13 Apr 2020 17:22:35 +0800
&gt; 
&gt; I modifed the code following your instruction.&nbsp; I added some more comments on functions. Test is done, IME
&gt; status changes as expected.
&gt; 
&gt; I used GetFocus() in w32_msg_pump() now.

Thanks.

&gt; But I can't invoke GetFocus() in w32-get-ime-open-status(), because w32-get-ime-open-status() is invoked
&gt; in lisp thread. I just use w32_system_caret_hwnd instead, if get_ime_context_fn(w32-get-ime-open-status)
&gt; returns NULL, w32-get-ime-open-status() return nil.

Do we actually need w32-get-ime-open-status?&nbsp; Maybe we should simply
delete that function?&nbsp; When will it be useful?

If we do need to use it, does it work to use this to find a suitable
window handle:

&nbsp; HWND current_window = FRAME_W32_WINDOW (SELECTED_FRAME ());

&gt; Attachement is the modifed patch.

Thanks.

[-- Attachment #1.2: Type: text/html, Size: 2125 bytes --]

[-- Attachment #2: w32fns.c.patch --]
[-- Type: application/octet-stream, Size: 5086 bytes --]

diff --git a/src/w32fns.c b/src/w32fns.c
index 8d714f0b8d..7ead4c8be1 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -166,6 +166,10 @@ DECLARE_HANDLE(HMONITOR);
 typedef BOOL (WINAPI * ImmReleaseContext_Proc) (IN HWND wnd, IN HIMC context);
 typedef BOOL (WINAPI * ImmSetCompositionWindow_Proc) (IN HIMC context,
 						      IN COMPOSITIONFORM *form);
+/* for ime switch */
+typedef BOOL (WINAPI * ImmGetOpenStatus_Proc) (IN HIMC);
+typedef BOOL (WINAPI * ImmSetOpenStatus_Proc) (IN HIMC, IN BOOL);
+
 typedef HMONITOR (WINAPI * MonitorFromPoint_Proc) (IN POINT pt, IN DWORD flags);
 typedef BOOL (WINAPI * GetMonitorInfo_Proc)
   (IN HMONITOR monitor, OUT struct MONITOR_INFO* info);
@@ -185,6 +189,8 @@ DECLARE_HANDLE(HMONITOR);
 TrackMouseEvent_Proc track_mouse_event_fn = NULL;
 ImmGetCompositionString_Proc get_composition_string_fn = NULL;
 ImmGetContext_Proc get_ime_context_fn = NULL;
+ImmGetOpenStatus_Proc get_ime_open_status_fn = NULL;
+ImmSetOpenStatus_Proc set_ime_open_status_fn = NULL;
 ImmReleaseContext_Proc release_ime_context_fn = NULL;
 ImmSetCompositionWindow_Proc set_ime_composition_window_fn = NULL;
 MonitorFromPoint_Proc monitor_from_point_fn = NULL;
@@ -3305,6 +3311,7 @@ #define M(msg) { msg, # msg }
       M (WM_EMACS_SETCURSOR),
       M (WM_EMACS_SHOWCURSOR),
       M (WM_EMACS_PAINT),
+      M (WM_EMACS_IME_STATUS),
       M (WM_CHAR),
 #undef M
       { 0, 0 }
@@ -3442,6 +3449,26 @@ w32_msg_pump (deferred_msg * msg_buf)
 		  emacs_abort ();
 	      }
 	      break;
+            case WM_EMACS_IME_STATUS:
+              focus_window = GetFocus ();
+              if (focus_window == NULL)
+                break;
+
+              if (!set_ime_open_status_fn)
+                break;
+              else
+                {
+                  HIMC context;
+                  context = get_ime_context_fn (focus_window);
+                  if (!context)
+                      break;
+
+                  BOOL wParam = (BOOL) msg.wParam;
+                  set_ime_open_status_fn (context, wParam);
+                  release_ime_context_fn (focus_window, context);
+                }
+              break;
+
 #ifdef MSG_DEBUG
 	      /* Broadcast messages make it here, so you need to be looking
 		 for something in particular for this to be useful.  */
@@ -10218,6 +10254,51 @@ DEFUN ("w32-notification-close",
 
 #endif	/* WINDOWSNT && !HAVE_DBUS */
 
+DEFUN ("w32-get-ime-open-status",
+       Fw32_get_ime_open_status, Sw32_get_ime_open_status,
+       0, 0, 0,
+       doc: /* Determines whether the IME is open or closed.
+
+This function doesn't has an argument.
+If return 1, IME is open.
+If return 0, IME is closed.*/)
+  (void)
+{
+  int retval;
+  HWND current_window = FRAME_W32_WINDOW (SELECTED_FRAME ());
+  HIMC context = get_ime_context_fn (current_window);
+  if (context != NULL)
+    {
+      retval = get_ime_open_status_fn (context);
+      release_ime_context_fn (current_window, context);
+
+      return make_fixnum (retval);
+    }
+
+  return Qnil;
+}
+
+DEFUN ("w32-set-ime-open-status",
+       Fw32_set_ime_open_status, Sw32_set_ime_open_status,
+       1, 1, 0,
+       doc: /* Opens or closes the IME on Windows.
+
+This function has one argument.
+If the argument is not nil, open or enable IME.
+If the argument is nil, close or disable IME. */)
+  (Lisp_Object status)
+{
+    unsigned ime_status;
+    if (NILP (status))
+      ime_status = 0;
+    else
+      ime_status = 1;
+
+    PostThreadMessage (dwWindowsThreadId, WM_EMACS_IME_STATUS, ime_status, 0);
+
+    return Qnil;
+}
+
 \f
 #ifdef WINDOWSNT
 /***********************************************************************
@@ -10744,6 +10825,8 @@ syms_of_w32fns (void)
   defsubr (&Sw32_notification_notify);
   defsubr (&Sw32_notification_close);
 #endif
+  defsubr (&Sw32_get_ime_open_status);
+  defsubr (&Sw32_set_ime_open_status);
 
 #ifdef WINDOWSNT
   defsubr (&Sw32_read_registry);
@@ -11032,6 +11115,11 @@ globals_of_w32fns (void)
       get_proc_addr (imm32_lib, "ImmReleaseContext");
     set_ime_composition_window_fn = (ImmSetCompositionWindow_Proc)
       get_proc_addr (imm32_lib, "ImmSetCompositionWindow");
+
+    get_ime_open_status_fn = (ImmGetOpenStatus_Proc)
+      get_proc_addr (imm32_lib, "ImmGetOpenStatus");
+    set_ime_open_status_fn = (ImmSetOpenStatus_Proc)
+      get_proc_addr (imm32_lib, "ImmSetOpenStatus");
   }
 
   HMODULE hm_kernel32 = GetModuleHandle ("kernel32.dll");
diff --git a/src/w32term.h b/src/w32term.h
index f8a8a727e8..4e9234f239 100644
--- a/src/w32term.h
+++ b/src/w32term.h
@@ -670,7 +670,8 @@ #define WM_EMACS_PAINT                 (WM_EMACS_START + 22)
 #define WM_EMACS_BRINGTOTOP            (WM_EMACS_START + 23)
 #define WM_EMACS_INPUT_READY           (WM_EMACS_START + 24)
 #define WM_EMACS_FILENOTIFY            (WM_EMACS_START + 25)
-#define WM_EMACS_END                   (WM_EMACS_START + 26)
+#define WM_EMACS_IME_STATUS            (WM_EMACS_START + 26)
+#define WM_EMACS_END                   (WM_EMACS_START + 27)
 
 #define WND_FONTWIDTH_INDEX    (0)
 #define WND_LINEHEIGHT_INDEX   (4)

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH] Add IME status change support on windows natively
  2020-04-13 10:02                         ` =?gb18030?B?u9i4tKO6IFtQQVRDSF0gQWRkIElNRSBzdGF0dXMgY2hhbmdlIHN1cHBvcnQgb24gd2luZG93cyBuYXRpdmVseQ==?= =?gb18030?B?QWxiZXJ0?=
@ 2020-04-13 13:10                           ` Eli Zaretskii
  2020-04-13 13:15                             ` =?gb18030?B?u9i4tKO6IFtQQVRDSF0gQWRkIElNRSBzdGF0dXMgY2hhbmdlIHN1cHBvcnQgb24gd2luZG93cyBuYXRpdmVseQ==?= =?gb18030?B?QWxiZXJ0?=
  0 siblings, 1 reply; 31+ messages in thread
From: Eli Zaretskii @ 2020-04-13 13:10 UTC (permalink / raw)
  To: Albert; +Cc: emacs-devel

> From: "Albert" <georgealbert@qq.com>
> Cc: "emacs-devel" <emacs-devel@gnu.org>
> Date: Mon, 13 Apr 2020 18:02:17 +0800
> 
> I modified the code processing WM_EMACS_IME_STATUS,  no need to get status of IME, just change IME
> status by the argument. If the user want to get status of IME to control IME status, he can write some lisp to
> do it.
> 
> and I modifed w32-get-ime-open-status(), get hwnd from FRAME_W32_WINDOW (SELECTED_FRAME
> ()).

Thanks, I pushed the changes with a few modifications and cleanups.

Please in the future accompany your contributions with suitable commit
log messages, as described in the CONTRIBUTE file.  I did this for you
this time; please see the style I used and try to use it in your
future contributions.



^ permalink raw reply	[flat|nested] 31+ messages in thread

* =?gb18030?B?u9i4tKO6IFtQQVRDSF0gQWRkIElNRSBzdGF0dXMgY2hhbmdlIHN1cHBvcnQgb24gd2luZG93cyBuYXRpdmVseQ==?=
  2020-04-13 13:10                           ` [PATCH] Add IME status change support on windows natively Eli Zaretskii
@ 2020-04-13 13:15                             ` =?gb18030?B?QWxiZXJ0?=
  2020-04-13 13:44                               ` [PATCH] Add IME status change support on windows natively Eli Zaretskii
  0 siblings, 1 reply; 31+ messages in thread
From: =?gb18030?B?QWxiZXJ0?= @ 2020-04-13 13:15 UTC (permalink / raw)
  To: =?gb18030?B?RWxpIFphcmV0c2tpaQ==?=; +Cc: =?gb18030?B?ZW1hY3MtZGV2ZWw=?=

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb18030", Size: 1241 bytes --]

Hi, Eli,


Thanks for your help. I will follow the emacs coding standard in the future.





------------------&nbsp;ԭʼÓʼþ&nbsp;------------------
·¢¼þÈË:&nbsp;"Eli Zaretskii"<eliz@gnu.org&gt;;
·¢ËÍʱ¼ä:&nbsp;2020Äê4ÔÂ13ÈÕ(ÐÇÆÚÒ») ÍíÉÏ9:10
ÊÕ¼þÈË:&nbsp;"Albert"<georgealbert@qq.com&gt;;
³­ËÍ:&nbsp;"emacs-devel"<emacs-devel@gnu.org&gt;;
Ö÷Ìâ:&nbsp;Re: [PATCH] Add IME status change support on windows natively



&gt; From: "Albert" <georgealbert@qq.com&gt;
&gt; Cc: "emacs-devel" <emacs-devel@gnu.org&gt;
&gt; Date: Mon, 13 Apr 2020 18:02:17 +0800
&gt; 
&gt; I modified the code processing WM_EMACS_IME_STATUS,&nbsp; no need to get status of IME, just change IME
&gt; status by the argument. If the user want to get status of IME to control IME status, he can write some lisp to
&gt; do it.
&gt; 
&gt; and I modifed w32-get-ime-open-status(), get hwnd from FRAME_W32_WINDOW (SELECTED_FRAME
&gt; ()).

Thanks, I pushed the changes with a few modifications and cleanups.

Please in the future accompany your contributions with suitable commit
log messages, as described in the CONTRIBUTE file.&nbsp; I did this for you
this time; please see the style I used and try to use it in your
future contributions.

[-- Attachment #2: Type: text/html, Size: 1671 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] Add IME status change support on windows natively
  2020-04-13 13:15                             ` =?gb18030?B?u9i4tKO6IFtQQVRDSF0gQWRkIElNRSBzdGF0dXMgY2hhbmdlIHN1cHBvcnQgb24gd2luZG93cyBuYXRpdmVseQ==?= =?gb18030?B?QWxiZXJ0?=
@ 2020-04-13 13:44                               ` Eli Zaretskii
  2020-04-13 14:52                                 ` =?gb18030?B?u9i4tKO6IFtQQVRDSF0gQWRkIElNRSBzdGF0dXMgY2hhbmdlIHN1cHBvcnQgb24gd2luZG93cyBuYXRpdmVseQ==?= =?gb18030?B?QWxiZXJ0?=
  2020-04-13 15:01                                 ` =?gb18030?B?u9i4tKO6IFtQQVRDSF0gQWRkIElNRSBzdGF0dXMgY2hhbmdlIHN1cHBvcnQgb24gd2luZG93cyBuYXRpdmVseQ==?= =?gb18030?B?QWxiZXJ0?=
  0 siblings, 2 replies; 31+ messages in thread
From: Eli Zaretskii @ 2020-04-13 13:44 UTC (permalink / raw)
  To: Albert; +Cc: emacs-devel

> From: "Albert" <georgealbert@qq.com>
> Date: Mon, 13 Apr 2020 21:15:16 +0800
> Cc: emacs-devel <emacs-devel@gnu.org>
> 
> Thanks for your help. I will follow the emacs coding standard in the future.

Thanks, please try the latest master branch, I've modified the code a
little.  In particular, w32-get-ime-open-status now returns nil or t,
not 0 or 1.



^ permalink raw reply	[flat|nested] 31+ messages in thread

* =?gb18030?B?u9i4tKO6IFtQQVRDSF0gQWRkIElNRSBzdGF0dXMgY2hhbmdlIHN1cHBvcnQgb24gd2luZG93cyBuYXRpdmVseQ==?=
  2020-04-13 13:44                               ` [PATCH] Add IME status change support on windows natively Eli Zaretskii
@ 2020-04-13 14:52                                 ` =?gb18030?B?QWxiZXJ0?=
  2020-04-13 15:32                                   ` =?gb18030?B?u9i4tKO6?= [PATCH] Add IME status change support on windows natively Eli Zaretskii
  2020-04-13 15:01                                 ` =?gb18030?B?u9i4tKO6IFtQQVRDSF0gQWRkIElNRSBzdGF0dXMgY2hhbmdlIHN1cHBvcnQgb24gd2luZG93cyBuYXRpdmVseQ==?= =?gb18030?B?QWxiZXJ0?=
  1 sibling, 1 reply; 31+ messages in thread
From: =?gb18030?B?QWxiZXJ0?= @ 2020-04-13 14:52 UTC (permalink / raw)
  To: =?gb18030?B?RWxpIFphcmV0c2tpaQ==?=; +Cc: =?gb18030?B?ZW1hY3MtZGV2ZWw=?=

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb18030", Size: 3841 bytes --]

Hi, Eli,


commit 61da72 is different from commit c6ecda. We don't need to get IME status before setting IME status. If IME is the same status when setting it in the same status, IME will ignore the status changing. Emacs can be a litttle bit faster if get_ime_open_status_fn() is not invoked. 



And IME somtimes doesn't fully comply with Microsoft IME api, RIME for example. RIME which is a open source chinese ime doesn't return the status as Microsoft pinyin IME. When Microsoft pinyin IME is activated,  if Microsoft pinyin is in english mode, w32-get-ime-open-status() return nil.&nbsp;If Microsoft pinyin is in chinese mode, w32-get-ime-open-status() return t.&nbsp; We can press <SHIFT&gt; to switch between two modes by default.


When RIME is activated,  w32-get-ime-open-status() return t whenever IME is in english mode or chinese mode.&nbsp;


I modified code in w32-get-ime-open-status(). w32-get-ime-open-status() can get the status from IME.


$ git diff master -- w32fns.c
diff --git a/src/w32fns.c b/src/w32fns.c
index dddf3dc571..124b795119 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -3459,10 +3459,8 @@ w32_msg_pump (deferred_msg * msg_buf)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!context)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;

-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BOOL new_status = (msg.wParam != 0);
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BOOL ime_status = get_ime_open_status_fn (context);
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (new_status != ime_status)
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set_ime_open_status_fn (context, new_status);
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BOOL wParam = (BOOL) msg.wParam;
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set_ime_open_status_fn (context, wParam);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; release_ime_context_fn (focus_window, context);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
@@ -10261,7 +10259,7 @@ DEFUN ("w32-get-ime-open-status",
&nbsp;&nbsp;&nbsp;&nbsp; {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HWND current_window = FRAME_W32_WINDOW (sf);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HIMC context = get_ime_context_fn (current_window);
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!context)
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (context)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BOOL retval = get_ime_open_status_fn (context);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; release_ime_context_fn (current_window, context);





------------------&nbsp;ԭʼÓʼþ&nbsp;------------------
·¢¼þÈË:&nbsp;"Eli Zaretskii"<eliz@gnu.org&gt;;
·¢ËÍʱ¼ä:&nbsp;2020Äê4ÔÂ13ÈÕ(ÐÇÆÚÒ») ÍíÉÏ9:44
ÊÕ¼þÈË:&nbsp;"Albert"<georgealbert@qq.com&gt;;
³­ËÍ:&nbsp;"emacs-devel"<emacs-devel@gnu.org&gt;;
Ö÷Ìâ:&nbsp;Re: [PATCH] Add IME status change support on windows natively



&gt; From: "Albert" <georgealbert@qq.com&gt;
&gt; Date: Mon, 13 Apr 2020 21:15:16 +0800
&gt; Cc: emacs-devel <emacs-devel@gnu.org&gt;
&gt; 
&gt; Thanks for your help. I will follow the emacs coding standard in the future.

Thanks, please try the latest master branch, I've modified the code a
little.&nbsp; In particular, w32-get-ime-open-status now returns nil or t,
not 0 or 1.

[-- Attachment #2: Type: text/html, Size: 4502 bytes --]

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* =?gb18030?B?u9i4tKO6IFtQQVRDSF0gQWRkIElNRSBzdGF0dXMgY2hhbmdlIHN1cHBvcnQgb24gd2luZG93cyBuYXRpdmVseQ==?=
  2020-04-13 13:44                               ` [PATCH] Add IME status change support on windows natively Eli Zaretskii
  2020-04-13 14:52                                 ` =?gb18030?B?u9i4tKO6IFtQQVRDSF0gQWRkIElNRSBzdGF0dXMgY2hhbmdlIHN1cHBvcnQgb24gd2luZG93cyBuYXRpdmVseQ==?= =?gb18030?B?QWxiZXJ0?=
@ 2020-04-13 15:01                                 ` =?gb18030?B?QWxiZXJ0?=
  1 sibling, 0 replies; 31+ messages in thread
From: =?gb18030?B?QWxiZXJ0?= @ 2020-04-13 15:01 UTC (permalink / raw)
  To: =?gb18030?B?RWxpIFphcmV0c2tpaQ==?=; +Cc: =?gb18030?B?ZW1hY3MtZGV2ZWw=?=

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb18030", Size: 938 bytes --]

Hi, Eli,
  


w32-get-ime-open-status() can be used for IME which fully comply with Microsoft IME api.&nbsp; IME status is not changed if we set the status the same as the last status. It doesn't matter.





------------------&nbsp;ԭʼÓʼþ&nbsp;------------------
·¢¼þÈË:&nbsp;"Eli Zaretskii"<eliz@gnu.org&gt;;
·¢ËÍʱ¼ä:&nbsp;2020Äê4ÔÂ13ÈÕ(ÐÇÆÚÒ») ÍíÉÏ9:44
ÊÕ¼þÈË:&nbsp;"Albert"<georgealbert@qq.com&gt;;
³­ËÍ:&nbsp;"emacs-devel"<emacs-devel@gnu.org&gt;;
Ö÷Ìâ:&nbsp;Re: [PATCH] Add IME status change support on windows natively



&gt; From: "Albert" <georgealbert@qq.com&gt;
&gt; Date: Mon, 13 Apr 2020 21:15:16 +0800
&gt; Cc: emacs-devel <emacs-devel@gnu.org&gt;
&gt; 
&gt; Thanks for your help. I will follow the emacs coding standard in the future.

Thanks, please try the latest master branch, I've modified the code a
little.&nbsp; In particular, w32-get-ime-open-status now returns nil or t,
not 0 or 1.

[-- Attachment #2: Type: text/html, Size: 1354 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: =?gb18030?B?u9i4tKO6?= [PATCH] Add IME status change support on windows natively
  2020-04-13 14:52                                 ` =?gb18030?B?u9i4tKO6IFtQQVRDSF0gQWRkIElNRSBzdGF0dXMgY2hhbmdlIHN1cHBvcnQgb24gd2luZG93cyBuYXRpdmVseQ==?= =?gb18030?B?QWxiZXJ0?=
@ 2020-04-13 15:32                                   ` Eli Zaretskii
  0 siblings, 0 replies; 31+ messages in thread
From: Eli Zaretskii @ 2020-04-13 15:32 UTC (permalink / raw)
  To: Albert; +Cc: emacs-devel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=gb18030, Size: 1101 bytes --]

> From: "Albert" <georgealbert@qq.com>
> Cc: "emacs-devel" <emacs-devel@gnu.org>
> Date: Mon, 13 Apr 2020 22:52:30 +0800
> 
> 
> commit 61da72 is different from commit c6ecda. We don't need to get IME status before setting IME status.
> If IME is the same status when setting it in the same status, IME will ignore the status changing. Emacs can
> be a litttle bit faster if get_ime_open_status_fn() is not invoked. 
> 
> And IME somtimes doesn't fully comply with Microsoft IME api, RIME for example. RIME which is a open
> source chinese ime doesn't return the status as Microsoft pinyin IME. When Microsoft pinyin IME is
> activated, if Microsoft pinyin is in english mode, w32-get-ime-open-status() return nil. If Microsoft pinyin is in
> chinese mode, w32-get-ime-open-status() return t.  We can press <SHIFT> to switch between two modes
> by default.
> 
> When RIME is activated, w32-get-ime-open-status() return t whenever IME is in english mode or chinese
> mode. 
> 
> I modified code in w32-get-ime-open-status(). w32-get-ime-open-status() can get the status from IME.

Thanks, installed.



^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] Add IME status change support on windows natively
  2020-04-13  4:53 ` Eli Zaretskii
  2020-04-13  5:47   ` Eli Zaretskii
  2020-04-13  6:12   ` =?gb18030?B?u9i4tKO6IFtQQVRDSF0gQWRkIElNRSBzdGF0dXMgY2hhbmdlIHN1cHBvcnQgb24gd2luZG93cyBuYXRpdmVseQ==?= =?gb18030?B?QWxiZXJ0?=
@ 2020-04-14  2:13   ` Richard Stallman
  2020-04-14  5:54     ` Eli Zaretskii
  2 siblings, 1 reply; 31+ messages in thread
From: Richard Stallman @ 2020-04-14  2:13 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel, georgealbert

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > >     I added some code on src/w32fns.c and src/w32term.h to add IME status change support on windows
  > > natively like gVim did. gVim can change IME status to chinese mode  in insert mode and switch back to
  > > english mode when in normal mode natively.

  > Thanks.  Can you please tell more about the uses of this feature?  How
  > would a user of Emacs use this, and what is the effect of using this
  > on editing inside Emacs?

Do we have a comparable feature on GNU/Linux?  We should not have any
features that work only on some nonfree operating system.

Our aim is to eliminate nonfree programs, not enhance them.

-- 
Dr Richard Stallman
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] Add IME status change support on windows natively
  2020-04-14  2:13   ` [PATCH] Add IME status change support on windows natively Richard Stallman
@ 2020-04-14  5:54     ` Eli Zaretskii
  2020-04-15  2:56       ` Richard Stallman
  0 siblings, 1 reply; 31+ messages in thread
From: Eli Zaretskii @ 2020-04-14  5:54 UTC (permalink / raw)
  To: rms; +Cc: emacs-devel, georgealbert

> From: Richard Stallman <rms@gnu.org>
> Cc: georgealbert@qq.com, emacs-devel@gnu.org
> Date: Mon, 13 Apr 2020 22:13:11 -0400
> 
> Do we have a comparable feature on GNU/Linux?  We should not have any
> features that work only on some nonfree operating system.

Yes, native input methods are supported on GNU/Linux for a very long
time.



^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] Add IME status change support on windows natively
  2020-04-14  5:54     ` Eli Zaretskii
@ 2020-04-15  2:56       ` Richard Stallman
  0 siblings, 0 replies; 31+ messages in thread
From: Richard Stallman @ 2020-04-15  2:56 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: georgealbert, emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > > Do we have a comparable feature on GNU/Linux?  We should not have any
  > > features that work only on some nonfree operating system.

  > Yes, native input methods are supported on GNU/Linux for a very long
  > time.

Indeed they are.  But I could not tell that this was relevant because
I didn't know what IME does.  Now I understand.

-- 
Dr Richard Stallman
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2020-04-15  2:56 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-13  4:09 [PATCH] Add IME status change support on windows natively Albert
2020-04-13  4:53 ` Eli Zaretskii
2020-04-13  5:47   ` Eli Zaretskii
2020-04-13  6:06     ` =?gb18030?B?u9i4tKO6IFtQQVRDSF0gQWRkIElNRSBzdGF0dXMgY2hhbmdlIHN1cHBvcnQgb24gd2luZG93cyBuYXRpdmVseQ==?= =?gb18030?B?QWxiZXJ0?=
2020-04-13  6:13       ` =?gb18030?B?u9i4tKO6?= [PATCH] Add IME status change support on windows natively Eli Zaretskii
2020-04-13  8:50         ` 回复: " Valtteri Vuorikoski
2020-04-13  9:06           ` Eli Zaretskii
2020-04-13  9:18             ` Valtteri Vuorikoski
2020-04-13  6:12   ` =?gb18030?B?u9i4tKO6IFtQQVRDSF0gQWRkIElNRSBzdGF0dXMgY2hhbmdlIHN1cHBvcnQgb24gd2luZG93cyBuYXRpdmVseQ==?= =?gb18030?B?QWxiZXJ0?=
2020-04-13  6:24     ` =?gb18030?B?u9i4tKO6?= [PATCH] Add IME status change support on windows natively Eli Zaretskii
2020-04-13  6:27       ` =?gb18030?B?u9i4tKO6ILvYuLSjuiBbUEFUQ0hdIEFkZCBJTUUgc3RhdHVzIGNoYW5nZSBzdXBwb3J0IG9uIHdpbmRvd3MgbmF0aXZlbHk=?= =?gb18030?B?QWxiZXJ0?=
2020-04-13  6:32         ` =?gb18030?B?u9i4tKO6ILvYuLSjuiBbUEFUQ0hdIEFkZCBJTUUgc3RhdHVzIGNoYW5nZSBzdXBwb3J0IG9uIHdpbmRvd3MgbmF0aXZlbHk=?= =?gb18030?B?QWxiZXJ0?=
2020-04-13  6:43         ` =?gb18030?B?u9i4tKO6ILvYuLSjug==?= [PATCH] Add IME status change support on windows natively Eli Zaretskii
2020-04-13  6:47           ` =?gb18030?B?u9i4tKO6ILvYuLSjuiC72Li0o7ogW1BBVENIXSBBZGQgSU1FIHN0YXR1cyBjaGFuZ2Ugc3VwcG9ydCBvbiB3aW5kb3dzIG5hdGl2ZWx5?= =?gb18030?B?QWxiZXJ0?=
2020-04-13  7:05             ` 回复: 回复: 回复: [PATCH] Add IME status change support on windows natively Eli Zaretskii
2020-04-13  7:07               ` =?gb18030?B?u9i4tKO6ILvYuLSjuiC72Li0o7ogu9i4tKO6IFtQQVRDSF0gQWRkIElNRSBzdGF0dXMgY2hhbmdlIHN1cHBvcnQgb24gd2luZG93cyBuYXRpdmVseQ==?= =?gb18030?B?QWxiZXJ0?=
2020-04-13  7:21                 ` =?gb18030?B?u9i4tKO6ILvYuLSjuiC72Li0o7ogu9i4tKO6?= [PATCH] Add IME status change support on windows natively Eli Zaretskii
2020-04-13  7:25                   ` Eli Zaretskii
2020-04-13  7:26                   ` =?gb18030?B?u9i4tKO6ILvYuLSjuiC72Li0o7ogu9i4tKO6ILvYuLSjuiBbUEFUQ0hdIEFkZCBJTUUgc3RhdHVzIGNoYW5nZSBzdXBwb3J0IG9uIHdpbmRvd3MgbmF0aXZlbHk=?= =?gb18030?B?QWxiZXJ0?=
2020-04-13  9:22                     ` =?gb18030?B?u9i4tKO6ILvYuLSjuiC72Li0o7ogu9i4tKO6ILvYuLSjuiBbUEFUQ0hdIEFkZCBJTUUgc3RhdHVzIGNoYW5nZSBzdXBwb3J0IG9uIHdpbmRvd3MgbmF0aXZlbHk=?= =?gb18030?B?QWxiZXJ0?=
2020-04-13  9:33                       ` [PATCH] Add IME status change support on windows natively Eli Zaretskii
2020-04-13 10:02                         ` =?gb18030?B?u9i4tKO6IFtQQVRDSF0gQWRkIElNRSBzdGF0dXMgY2hhbmdlIHN1cHBvcnQgb24gd2luZG93cyBuYXRpdmVseQ==?= =?gb18030?B?QWxiZXJ0?=
2020-04-13 13:10                           ` [PATCH] Add IME status change support on windows natively Eli Zaretskii
2020-04-13 13:15                             ` =?gb18030?B?u9i4tKO6IFtQQVRDSF0gQWRkIElNRSBzdGF0dXMgY2hhbmdlIHN1cHBvcnQgb24gd2luZG93cyBuYXRpdmVseQ==?= =?gb18030?B?QWxiZXJ0?=
2020-04-13 13:44                               ` [PATCH] Add IME status change support on windows natively Eli Zaretskii
2020-04-13 14:52                                 ` =?gb18030?B?u9i4tKO6IFtQQVRDSF0gQWRkIElNRSBzdGF0dXMgY2hhbmdlIHN1cHBvcnQgb24gd2luZG93cyBuYXRpdmVseQ==?= =?gb18030?B?QWxiZXJ0?=
2020-04-13 15:32                                   ` =?gb18030?B?u9i4tKO6?= [PATCH] Add IME status change support on windows natively Eli Zaretskii
2020-04-13 15:01                                 ` =?gb18030?B?u9i4tKO6IFtQQVRDSF0gQWRkIElNRSBzdGF0dXMgY2hhbmdlIHN1cHBvcnQgb24gd2luZG93cyBuYXRpdmVseQ==?= =?gb18030?B?QWxiZXJ0?=
2020-04-14  2:13   ` [PATCH] Add IME status change support on windows natively Richard Stallman
2020-04-14  5:54     ` Eli Zaretskii
2020-04-15  2:56       ` Richard Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).