From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jared Finder Newsgroups: gmane.emacs.devel Subject: Re: "Final" version of tty child frames Date: Sun, 05 Jan 2025 16:05:59 -0800 Message-ID: <9c324c399a59d8e64cdc7072d2db0ae8@finder.org> References: <86wmi0g0x6.fsf@gnu.org> <11a86987cce9fe0a257c3fa58703dc33@finder.org> <86wmgl6jzv.fsf@gnu.org> <092cb755eee3a9b5e06d15c0b07e90b1@finder.org> <276414b03c24964aaeb9e43e8dba5e77@finder.org> <5fedec86bce470555814acbdf999f99d@finder.org> <86h6791khk.fsf@gnu.org> <09b0904da92efad899865b2ece5f3116@finder.org> <23dfc3fde8677a984b4c37a40d09d83b@finder.org> <86h66dagdg.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32969"; mail-complaints-to="usenet@ciao.gmane.io" Cc: gerd.moellmann@gmail.com, emacs-devel@gnu.org, rudalics@gmx.at To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Jan 06 01:07:06 2025 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 1tUaeA-0008QL-2n for ged-emacs-devel@m.gmane-mx.org; Mon, 06 Jan 2025 01:07:06 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tUadL-0007CZ-Ih; Sun, 05 Jan 2025 19:06:15 -0500 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 1tUadF-0007CJ-9N for emacs-devel@gnu.org; Sun, 05 Jan 2025 19:06:09 -0500 Original-Received: from greenhill.hpalace.com ([192.155.80.58]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tUadC-0001mo-Gm; Sun, 05 Jan 2025 19:06:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=finder.org; s=2018; t=1736121959; bh=qNxz9wHXfYnGDRTEpZ0ZQIYg6Q29gBO1r3yASJVxfUE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Bw0dwg488j3Czw6H+7TepVAZ4JaHTCaj6WdCfTS2Yf+7WYXP3CXOKJhPZ3j6lfzp2 B5ShCYIRQWKGuJ1zwbBz4xwzaRSooezIy8aVw1c2t8InaJMs0woGhWvnWscDAEsQ2K kiydhai427rAjr4I56eN6KFBQxmNjAJHuuZNUpC8YaXiUW4IR8pkSvYluJcjfOrt/A NSVppZNmAjLYcNDRHYKrkig0L2/by7Slv/KjycmnPJX81mHHbsJzztZPSFCKlgZHE/ TYmzlpyGC1Ol4eR2WxSIPAL3jiftppI4l84K+iyaqbE75s7F9Zjl3TTRBWWoB4LKqG Z+GgOLwONbciQ== Original-Received: from mail.finder.org (unknown [192.155.80.58]) by greenhill.hpalace.com (Postfix) with ESMTPSA id 1BF95138A; Mon, 6 Jan 2025 00:05:59 +0000 (UTC) In-Reply-To: <86h66dagdg.fsf@gnu.org> X-Sender: jared@finder.org Received-SPF: pass client-ip=192.155.80.58; envelope-from=jared@finder.org; helo=greenhill.hpalace.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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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:327729 Archived-At: On 2025-01-04 23:07, Eli Zaretskii wrote: >> Date: Sat, 04 Jan 2025 14:12:00 -0800 >> From: Jared Finder >> Cc: Eli Zaretskii , emacs-devel@gnu.org, rudalics@gmx.at >> >> It was that easy to do. Attached is a patch that adds support for TTY >> child frames to a GPM mouse. > > Thanks. Style comments addressed, thank you! Someday, I will internalize Emacs' unique C style conventions. Probably once I only code for Emacs and not other projects. :) >> @@ -2638,7 +2639,11 @@ term_mouse_position (struct frame **fp, int >> insist, Lisp_Object *bar_window, >> enum scroll_bar_part *part, Lisp_Object *x, >> Lisp_Object *y, Time *timeptr) >> { >> - *fp = SELECTED_FRAME (); >> + /* This code runs even when `gpm-mouse-mode' was never active, like >> + inside an xterm. In such cases, last_mouse_frame will never be >> + set, so fallback to SELECTED_FRAME. */ >> + *fp = FRAMEP (last_mouse_frame) ? XFRAME (last_mouse_frame) >> + : SELECTED_FRAME (); > > Does this mean child frames on xterm will have the selected-frame set > to a child frame, and thus do not need this trick with > last_mouse_frame? Or what other difference between xterm and the > Linux console hides behind this "fallback"? This is just keeping the behavior that already exists today. I was surprised by the current behavior: that term_mouse_position which only works for a GPM enabled mouse gets called even when GPM could not be used. It could make sense to change this behavior however it would be a bigger change as gpm-mouse-mode is enabled by default even for non-GPM supporting terminals. I suspect that GPM support is equivalent to TERM=linux, but I may be wrong. This works when xterm-mouse-mode is enabled because mouse_position_hook (set to term_mouse_position) is called first, followed by mouse-position-function (set to xterm-mouse-position-function). On ttys with xterm-mouse-mode enabled the return value from term_mouse_position is ignored. See existing definitions in Fmouse_pixel_position and mouse_position in frame.c. >> +{ >> + Lisp_Object frame = CALLN (Ffuncall, Qframe_at, >> + make_fixnum (x), make_fixnum (y)); > > I'd refrain from calling into Lisp here: frame-at will call > tty-frame-list-z-order, which is implemented in C, and the rest of > frame-at can be trivially done in C. Would it make sense to delete the Lisp implementation of frame-at and make it implemented in C only? The only other existing client of frame-at is xterm-mouse-mode for the same use case. Looking forward, I expect that getting a window by screen pixel coordinate will be less available over time. Wayland and Android specifically do not support this for arbitrary pixels for security reasons. -- MJF