From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu Newsgroups: gmane.emacs.devel Subject: Re: Moving point after character when clicking latter half of it Date: Thu, 13 Jul 2023 08:31:30 +0800 Message-ID: <877cr4bqjh.fsf@yahoo.com> References: <2255158.iZASKD2KPV@silef> <21946289.EfDdHjke4D@anduin> <87mt02ar4e.fsf@yahoo.com> <3242369.aeNJFYEL58@anduin> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40467"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , emacs-devel@gnu.org To: Moritz Maxeiner Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Jul 13 02:32:41 2023 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 1qJkG8-000ACM-9p for ged-emacs-devel@m.gmane-mx.org; Thu, 13 Jul 2023 02:32:40 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qJkFN-0003Mw-7e; Wed, 12 Jul 2023 20:31:53 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJkFK-0003MZ-Oi for emacs-devel@gnu.org; Wed, 12 Jul 2023 20:31:51 -0400 Original-Received: from sonic309-22.consmr.mail.ne1.yahoo.com ([66.163.184.148]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qJkFC-0001p1-AQ for emacs-devel@gnu.org; Wed, 12 Jul 2023 20:31:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1689208298; bh=BZUXAKTMlztaD4XuZ8D92cLMdGweNsQap5h8rsz5T7A=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=l3lSXzhZbEpVc6TJyf6eomIbPMVAlyy8R9KEpr0VpGi8tVJjET6kMkaqHn5m19I9/nB+rx/n+G41fWRBquoGbgrEw9XyybWzcKUGOU4FiQ01Sm1rMJhR6Kk2kMY6Q0GN0AooZZTEZ4LfmieVk8SI/kVjp2FwAULt6YubTuyVGWR2YAB6AfOrkH6fL4nNlb35MFjnw6u9Qs94DPyYk9nz0F72fiWf9bqZUSyNy7tU1UiFVNkUNPnJd9ZJ+f4C2VTeIh5Beu1G1fd9zctY3jrPDqjquGdfQLWvUaV0CuWlEi7hVd7O56K+jXa+LewGpV2HZXgsOdkSIYirZXeHqz9x6A== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1689208298; bh=9rD/1/b9EpMehqgljbkI6eIiKaXSOCMjHLhCYVTmPmB=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=knANfHFjLnxCq+3qiL6hNncaT9j+BxSRk009uwmXv5KQmPKyT2/t9NWUUqWGhELX2IMwq8gby6RJRuEAFq1B6ZxQkq7v5Zcr2rgOAsn6q9eGduqnrQ6L7/N5IR5CMQHjr0lSvHvrodHQnVU/XdIifFcVgNBrIBINSKD1R3iKnXqlq/tWiBQhVTFMMnT115DUi0dx/EAaGQcnUz5uWCci+j/yuOrgq8WCjsVcXJqBfqWKKOgQGyyS8ia0651ExF1A2NSjLzw7emU9DbyTUcXwaNQv0F8nCYFSfuQttn3hMpu5JLNs3LagSpB1kQuxWSxddK3+KjzllpyFe41kLu9eww== X-YMail-OSG: OptcCnQVM1kmpa8zMr5G_37GcxOXgQy_0sCgPZEnhXyD5UmVRBK17RVhsgiUzw2 gNv8hiXpC8UAKJs6f8.HTB728CelUmRJxp2p88DzodgGSchDYMsXboBEOQHov781duw1c3PGPhsE etNpnAgtc45oC7dGmEe9mWVx0GLOgjSIrnEUdcy4e2LZgbEWPq0YxmwiVJQcpWXRivsgaWeVmxIS yPzl0BZTfZYTd5L9slJrfkwFjTqNCBHmgwoxXCZOK8dO61s245pBbIXv9EKm1B_NyKwBkhdP4VRI fTCi52pMdkWYaljakkkNxRegPX68SWxhkZX6OSw1xiMRtoYovD2OUjnUaPFD0XsnyXlKPEyRBLA6 f8rC0XUSYQz7wDepIUuBweJvUg8oA2ZJ349my1uTiUm04tWkda9aiXYfSosEYhYHqd4eCmnAxU5s IP.duCDIWyTIsIBbxsu3h6dZhO.2QV3_3FwpcQXzDGiabpAoCFVCyZ0dpoeeAD7PfAzOvFkAvz4n pVI4ABXKaVJEbLRnkQSS9v55pGFXEBSqGUP3agnQA420bsD0wdtBJ9PSFk0vrdp.U1lmqxLP5mqO Z4bjpJC5A.WP7h1Ak3ZPvR82P2QFl1BaWg9qtTZC3rvn13RI1rJ9kVVgEmATt85JDp2w.D.B8BkI ykw7mC3wXT4oXVvubLW1lFQZ92ZoZziTnmw1Bc6ksPS2YTNU79EGcB7Flg7bwN.1MqM6MjK7jVP3 C7sVNHN5JykW.QytO8nKkAhVcQIsuU0JhgfIPg4g7lACsSFkS.dcCU5matA2Cei843VFSknUIQJQ gSBv1RkgLM_hm4w4ht9YSzMCachVStGUrla0jo9bub X-Sonic-MF: X-Sonic-ID: d1e825fc-05bc-490b-8c94-0991e9e3119c Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic309.consmr.mail.ne1.yahoo.com with HTTP; Thu, 13 Jul 2023 00:31:38 +0000 Original-Received: by hermes--production-sg3-67fd64777-6fgkn (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 87b91f0e926dbc497ccbaf3603a16946; Thu, 13 Jul 2023 00:31:35 +0000 (UTC) In-Reply-To: <3242369.aeNJFYEL58@anduin> (Moritz Maxeiner's message of "Wed, 12 Jul 2023 21:58:44 +0200") X-Mailer: WebService/1.1.21638 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Received-SPF: pass client-ip=66.163.184.148; envelope-from=luangruo@yahoo.com; helo=sonic309-22.consmr.mail.ne1.yahoo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:307800 Archived-At: Moritz Maxeiner writes: > My apologies, after rereading your previous message I realize I misunderstood. > I thought I was to put the changes after the remember_mouse_glyph call (like I > was previously asked to do for move_it_in_display_line instead of modifying > another xdisp.c function, move_it_in_display_line_to). My comment derived from > that misunderstanding as there are multiple calls to remember_mouse_glyph that > need to be affected. > > I have adjusted the patch as requested (I think), added some documentation in > commands.texi, as well as a NEWS entry. I'm not sure about correct placement / > formatting of the latter two. > > Btw. I'm not particularly happy about needed to add the `original_gx' > variable, but since the function seems to overwrite its argument, which I need > access to at its end (once the full glyph has been determined), I don't see > another option. I'm also not super happy about the needed division, but I also > don't see a way around that. If you know a more elegant solution I'd be happy > to hear it. I don't see a problem with that, but please see below. > diff --git a/doc/lispref/commands.texi b/doc/lispref/commands.texi > index cd1745614eb..274c456d8c3 100644 > --- a/doc/lispref/commands.texi > +++ b/doc/lispref/commands.texi > @@ -1969,6 +1969,8 @@ events do not appear. @xref{Mouse Tracking}. > When non-@code{nil}, mouse motion events are generated even for very > small movements. Otherwise, motion events are not generated as long > as the mouse cursor remains pointing to the same glyph in the text. > +Note that non-@code{nil} @code{mouse-prefer-closest-glyph} changes > +that to the left/right half of the glyph under the mouse cursor instead. I think this change is unnecessary and could at least be reworded or moved to a more suitable venue. > @end defvar > > @node Touchscreen Events > @@ -2751,6 +2753,14 @@ If @var{whole} is non-@code{nil}, the @var{x} coordinate is relative > to the entire window area including scroll bars, margins and fringes. > @end defun > > +@defvar mouse-prefer-closest-glyph > +If you set this variable to non-@code{nil}, whenever you click or drag the mouse, > +instead of the point being always set in front of the clicked glyph, the point > +horizontally closest to the mouse position will be used. > +So if you click in the left half of a glyph, point is set in front of it, > +but if you click in the right half, point is set after it. > +@end defvar How about: If this variable is non-@code{nil}, the @code{posn-point} of a mouse position list will be set to the position of the glyph whose left most position is closest to the mouse pointer, as opposed to the position of the glyph underneath the mouse pointer itself. For example, if @code{posn-at-x-y} is called with @var{x} set to @code{9}, which is contained within a character of width 10 positioned at column 0, the point saved within the mouse position list will be after that character. ? > + DEFVAR_BOOL ("mouse-prefer-closest-glyph", mouse_prefer_closest_glyph, > + doc: /* Non-nil means mouse position lists are reported relative ^^ There is superfluous whitespace here. > if (window_resize_pixelwise) > { > width = height = 1; > @@ -2950,6 +2953,16 @@ remember_mouse_glyph (struct frame *f, int gx, int gy, NativeRectangle *rect) > store_rect: > STORE_NATIVE_RECT (*rect, gx, gy, width, height); > > + if (mouse_prefer_closest_glyph) > + { > + int half_width = rect->width / 2; > + rect->width = half_width; > + > + int bisection = rect->x + half_width; > + if (original_gx > bisection) > + rect->x = bisection; > + } Instead of repeatedly loading from and storing to RECT, why not modify width and height before the expansion of STORE_NATIVE_RECT? Thanks.