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: Wed, 12 Jul 2023 08:52:01 +0800 Message-ID: <87mt02ar4e.fsf@yahoo.com> References: <2255158.iZASKD2KPV@silef> <83r0pe7hru.fsf@gnu.org> <87wmz6bnlr.fsf@yahoo.com> <21946289.EfDdHjke4D@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="28892"; 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 Wed Jul 12 02:53:04 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 1qJO6K-0007Jh-H5 for ged-emacs-devel@m.gmane-mx.org; Wed, 12 Jul 2023 02:53:04 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qJO5a-00083R-Fe; Tue, 11 Jul 2023 20:52:19 -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 1qJO5Y-000834-G3 for emacs-devel@gnu.org; Tue, 11 Jul 2023 20:52:16 -0400 Original-Received: from sonic317-33.consmr.mail.ne1.yahoo.com ([66.163.184.44]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qJO5W-0003uR-QU for emacs-devel@gnu.org; Tue, 11 Jul 2023 20:52:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1689123132; bh=ycbGrq02HHwXOUKDZu0pndQx+IThuj6TIuYCZBw9qew=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=ZnB8ePMNfRMRLh3kJLYxaDxoBif0jSCF5AfsUIknRQpkQq3b2TNo3U1LfQy/E0prTCQJZkJCDOQcu8JxwGui0HYWehDWMTukg90fEJp0Uv8sAUXWpBNbmLyHI/hwtu50mjEKEWfnZlXilXxrVNDU62cYmhXW2KU7XkSjZsjuk9daK/rZ/y/rjhJuTkMKVwCy9FoIbDyND+uavhMus/X34mbPn19+wUPKTLJs2WaIFUh7FZumIaNmIww9A78BBImLHKuDnru2nKk2/nnMo/WELUpyYea+7UwYcnhJD3ya8PFd/dE0a359XYDs69YEpvORQyuAeS8iIUXnT/QovqctYw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1689123132; bh=cEiu+xFx/V+/OlN520RzK99IywKz0Ev/UW4NAx81taq=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=siVsq1JL3Ltv+JctWdxWYyD2nGULqCoykKBP0HmCFWq2PcZQQGYwK17S+GIBittU2TyZN7VRgxyeSbHbBTZOMOlohHCdf4ggD3uZXqM3n8iMqBr6ipVWmgcTcbuca1yqV4wmJoDNypP0juqhgkvqYOMAru9c7z+mb6xW/UhB7wep6j4lyMy1CNmMUAz4iQlVJNmhrYnFz6GN0Ud0zz3X09q8fbcWxxefAlVOBBzVBVnhwfTUVvCCJDSIOFJRkGG6542VoeXAggbHuRaAq4gFdUZwamtb6dR4/4DL+M00LAHIgsyZwQOuXjw/zu9LSDSADpuUzYm/XX1JXnk5rLFOKw== X-YMail-OSG: aqQej6AVM1mCMCn9vkiCrfDAKzHpbGEyEfUBAq3OoHZG_Jg5Awa_HpT8KcCz9bJ .g5xTYQb3ckSn3DxuncNKTPXpHEudhFyT9oeAx40vQX_2UdBFyGM_tJpSnP6siVGNjIuK6jzIk8R RdpaJhCHeA9u1TW0GsJ.mgbzqrcpRidDdTZEPoWwHgecNrUwh9O4_cbqN_.fIKOOHLKluk4S39DM qAN_cfz4FX.5.bF6kEAW7YpZ9fipgY8a73rE2AaQD3FGmcztDeVb.W6uPtcP0M_NatgWbWHUMRWF _FqB9estHoD2Bc6UPQy_7oXV_mon6Gcwtr5Bduj5xttk4EvuVbHpmNhXuPCJq8qdpGDTTKbhWfFl VfdVAQaLhYTxRDT1Yz1WqH3hQ2HXZRU.fW9yrbN12_8TaKOLvCJzVMaj4op2eZR6eg_xf3ScnIgQ QFHJ5epQ6nkVhcXm8q39R737SzRA3vfkDpX0LtyimtzfKMRBkaRPXjinGlrlVnFpoZhYXxsGuhBb es6m08WvKIYrg0W53OlVR0M7HdMzHKM3pLNpvI_BtwIsC5nNA5943df1Kzl0wYBlFtfP96rS34Ft Yvr_uFCUiRM0mWwF10JewgjvvQCdd33MCRigyfHQjuCLZYN1YPbVaKqxe.8trtB8yM4z.2X2pVgc yXUzXDceTfdr6HWfxnL0bFF6OOHeoEamfMh2Ee4.ezY0MH.6IsSFXI8Lv6DEAQoUpVTwfOdx03HB ZACiYVrU0cAxgL4.LgUV.u2gSAgYDjloOm_oBT5qZC609Qnyx4zcr.1ZlG3F_flkbXQA9M3PLtBe dSdh5OTuJG6E4BiBUpwEEzK3BhOayILrfWZpbZ.YnY X-Sonic-MF: X-Sonic-ID: 2844bc83-f548-4581-91b4-6b4e8afc688c Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic317.consmr.mail.ne1.yahoo.com with HTTP; Wed, 12 Jul 2023 00:52:12 +0000 Original-Received: by hermes--production-sg3-67fd64777-rc8tr (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 8da7fe3778858f8d789806e4601b3aa0; Wed, 12 Jul 2023 00:52:06 +0000 (UTC) In-Reply-To: <21946289.EfDdHjke4D@anduin> (Moritz Maxeiner's message of "Tue, 11 Jul 2023 20:01:59 +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.44; envelope-from=luangruo@yahoo.com; helo=sonic317-33.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:307766 Archived-At: Moritz Maxeiner writes: > I'm not clear on why that would make it wrong (as in incorrect semantics). > It's definitely inefficient (though I've not noticed the overhead in practice), > which is why I asked if there's a more elegant solution. The overhead is apparent when options such as `mouse-drag-and-drop-region' are enabled and the connection to the X server is slow. > Which this is, thank you very much for pointing that out. I've changed that > part of the patch accordingly, though this does unfortunately mean that a new > function is required, due to multiple places setting the glyph rectangle as it > relates to dragging. I find that difficult to believe. Would you please describe the other callers of `remember_mouse_glyph' that make adjustments there impossible? I asked you to make the change in `remember_mouse_glyph' because that would avoid the need to modify each of the *term.[cm] files individually. Replacing it with a different function would miss the point of the change. > Assuming this version of the implementation meets muster I will work > on the etc/NEWS entry and can look into adding something to > (elisp)Accessing Mouse, as well. Several other comments below: > +/* Function to bisect `glyph` into left and right halves, then > + replace it with the half in which `x` is. */ > + > +static void > +x_vertical_bisect_glyph(XRectangle *glyph, int x) > +{ > + int halfwidth = glyph->width / 2; > + glyph->width = halfwidth; > + > + int bisection = glyph->x + halfwidth; > + if (x > bisection) > + glyph->x = bisection; > +} Please follow the GNU coding standards for both function declarators and comments, by capitalizing (not quoting) arguments which appear in the commentary, and placing a space between the identifier name and the opening parentheses of the parameter type list. Also, use the active voice when describing the behavior of a function within its commentary: /* Replace *GLYPH, a rectangle containing the bounds of a glyph, with the half of the rectangle containing the position X. */ static void x_vertical_bisect_glyph (XRectangle *glyph, int x) { /* ... */ } In addition, we don't use Markdown style quotes for code. When quoting identifier names in the future, either write: /* `foo' is used to perform ... */ or /* 'foo' is used to perform ... */ > /* Function to report a mouse movement to the mainstream Emacs code. > The input handler calls this. > > @@ -14218,6 +14232,8 @@ x_note_mouse_movement (struct frame *frame, const XMotionEvent *event, > note_mouse_highlight (frame, event->x, event->y); > /* Remember which glyph we're now on. */ > remember_mouse_glyph (frame, event->x, event->y, r); > + if (mouse_prefer_closest_glyph) > + x_vertical_bisect_glyph(r, event->x); > dpyinfo->last_mouse_glyph_frame = frame; > return true; > } > @@ -14382,6 +14398,8 @@ x_fast_mouse_position (struct frame **fp, int insist, Lisp_Object *bar_window, > remember_mouse_glyph (f1, win_x, win_y, > &dpyinfo->last_mouse_glyph); > dpyinfo->last_mouse_glyph_frame = f1; > + if (mouse_prefer_closest_glyph) > + x_vertical_bisect_glyph(&dpyinfo->last_mouse_glyph, win_x); > > *bar_window = Qnil; > *part = scroll_bar_nowhere; > @@ -14733,6 +14751,8 @@ XTmouse_position (struct frame **fp, int insist, Lisp_Object *bar_window, > dpyinfo = FRAME_DISPLAY_INFO (f1); > remember_mouse_glyph (f1, win_x, win_y, &dpyinfo->last_mouse_glyph); > dpyinfo->last_mouse_glyph_frame = f1; > + if (mouse_prefer_closest_glyph) > + x_vertical_bisect_glyph(&dpyinfo->last_mouse_glyph, win_x); Please place a space between the identifier name and the opening brace of each function call. However, implementing this feature shouldn't need changes to xterm.c at all. Please make the change in `remember_mouse_glyph', not in window system specific code.