From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: =?utf-8?B?5Zue5aSN77yaIOWbnuWkje+8miDlm57lpI3vvJo=?= [PATCH] Add IME status change support on windows natively Date: Mon, 13 Apr 2020 10:05:30 +0300 Message-ID: <83a73fkgqt.fsf@gnu.org> References: <83k12kj8b7.fsf@gnu.org> <83d08bkimi.fsf@gnu.org> <83blnvkhrx.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="81321"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: "Albert" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Apr 13 09:06:32 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jNtAu-000L1r-Ft for ged-emacs-devel@m.gmane-mx.org; Mon, 13 Apr 2020 09:06:32 +0200 Original-Received: from localhost ([::1]:41042 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jNtAt-0006Zi-Iv for ged-emacs-devel@m.gmane-mx.org; Mon, 13 Apr 2020 03:06:31 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35740) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jNtAL-0005ww-8l for emacs-devel@gnu.org; Mon, 13 Apr 2020 03:05:58 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:45384) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1jNtAK-0008CY-32; Mon, 13 Apr 2020 03:05:56 -0400 Original-Received: from [176.228.60.248] (port=1272 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jNtA7-0005zn-Fp; Mon, 13 Apr 2020 03:05:46 -0400 In-Reply-To: (georgealbert@qq.com) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:246896 Archived-At: 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.