From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#56305: 29.0.50; 'yes-or-no-p' deselects minibuffer frame Date: Mon, 4 Jul 2022 19:10:07 +0000 Message-ID: References: <3984f6ec-1988-f0ae-d44c-f4b92a202938@gmx.at> <83o7yb5lqe.fsf@gnu.org> <83bku69nn2.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16399"; mail-complaints-to="usenet@ciao.gmane.io" Cc: rudalics@gmx.at, 56305@debbugs.gnu.org, Stefan Monnier , acm@muc.de To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jul 04 21:11:12 2022 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 1o8RTU-00043m-6f for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 04 Jul 2022 21:11:12 +0200 Original-Received: from localhost ([::1]:58466 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o8RTS-0007E8-VO for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 04 Jul 2022 15:11:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39738) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8RTL-0007Cl-Ei for bug-gnu-emacs@gnu.org; Mon, 04 Jul 2022 15:11:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54743) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o8RTL-0002rM-5q for bug-gnu-emacs@gnu.org; Mon, 04 Jul 2022 15:11:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o8RTL-0006t9-1v for bug-gnu-emacs@gnu.org; Mon, 04 Jul 2022 15:11:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 04 Jul 2022 19:11:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56305 X-GNU-PR-Package: emacs Original-Received: via spool by 56305-submit@debbugs.gnu.org id=B56305.165696181726377 (code B ref 56305); Mon, 04 Jul 2022 19:11:03 +0000 Original-Received: (at 56305) by debbugs.gnu.org; 4 Jul 2022 19:10:17 +0000 Original-Received: from localhost ([127.0.0.1]:48635 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o8RSa-0006rN-Ng for submit@debbugs.gnu.org; Mon, 04 Jul 2022 15:10:17 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:16818 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1o8RSY-0006r3-Ec for 56305@debbugs.gnu.org; Mon, 04 Jul 2022 15:10:15 -0400 Original-Received: (qmail 38676 invoked by uid 3782); 4 Jul 2022 19:10:08 -0000 Original-Received: from acm.muc.de (p4fe15a3f.dip0.t-ipconnect.de [79.225.90.63]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Mon, 04 Jul 2022 21:10:07 +0200 Original-Received: (qmail 21845 invoked by uid 1000); 4 Jul 2022 19:10:07 -0000 Content-Disposition: inline In-Reply-To: <83bku69nn2.fsf@gnu.org> X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de 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:236067 Archived-At: [ Adding Stefan M., because he's had experience of this sort of thing. ] Hello, Eli, Martin, and Stefan. On Sun, Jul 03, 2022 at 19:17:21 +0300, Eli Zaretskii wrote: > > Date: Sun, 3 Jul 2022 16:09:43 +0000 > > Cc: Eli Zaretskii , 56305@debbugs.gnu.org, acm@muc.de > > From: Alan Mackenzie > > While debugging, is there any easy way of determining which frame > > currently has the focus? > Yes, call x_get_focus_frame (or just examine the value of > FRAME_DISPLAY_INFO (f)->x_focus_frame manually). Thank you indeed. That was very helpful. I've spent several hours in gdb since these recent posts. Quick summary of the problem: On an Emacs with a minibuffer-only frame (MBF) and a minibuffer-less frame (NF), with MBF selected with focus, type C-x C-c. Instead of the focus remaining in MBF, it's moved to NF. I've pretty much tracked down what is happening, though I don't understand the last bit. Line ~71 in do_switch_frame (frame.c) is this: Fredirect_frame_focus (gfocus, frame); At this point in time gfocus is NF and frame is also NF. NF's frame focus had earlier been redirected to MBF. When Fredirect_frame_focus is executed, NF becomes redirected to itself, and also becomes the focussed frame (otherwise known as, sort of, the "highlighted frame"). This becoming the focussed frame is the problem. A few lines higher up in do_switch_frame, there is a comment which purports to explain this shifting of the frame focus, namely: /* If a frame's focus has been redirected toward the currently selected frame, we should change the redirection to point to the newly selected frame. This means that if the focus is redirected from a minibufferless frame to a surrogate minibuffer frame, we can use `other-window' to switch between all the frames using that minibuffer frame, and the focus redirection will follow us around. */ I don't understand this at all well. What it describes is indeed what happens. But if NF has been redirected to MBF, that surely means that when NF is the selected frame with focus, any characters typed will appear in MBF. Not the other way around. What happens to NF's focus, which previously pointed at MBF, is that it points to NF itself. This is as described in the comment. It is wrong. Surely what the comment should say, and what should happen is that if there is a frame switch from NF to NF2, then NF2 should become redirected to MBF. No? What am I missing? Apologies for this post being somewhat dense. -- Alan Mackenzie (Nuremberg, Germany).