From unknown Tue Jun 17 22:29:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#46180: Patch to fix input method cursor location for the feature/pgtk branch 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-GNU-PR-Keywords: To: 46180@debbugs.gnu.org, masm+github@masm11.me, wengxt@gmail.com X-Debbugs-Original-To: bug-gnu-emacs@gnu.org, Yuuki Harano , Xuetian Weng Received: via spool by submit@debbugs.gnu.org id=B.161194965530911 (code B ref -1); Fri, 29 Jan 2021 19:48:02 +0000 Received: (at submit) by debbugs.gnu.org; 29 Jan 2021 19:47:35 +0000 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 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 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 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 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) MIME-Version: 1.0 From: Yichao Yu Date: Fri, 29 Jan 2021 14:47:18 -0500 Message-ID: Content-Type: text/plain; charset="UTF-8" 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-Spam-Score: -1.1 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.1 (--) 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 From unknown Tue Jun 17 22:29:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#46180: Patch to fix input method cursor location for the feature/pgtk branch Resent-From: Yuuki Harano Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 30 Jan 2021 16:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46180 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: yyc1992@gmail.com, 46180@debbugs.gnu.org Cc: wengxt@gmail.com Received: via spool by 46180-submit@debbugs.gnu.org id=B46180.161202322523933 (code B ref 46180); Sat, 30 Jan 2021 16:14:02 +0000 Received: (at 46180) by debbugs.gnu.org; 30 Jan 2021 16:13:45 +0000 Received: from localhost ([127.0.0.1]:55682 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l5ssX-0006Ds-Ka for submit@debbugs.gnu.org; Sat, 30 Jan 2021 11:13:44 -0500 Received: from shiro.masm11.me ([150.95.182.25]:51496) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l5rJA-0007Vb-DT for 46180@debbugs.gnu.org; Sat, 30 Jan 2021 09:33:06 -0500 Received: from luna.pink.masm11.me (KD111239254026.au-net.ne.jp [111.239.254.26]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by shiro.masm11.me (Postfix) with ESMTPSA id 6EB8DC0178; Sat, 30 Jan 2021 23:33:01 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=masm11.me; s=202002; t=1612017181; bh=HIVH9e4FUdW2HuEPwdkmt8ESxZFsjnHnOxCls8n1RQY=; h=Date:To:Cc:Subject:From:In-Reply-To:References; b=Fj1bch+dyeGJpr2xo33uIA5R33f0BeZyfkzpaytcacgB0W5DNSTp7m0p+qyc/v/5j g/RAUYV80pXyAs8AWDR2l3JntVDYY3EEdAmGKY4tlrb0aiLCE1jcJ9BHo1PNShCXx3 kXjRgofEg2efsZVnRUI7k068j9C7QyOG/t71xuUY= Date: Sat, 30 Jan 2021 23:32:54 +0900 (JST) Message-Id: <20210130.233254.961198246273404352.masm@luna.pink.masm11.me> From: Yuuki Harano In-Reply-To: References: Organization: Ingage Inc. X-Mailer: Mew version 6.8 on Emacs 28.0 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Mailman-Approved-At: Sat, 30 Jan 2021 11:13:40 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Thank you for the patch. I tried it. It seems to be good, and I pushed it. -- Yuuki Harano From unknown Tue Jun 17 22:29:55 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Yichao Yu Subject: bug#46180: closed (Re: bug#46180: Patch to fix input method cursor location for the feature/pgtk branch) Message-ID: References: X-Gnu-PR-Message: they-closed 46180 X-Gnu-PR-Package: emacs Reply-To: 46180@debbugs.gnu.org Date: Wed, 21 Apr 2021 03:21:03 +0000 Content-Type: multipart/mixed; boundary="----------=_1618975263-22578-1" This is a multi-part message in MIME format... ------------=_1618975263-22578-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #46180: Patch to fix input method cursor location for the feature/pgtk bran= ch which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 46180@debbugs.gnu.org. --=20 46180: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D46180 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1618975263-22578-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 46180-done) by debbugs.gnu.org; 21 Apr 2021 03:20:05 +0000 Received: from localhost ([127.0.0.1]:56603 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lZ3PJ-0005pb-0x for submit@debbugs.gnu.org; Tue, 20 Apr 2021 23:20:05 -0400 Received: from mail-pf1-f179.google.com ([209.85.210.179]:35802) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lZ3PH-0005oT-PJ for 46180-done@debbugs.gnu.org; Tue, 20 Apr 2021 23:20:04 -0400 Received: by mail-pf1-f179.google.com with SMTP id h15so9652082pfv.2 for <46180-done@debbugs.gnu.org>; Tue, 20 Apr 2021 20:20:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:in-reply-to:references:user-agent :mime-version:date:message-id:subject:to:cc; bh=q6nB21Z/TJpweoZSM4xSZVf6/dysH7d6B93yDgj2RDA=; b=DUk9DKTzI+I9UIDPr4cZJ+FDuH2dodyH7MmEBgT2MmEOX63a9y1UlE7N39PVDi9ITB jIWPJ31x4V38osF5NTyA1sPleMjbiDZ7bNme/yF9pRtdAr5CiL6E2hmMcGGM8LaEpH5V X92ZxV9GrupApr/AADuaT6tuDqXtNkHjLqR0kprPkCTtu+0GzyzuBbm/vU0wVOWXLAU8 X97rotH3iTX6e6bv40c1EM2JxKtFeIaqZrlkm2VlU6HT+kqlt6pGTN3WqSY1o603iN8d 9YlVlLo0jAvOXjK8ZM/A6rYS4FrqlYLfrVqj6OCboAMudGf12Iy0t6GV3vw/C39D25EI OYWg== X-Gm-Message-State: AOAM532b+qSjGvKhPHz6WiHNNoq2lbM3/UmLISH+NU3jdTsCaTYazJQ/ Q9AYippFrNHO7GnSUPBCYFEO2cFnFAhA/YBBdhs= X-Google-Smtp-Source: ABdhPJxOgwW9kGU++mcxwmdyxQMK/ztO343cCpq6ZObiXJRFqDTVrj4/Q5/DdZyHEhIZcb6b8is/ELRIERca/iqUMWc= X-Received: by 2002:a63:a16:: with SMTP id 22mr6198033pgk.345.1618975198354; Tue, 20 Apr 2021 20:19:58 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Tue, 20 Apr 2021 22:19:58 -0500 From: Stefan Kangas In-Reply-To: <20210130.233254.961198246273404352.masm@luna.pink.masm11.me> (Yuuki Harano's message of "Sat, 30 Jan 2021 23:32:54 +0900 (JST)") References: <20210130.233254.961198246273404352.masm@luna.pink.masm11.me> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Date: Tue, 20 Apr 2021 22:19:58 -0500 Message-ID: Subject: Re: bug#46180: Patch to fix input method cursor location for the feature/pgtk branch To: Yuuki Harano Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 46180-done Cc: yyc1992@gmail.com, 46180-done@debbugs.gnu.org, wengxt@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) Yuuki Harano writes: > Thank you for the patch. > > I tried it. It seems to be good, and I pushed it. This seems to have been pushed. I'm therefore closing this bug report. ------------=_1618975263-22578-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 29 Jan 2021 19:47:35 +0000 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 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 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 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 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) MIME-Version: 1.0 From: Yichao Yu Date: Fri, 29 Jan 2021 14:47:18 -0500 Message-ID: Subject: Patch to fix input method cursor location for the feature/pgtk branch To: bug-gnu-emacs@gnu.org, Yuuki Harano , Xuetian Weng Content-Type: text/plain; charset="UTF-8" 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-Spam-Score: -1.1 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.1 (--) 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 ------------=_1618975263-22578-1--