From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yichao Yu Newsgroups: gmane.emacs.bugs Subject: bug#10867: 26.3; XIM preedit/status font handling Date: Fri, 21 Aug 2020 00:53:02 -0400 Message-ID: References: <83bljl7ejw.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27317"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Xuetian Weng , 10867@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Aug 21 06:54:15 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1k8z4A-00070f-Rm for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 21 Aug 2020 06:54:14 +0200 Original-Received: from localhost ([::1]:38108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k8z49-0006M1-Ud for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 21 Aug 2020 00:54:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52664) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8z3z-0006Fj-0x for bug-gnu-emacs@gnu.org; Fri, 21 Aug 2020 00:54:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33207) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k8z3y-0006Jg-OT for bug-gnu-emacs@gnu.org; Fri, 21 Aug 2020 00:54:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1k8z3y-0005H4-Ll for bug-gnu-emacs@gnu.org; Fri, 21 Aug 2020 00:54:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Yichao Yu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 21 Aug 2020 04:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10867 X-GNU-PR-Package: emacs Original-Received: via spool by 10867-submit@debbugs.gnu.org id=B10867.159798560220214 (code B ref 10867); Fri, 21 Aug 2020 04:54:02 +0000 Original-Received: (at 10867) by debbugs.gnu.org; 21 Aug 2020 04:53:22 +0000 Original-Received: from localhost ([127.0.0.1]:44751 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k8z3K-0005Fy-Fv for submit@debbugs.gnu.org; Fri, 21 Aug 2020 00:53:22 -0400 Original-Received: from mail-il1-f193.google.com ([209.85.166.193]:33456) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k8z3H-0005Fj-DQ for 10867@debbugs.gnu.org; Fri, 21 Aug 2020 00:53:21 -0400 Original-Received: by mail-il1-f193.google.com with SMTP id r13so426448iln.0 for <10867@debbugs.gnu.org>; Thu, 20 Aug 2020 21:53:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LOYdq/Ps3e7GAxX0QcDsZus9VZtDtmJGdVeDtsZ/+cA=; b=Op1poCcueEZ7nv0IDklFmyut3qHl418d2GH7RqfbTgYNfSeR21q9dTj7Lwfoanqxmo eFmY0PA9Mejuh9TQdnptbztk+rm+Wn6nhcp9kWqs9aG9QhPHPbx0g0A6UTusYmxsIRs0 u1B23PZgEQ+aIy/PpUkvITgv0NM8uAxwAoIsZlO/unVVrvMa+4mXP+M8ZYDM2oZeMfxI J24dq4TLFL/8CfcRUOAINQKKpjRN3IV+71+vN1m02aJdltHuJ9IsEkNWMC+7VZg2U8EC tz3t5ktB8ScMbPKr9a7YanYpXDQvEDpIebwI2cfYkO2orEb6UuOfs+27fWxPcbDRw+oJ fSdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LOYdq/Ps3e7GAxX0QcDsZus9VZtDtmJGdVeDtsZ/+cA=; b=fMPzLnbL8VqJQLOO8a8fn/NpAx2tAb4TM42wvYGthrF7kQhxx8Vb0WwTQY5HU2N2sF ocbrZ2qjIvOzCbclrfz/hJ32QExWmQ5j1pUWbLxWBLmr/H0fyTWbHHHnV6R78CecK8zF Ly1jnLUxj33xy6hFWcU5MfEb8F6sUpEP6kyrDo/CkWU+gnoZVUC4iu98GyunKOZV+P2W y25vHEX3e8ZZpZYs8WoIF0hBkyEABbCAitTDhzHZ7WYGWLW8BjIcY/6YOZkE58LWqhkf 4mFgX3gyOkln/Vvpm1sTU9UnUuOTCRgjyMyu8YtHXrK1lA9xU0tcK5i7ABGndzMo63fh /yhg== X-Gm-Message-State: AOAM53115NBSPlQVMXBPTU/hgu8MnY/KuXD9ufHmme79APer2RQG0pls HVKCo/eXaLby0k/kV+mDnEupl4T24X13zrtc90c= X-Google-Smtp-Source: ABdhPJznPYrcWAIXJgzAYsmu7R1QouGK0h4Ja+FPA1POmNWxRonCcYXxgMlz9dkF7m4Kqp+ea9zOvJZUNcyaFR9AXmQ= X-Received: by 2002:a05:6e02:c2e:: with SMTP id q14mr1208697ilg.286.1597985593611; Thu, 20 Aug 2020 21:53:13 -0700 (PDT) In-Reply-To: <83bljl7ejw.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:185810 Archived-At: > Thanks. Can someone with access to a system with this issue and > sufficient knowledge of what's going on please review this patch? And some new findings and a more aggressive and robust fix. 1. It's fine to set status area and preedit position even without the corresponding xim style set. The input method will handle that just fine. In emacs, doing that for status area cause error due to uninitialized memory (`needed` is not initialized in `xic_set_statusarea` under such condition) so that one still needs to be done conditionally. 2. Without XIMPreeditPosition and XIMStatusArea, xlib will not require the fonts to be set and there's no issue with not finding font or finding too many fonts anymore. All in all, the following patch fixes all the issues cleanly. Note that this is exactly what gtk3 does (https://github.com/GNOME/gtk/blob/de04aaf82db8d694af7d42ab6bb2e26d3ef0c947/modules/input/gtkimcontextxim.c#L183), i.e. it does not accept either XIMPreeditPosition or XIMStatusArea. (It does accept callback but that is for "on-the-spot" style I believe and is not implemented in emacs anyway.) That's why I expect this to work with all modern input methods. The support for cursor following (xic_set_preeditarea) as well as the problematic approach involving the font was introduced in https://github.com/emacs-mirror/emacs/commit/5a7df7d75faa0f8921fd6a9591cdf6836d89941b 20.5 years ago. ``` diff --git a/src/xfns.c b/src/xfns.c index 78f977bf0a..ef4e2abfa5 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -2322,23 +2322,6 @@ hack_wm_protocols (struct frame *f, Widget widget) static XIMStyle best_xim_style (XIMStyles *); -/* Supported XIM styles, ordered by preference. */ - -static const XIMStyle supported_xim_styles[] = -{ - XIMPreeditPosition | XIMStatusArea, - XIMPreeditPosition | XIMStatusNothing, - XIMPreeditPosition | XIMStatusNone, - XIMPreeditNothing | XIMStatusArea, - XIMPreeditNothing | XIMStatusNothing, - XIMPreeditNothing | XIMStatusNone, - XIMPreeditNone | XIMStatusArea, - XIMPreeditNone | XIMStatusNothing, - XIMPreeditNone | XIMStatusNone, - 0, -}; - - #if defined HAVE_X_WINDOWS && defined USE_X_TOOLKIT /* Create an X fontset on frame F with base font name BASE_FONTNAME. */ @@ -2622,15 +2605,8 @@ xic_free_xfontset (struct frame *f) static XIMStyle best_xim_style (XIMStyles *xim) { - int i, j; - int nr_supported = ARRAYELTS (supported_xim_styles); - - for (i = 0; i < nr_supported; ++i) - for (j = 0; j < xim->count_styles; ++j) - if (supported_xim_styles[i] == xim->supported_styles[j]) - return supported_xim_styles[i]; - - /* Return the default style. */ + /* Return the default style. This is what GTK3 uses and + should work fine with all modern input methods. */ return XIMPreeditNothing | XIMStatusNothing; } diff --git a/src/xterm.c b/src/xterm.c index 2e0407aff4..0a242ad214 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -9704,7 +9704,7 @@ x_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, int x, #ifdef HAVE_X_I18N if (w == XWINDOW (f->selected_window)) - if (FRAME_XIC (f) && (FRAME_XIC_STYLE (f) & XIMPreeditPosition)) + if (FRAME_XIC (f)) xic_set_preeditarea (w, x, y); #endif } @@ -10387,11 +10387,8 @@ xim_instantiate_callback (Display *display, XPointer client_data, XPointer call_ create_frame_xic (f); if (FRAME_XIC_STYLE (f) & XIMStatusArea) xic_set_statusarea (f); - if (FRAME_XIC_STYLE (f) & XIMPreeditPosition) - { - struct window *w = XWINDOW (f->selected_window); - xic_set_preeditarea (w, w->cursor.x, w->cursor.y); - } + struct window *w = XWINDOW (f->selected_window); + xic_set_preeditarea (w, w->cursor.x, w->cursor.y); } } ```