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#46180: Patch to fix input method cursor location for the feature/pgtk branch Date: Fri, 29 Jan 2021 14:47:18 -0500 Message-ID: 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="6984"; mail-complaints-to="usenet@ciao.gmane.io" To: 46180@debbugs.gnu.org, masm+github@masm11.me, wengxt@gmail.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jan 29 20:48:40 2021 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 1l5Zl2-0001l0-5q for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 29 Jan 2021 20:48:40 +0100 Original-Received: from localhost ([::1]:35296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l5Zl1-0001JP-5W for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 29 Jan 2021 14:48:39 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44988) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l5ZkR-0000ta-UM for bug-gnu-emacs@gnu.org; Fri, 29 Jan 2021 14:48:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41451) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l5ZkQ-0006uB-KG for bug-gnu-emacs@gnu.org; Fri, 29 Jan 2021 14:48:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l5ZkQ-00083A-JG for bug-gnu-emacs@gnu.org; Fri, 29 Jan 2021 14:48:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Yichao Yu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 29 Jan 2021 19:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 46180 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org, Yuuki Harano , Xuetian Weng Original-Received: via spool by submit@debbugs.gnu.org id=B.161194965530911 (code B ref -1); Fri, 29 Jan 2021 19:48:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 29 Jan 2021 19:47:35 +0000 Original-Received: from localhost ([127.0.0.1]:52997 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l5Zjy-00082U-JX for submit@debbugs.gnu.org; Fri, 29 Jan 2021 14:47:35 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:55700) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l5Zjx-00082N-Ro for submit@debbugs.gnu.org; Fri, 29 Jan 2021 14:47:34 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44936) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l5Zjx-0000S5-IV for bug-gnu-emacs@gnu.org; Fri, 29 Jan 2021 14:47:33 -0500 Original-Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]:39428) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l5Zjv-0006fj-RI for bug-gnu-emacs@gnu.org; Fri, 29 Jan 2021 14:47:33 -0500 Original-Received: by mail-lj1-x233.google.com with SMTP id u4so10309811ljh.6 for ; Fri, 29 Jan 2021 11:47:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=16hwWKPJ4sw/rXpQqr9jL5CvyMPaUngI/tFr2+jz4KE=; b=H/fCfmlg2wy/DYHpUfMsdjJhyRSGIB2Gn7yX3r/fzKBpZu/NhlGkw5z59WoOkuOjr7 JCWrYzY9CLZ+CoMYstZBWFoG1eztG50AGvwoaQaMOHcKlv69EBFr9U19cJGREFv9Gx1B tfHaU7+yOYNgPYrrkdX6oIk985v0Epex3d58F973f/TlEDpPny8joGC5AimzXbdZwbLN 4hfw2M4VZF6e0Nj8Rj+wLbAm0vcHwhr0px6ZGKL6HNY+fv5CexJAIb5MjA41BZd7CM5H DGyex/Wos0gNLMQEs9doWmBlvVvty6/XSQ8rjlNWd0jKhxFjFS4Lh2Argr7h12Lx0/kY cKOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=16hwWKPJ4sw/rXpQqr9jL5CvyMPaUngI/tFr2+jz4KE=; b=osVzAi389CMB06t22ggip01D/clTA461cYBfkgpAYnmTP74a5eh/cYYqCUYhAUx1/n ICrqhc4Vwy6tqz0U/Ib1dXzBBhFh109YcZ8vcYhpSj5iyQV8qcJn4/FD16AEj7eQmh7C dxx/bfhV88YHLqUJ2mpUEr7k15i5DS+xTSt9+xm1MCjlipHC5BzUsU0BAm4mTbrCqP8r troKlZxWJOze4sKqx1PmVW+j8faL4wG8JeKVhNAqCvYUFxiKCjLwbCHLraivm4dFho3u B1LOayJRKYNsgDTXGkUTR3p15DqeeLR/q9briW/AHmMUv98UeTQOKgV+jak6UAe/i6LA UMPw== X-Gm-Message-State: AOAM532w7BzK/k/aoHuAC8ZK60H4sbxkk4DaaN1Kay8/8z57jRZgqMA6 24vztSwilNMkX8v9ayFIcZVA8ql5hMfTfZjRitO+ldAuIwA+Tw== X-Google-Smtp-Source: ABdhPJwB3+BaeCJrMt65HOxfYFVec2EnJ3O9czxbROA6TPXlzsZoVWsRISQKj0rYIINtwiEXX8UogK3b74gCXqGZYyc= X-Received: by 2002:a2e:531d:: with SMTP id h29mr3207471ljb.115.1611949649335; Fri, 29 Jan 2021 11:47:29 -0800 (PST) Received-SPF: pass client-ip=2a00:1450:4864:20::233; envelope-from=yyc1992@gmail.com; helo=mail-lj1-x233.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:198883 Archived-At: See patch attached below. The pgtk branch carried over some old XIM code that isn't valid in such configuration. This makes sure the gtk immodule can get the correct cursor location. I guess this does mean that the patch I submitted a few months ago to fix/improve XIM usage would not be useful for much longer but hopefully it's for the better =). ----------------------------------- >From be5764d617b2a5fe3b26ddab1e739dad6d393825 Mon Sep 17 00:00:00 2001 From: Yichao Yu Date: Fri, 29 Jan 2021 14:38:53 -0500 Subject: [PATCH] Add support for setting cursor location using Gtk IM Context The existing XIC implementation doesn't work when using Gtk IM Context. Instead, `gtk_im_context_set_cursor_location` should be used to update the cursor information for the input method. Tested with fcitx5. --- src/pgtkim.c | 12 ++++++++++++ src/pgtkterm.c | 12 ++++++++---- src/pgtkterm.h | 2 ++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/pgtkim.c b/src/pgtkim.c index 68f83d2c6e..ba69a27501 100644 --- a/src/pgtkim.c +++ b/src/pgtkim.c @@ -210,6 +210,18 @@ pgtk_im_filter_keypress (struct frame *f, GdkEventKey * ev) return false; } +void +pgtk_im_set_cursor_location (struct frame *f, int x, int y, int width, + int height) +{ + struct pgtk_display_info *dpyinfo = FRAME_DISPLAY_INFO (f); + if (dpyinfo->im.context != NULL && dpyinfo->im.focused_frame == f) + { + GdkRectangle area = { x, y, width, height }; + gtk_im_context_set_cursor_location (dpyinfo->im.context, &area); + } +} + static void pgtk_im_use_context (struct pgtk_display_info *dpyinfo, bool use_p) { diff --git a/src/pgtkterm.c b/src/pgtkterm.c index 44e1f3e296..7d46053d31 100644 --- a/src/pgtkterm.c +++ b/src/pgtkterm.c @@ -2878,6 +2878,7 @@ pgtk_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, int x, int y, enum text_cursor_kinds cursor_type, int cursor_width, bool on_p, bool active_p) { + struct frame *f = XFRAME (w->frame); PGTK_TRACE ("draw_window_cursor: %d, %d, %d, %d, %d, %d.", x, y, cursor_type, cursor_width, on_p, active_p); if (on_p) @@ -2922,11 +2923,14 @@ pgtk_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)) - xic_set_preeditarea (w, x, y); -#endif + { + int frame_x = + WINDOW_TO_FRAME_PIXEL_X (w, x) + WINDOW_LEFT_FRINGE_WIDTH (w); + int frame_y = WINDOW_TO_FRAME_PIXEL_Y (w, y); + pgtk_im_set_cursor_location (f, frame_x, frame_y, w->phys_cursor_width, + w->phys_cursor_height); + } } } diff --git a/src/pgtkterm.h b/src/pgtkterm.h index 5e71f93998..07d7fc10c6 100644 --- a/src/pgtkterm.h +++ b/src/pgtkterm.h @@ -653,6 +653,8 @@ #define FIRST_CHAR_POSITION(f) \ extern void pgtk_im_focus_in (struct frame *f); extern void pgtk_im_focus_out (struct frame *f); extern bool pgtk_im_filter_keypress (struct frame *f, GdkEventKey * ev); +extern void pgtk_im_set_cursor_location (struct frame *f, int x, int y, + int width, int height); extern void pgtk_im_init (struct pgtk_display_info *dpyinfo); extern void pgtk_im_finish (struct pgtk_display_info *dpyinfo); -- 2.30.0