From: Alan Mackenzie Date: Fri, 20 May 2022 20:18:38 +0000 (+0000) Subject: Restore the Fselect_window call in gui_consider_frame_title. X-Git-Tag: emacs-28.1.90~75 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=dfa3e6f424;p=emacs.git Restore the Fselect_window call in gui_consider_frame_title. This fixes bug #55412. The call to Fselect_window was removed on 2021-03-21 in the commit "Prevent open minibuffers getting lost when their frame gets deleted". This call is actually needed to determine current elements of the pertinent window and frame when these are used in the frame title. * src/frame.c (do_switch_frame): When the selected window in the target frame is the mini-window, switch away from this window unless there is a valid minibuffer there. * src/frame.h (struct frame): Add an incidental comment about the element selected_window. * src/minibuf.c (move_minibuffers_onto_frame): No longer set the selected window of the source frame. This action is now performed later, on returning to that frame, in do_switch_frame when needed (see above). * src/xdisp.c (gui_consider_frame_title): Replace the Fselect_window call and associated ancillary settings. --- diff --git a/src/frame.c b/src/frame.c index ccac18d23c2..dc8045f41e6 100644 --- a/src/frame.c +++ b/src/frame.c @@ -1564,6 +1564,13 @@ do_switch_frame (Lisp_Object frame, int track, int for_deletion, Lisp_Object nor if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame))) last_nonminibuf_frame = XFRAME (selected_frame); + /* If the selected window in the target frame is its mini-window, we move + to a different window, the most recently used one, unless there is a + valid active minibuffer in the mini-window. */ + if (EQ (f->selected_window, f->minibuffer_window) + && NILP (Fminibufferp (XWINDOW (f->minibuffer_window)->contents, Qt))) + Fset_frame_selected_window (frame, call1 (Qget_mru_window, frame), Qnil); + Fselect_window (f->selected_window, norecord); /* We want to make sure that the next event generates a frame-switch diff --git a/src/frame.h b/src/frame.h index 0b8cdf62ded..cc0dae8f5ab 100644 --- a/src/frame.h +++ b/src/frame.h @@ -123,6 +123,7 @@ struct frame /* This frame's selected window. Each frame has its own window hierarchy and one of the windows in it is selected within the frame. + This window may be the mini-window of the frame, if any. The selected window of the selected frame is Emacs's selected window. */ Lisp_Object selected_window; diff --git a/src/minibuf.c b/src/minibuf.c index 847e7be5ad4..0fc7f2caa15 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -197,20 +197,12 @@ move_minibuffers_onto_frame (struct frame *of, bool for_deletion) return; if (FRAME_LIVE_P (f) && !EQ (f->minibuffer_window, of->minibuffer_window) - && WINDOW_LIVE_P (f->minibuffer_window) /* F not a tootip frame */ + && WINDOW_LIVE_P (f->minibuffer_window) /* F not a tooltip frame */ && WINDOW_LIVE_P (of->minibuffer_window)) { zip_minibuffer_stacks (f->minibuffer_window, of->minibuffer_window); if (for_deletion && XFRAME (MB_frame) != of) MB_frame = selected_frame; - if (!for_deletion - && MINI_WINDOW_P (XWINDOW (FRAME_SELECTED_WINDOW (of)))) - { - Lisp_Object old_frame; - XSETFRAME (old_frame, of); - Fset_frame_selected_window (old_frame, - Fframe_first_window (old_frame), Qnil); - } } } diff --git a/src/xdisp.c b/src/xdisp.c index 6963935666b..9740e6b590e 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -12796,8 +12796,9 @@ gui_consider_frame_title (Lisp_Object frame) mode_line_noprop_buf; then display the title. */ record_unwind_protect (unwind_format_mode_line, format_mode_line_unwind_data - (NULL, current_buffer, Qnil, false)); + (f, current_buffer, selected_window, false)); + Fselect_window (f->selected_window, Qt); set_buffer_internal_1 (XBUFFER (XWINDOW (f->selected_window)->contents)); fmt = FRAME_ICONIFIED_P (f) ? Vicon_title_format : Vframe_title_format;