From: Alan Mackenzie <acm@muc.de>
To: martin rudalics <rudalics@gmx.at>
Cc: 56305@debbugs.gnu.org, Eli Zaretskii <eliz@gnu.org>,
monnier@iro.umontreal.ca, acm@muc.de
Subject: bug#56305: 29.0.50; 'yes-or-no-p' deselects minibuffer frame
Date: Sun, 10 Jul 2022 11:34:50 +0000 [thread overview]
Message-ID: <Ysq5Wlk17NXvGcDJ@ACM> (raw)
In-Reply-To: <cc7ce72b-9c68-6301-1308-fb1ed7199c54@gmx.at>
Hello, Martin.
On Sun, Jul 10, 2022 at 10:07:28 +0200, martin rudalics wrote:
> > diff --git a/src/minibuf.c b/src/minibuf.c
> > index 0fc7f2caa1..0d80b2ec90 100644
> > --- a/src/minibuf.c
> > +++ b/src/minibuf.c
> > @@ -896,6 +896,16 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
> > /* Don't allow the user to undo past this point. */
> > bset_undo_list (current_buffer, Qnil);
> > + /* If some Emacs frame currently has the window-system focus, give
> > + it to the minibuffer frame. This is sometimes needed for
> > + minibuffer-only frames. Don't give that frame the focus if it's
> > + already got it, since this might cause the frame to be wrongly
> > + raised. */
> > + if (FRAME_DISPLAY_INFO (XFRAME (mini_frame))->x_focus_frame
> > + && (FRAME_DISPLAY_INFO (XFRAME (mini_frame))->x_focus_frame
> > + != XFRAME (mini_frame)))
> > + Fx_focus_frame (mini_frame, Qt);
> > +
> > recursive_edit_1 ();
> > /* If cursor is on the minibuffer line,
> > How do you react to this suggestion? Anyhow, I just tried it on a Linux
> > tty, and it segfaults. ;-( So it clearly needs some refinement.
> This doesn't improve anything here. On Debian I'm using a setup which
> is described under "Focus Settings" here
> https://docs.xfce.org/xfce/xfwm4/4.12/preferences
Thanks! I use xfce, too. But I haven't changed anything here away from
its default. I run Emacs on a tty anyway.
> In particular, I (a) Automatically raise windows when they receive focus
> and I use a (b) Delay before raising focused window. (a) is for me
> indispensable to bring a window to foreground with the mouse (mainly due
> to a habit developed while working under Windows where clicking into a
> lowered frame to raise it inevitably moved point in the Emacs window
> clicked at). (b) is indispensable to avoid that some arbitrary window
> gets raised when moving the mouse over it while trying to reach some
> specific window (this is one case mutter handles decidedly better than
> xfwm). If anybody can suggest a better setup for emulating what Emacs
> calls 'mouse-autoselect-window' on the display level, I'll be all ears.
> Now note that when in my scenario I type C-x C-c, the minibuffer frame
> is selected and has focus.
But not raised, though? Surely the MB frame being selected and having
focus is what we want, so that we can type "yes" or "no" next.
> Then apparently the
> Fselect_window (old_window, Qt)
> call in unwind_format_mode_line (the one you mentioned earlier in this
> thread) kicks in causing the window manager to move focus to the normal
> frame.
(See below.)
> Finally, your patch will ask the window manager to focus the
> minibuffer frame again and raise it.
> I used the term "apparently" because there are too many do_switch_frame
> calls triggered by redisplay in order to attribute them orderly to their
> precise origin. And tracing focus transitions with GDB is next to
> impossible because you continuously have to shift focus between GDB and
> the debugged application.
Try running GDB in an Emacs on a Linux tty. That's what I do anyway. I
seem to remember watching the focus, last time I did this, a day or two
ago.
Anyway, we'll have to decide soon what to do for Emacs 28.2. The first
pretest is already out there. What we do needs to be simple and safe.
The alternatives so far seem to be do nothing, apply the 53-line
deletion from master (which Eli has already rejected) or apply my patch
above (fixed to work with tty's). At the moment, I would favour the
last of these.
> Nota bene: In each redisplay cycle, Emacs may ask the window manager at
> least twice for each of its frames to refocus it in order to format that
> frame's title. Doesn't a window manager have better things to do than
> cater for how applications try to format their internal data? Doesn't
> such an interaction strike anyone as provocative at least?
select-window and select-frame should NOT move the focus. select-frame
is even documented (in the Elisp manual) not to do this. That
documentation is not true for Emacs 28.x, but may now have become true
in master since I removed those 53 lines from do_switch_frame, but I'm
not sure.
A worthwhile project would be rigourously to determine where the focus
gets changed as a side effect of other things and to remove such side
effects. Then we could add code to move the focus when we actually want
to.
> > I suggested using s-f-s-input-focus at one time, but you pointed out
> > that this would raise the frame, which isn't wanted.
> s-f-s-input-focus would add insult to injury - guaranteeing an unwanted
> raise even if 'x-focus-frame' alone would not raise it.
> > But surely every window manager will give the minibuffer frame the
> > focus, precisely what we need here?
> I wouldn't even bet on that. Certainly not with newer generations of
> window managers. A WM may concede input focus upon an application's
> request for special windows like dialog boxes only. We're just lucky if
> it allows to give focus to some "normal" window too.
You're implying that C-x 5 o might not work with such WMs. That would
not be good.
> > What could happen with a strange WM
> > that could be disturbing?
> Isn't that the wrong question? Here we talk about a strange application
> that within milliseconds asks the WM to move focus away from one of its
> windows and then move it back to the original window in order to format
> its internal data.
As I said, I don't think select-frame/window should move the focus.
Maybe somebody could fix this for Emacs 29.
> >> The change to master fixes the bug here.
> > Thanks!
> Unfortunately, it breaks C-x o. Try with my scenario but instead of
> answering the 'yes-or-no-p' question type C-x o. With Emacs 28.1 this
> selects the window on top of the normal frame. With current master it
> does nothing.
I don't think that's true. It selects the other window on the normal
frame (which is the selected frame), but retains the focus in the
minibuffer frame (the focus being redirected from the normal frame).
> It doesn't even tell me that there is no other window to select. So
> this cure is certainly worse than the disease.
I think that might be over-stating things. Most of the time, users are
just going to be typing "yes" or "no" here.
> martin
--
Alan Mackenzie (Nuremberg, Germany).
next prev parent reply other threads:[~2022-07-10 11:34 UTC|newest]
Thread overview: 83+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-29 17:54 bug#56305: 29.0.50; 'yes-or-no-p' deselects minibuffer frame martin rudalics
2022-06-29 19:10 ` Eli Zaretskii
2022-06-30 10:35 ` Alan Mackenzie
2022-06-30 20:32 ` Alan Mackenzie
2022-07-02 11:38 ` Alan Mackenzie
2022-07-03 8:16 ` martin rudalics
2022-07-03 16:09 ` Alan Mackenzie
2022-07-03 16:17 ` Eli Zaretskii
2022-07-04 19:10 ` Alan Mackenzie
2022-07-04 19:21 ` Eli Zaretskii
2022-07-04 19:43 ` Alan Mackenzie
2022-07-05 2:29 ` Eli Zaretskii
2022-07-05 15:59 ` Alan Mackenzie
2022-07-05 16:24 ` Eli Zaretskii
2022-07-05 17:09 ` Alan Mackenzie
2022-07-06 17:04 ` Alan Mackenzie
2022-07-06 17:29 ` Eli Zaretskii
2022-07-06 18:16 ` Alan Mackenzie
2022-07-06 18:34 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-06 18:58 ` Andreas Schwab
2022-07-06 19:05 ` Alan Mackenzie
2022-07-06 19:09 ` Andreas Schwab
2022-07-06 19:22 ` Alan Mackenzie
2022-07-07 17:25 ` Alan Mackenzie
2022-07-07 18:57 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-08 21:03 ` Alan Mackenzie
2022-07-09 2:15 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-07 7:55 ` martin rudalics
2022-07-07 9:12 ` Alan Mackenzie
2022-07-08 7:01 ` martin rudalics
2022-07-08 10:55 ` Alan Mackenzie
2022-07-08 11:55 ` Eli Zaretskii
2022-07-08 18:31 ` Alan Mackenzie
2022-07-09 8:36 ` martin rudalics
2022-07-08 21:45 ` Gregory Heytings
2022-07-09 8:35 ` martin rudalics
2022-07-09 10:57 ` Alan Mackenzie
2022-07-10 8:07 ` martin rudalics
2022-07-10 11:34 ` Alan Mackenzie [this message]
2022-07-10 11:47 ` Eli Zaretskii
2022-07-10 12:41 ` Alan Mackenzie
2022-07-10 13:01 ` Eli Zaretskii
2022-07-10 16:13 ` Drew Adams
2022-07-10 16:55 ` Alan Mackenzie
2022-07-11 7:45 ` martin rudalics
2022-07-11 11:12 ` Eli Zaretskii
2022-07-12 7:33 ` martin rudalics
2022-07-12 16:02 ` Eli Zaretskii
2022-07-11 16:22 ` Alan Mackenzie
2022-07-11 16:43 ` Eli Zaretskii
2022-07-11 17:15 ` Alan Mackenzie
2022-07-11 17:33 ` Eli Zaretskii
2022-07-11 17:34 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-11 20:09 ` Alan Mackenzie
2022-07-11 17:06 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-11 20:01 ` Alan Mackenzie
2022-07-12 7:35 ` martin rudalics
2022-07-12 14:56 ` Drew Adams
2022-07-16 7:06 ` martin rudalics
2022-07-16 20:34 ` Alan Mackenzie
2022-07-18 7:36 ` martin rudalics
2022-07-18 14:44 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-19 8:09 ` martin rudalics
2022-07-19 16:04 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-16 23:39 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-17 11:29 ` Alan Mackenzie
2022-07-17 14:03 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-17 15:06 ` Alan Mackenzie
2022-07-18 7:37 ` martin rudalics
2022-07-18 14:58 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-18 15:58 ` Eli Zaretskii
2022-07-18 16:12 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-18 16:50 ` Eli Zaretskii
2022-07-19 20:48 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-20 12:17 ` Eli Zaretskii
2022-07-20 14:54 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-20 16:02 ` Eli Zaretskii
2022-07-21 15:07 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-21 15:58 ` Eli Zaretskii
2022-07-19 8:09 ` martin rudalics
2022-07-07 15:54 ` Alan Mackenzie
2022-07-04 19:46 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-04 19:59 ` Alan Mackenzie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Ysq5Wlk17NXvGcDJ@ACM \
--to=acm@muc.de \
--cc=56305@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=rudalics@gmx.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).