return false;
}
-/* Make sure that minibuf_window doesn't refer to FRAME's minibuffer
- window. Preferably use the selected frame's minibuffer window
- instead. If the selected frame doesn't have one, get some other
- frame's minibuffer window. SELECT non-zero means select the new
- minibuffer window. */
-static void
-check_minibuf_window (Lisp_Object frame, int select)
-{
- struct frame *f = decode_live_frame (frame);
-
- XSETFRAME (frame, f);
-
- if (WINDOWP (minibuf_window) && EQ (f->minibuffer_window, minibuf_window))
- {
- Lisp_Object frames, this, window = make_fixnum (0);
-
- if (!EQ (frame, selected_frame)
- && FRAME_HAS_MINIBUF_P (XFRAME (selected_frame)))
- window = FRAME_MINIBUF_WINDOW (XFRAME (selected_frame));
- else
- FOR_EACH_FRAME (frames, this)
- {
- if (!EQ (this, frame) && FRAME_HAS_MINIBUF_P (XFRAME (this)))
- {
- window = FRAME_MINIBUF_WINDOW (XFRAME (this));
- break;
- }
- }
-
- /* Don't abort if no window was found (Bug#15247). */
- if (WINDOWP (window))
- {
- /* Use set_window_buffer instead of Fset_window_buffer (see
- discussion of bug#11984, bug#12025, bug#12026). */
- set_window_buffer (window, XWINDOW (minibuf_window)->contents, 0, 0);
- minibuf_window = window;
-
- /* SELECT non-zero usually means that FRAME's minibuffer
- window was selected; select the new one. */
- if (select)
- Fselect_window (minibuf_window, Qnil);
- }
- }
-}
-
-
/**
* delete_frame:
*
struct frame *sf;
struct kboard *kb;
Lisp_Object frames, frame1;
- int minibuffer_selected, is_tooltip_frame;
+ int is_tooltip_frame;
bool nochild = !FRAME_PARENT_FRAME (f);
Lisp_Object minibuffer_child_frame = Qnil;
/* At this point, we are committed to deleting the frame.
There is no more chance for errors to prevent it. */
- minibuffer_selected = EQ (minibuf_window, selected_window);
sf = SELECTED_FRAME ();
/* Don't let the frame remain selected. */
if (f == sf)
do_switch_frame (frame1, 0, 1, Qnil);
sf = SELECTED_FRAME ();
}
-
- /* Don't allow minibuf_window to remain on a deleted frame. */
- check_minibuf_window (frame, minibuffer_selected);
+ else
+ /* Ensure any minibuffers on FRAME are moved onto the selected
+ frame. */
+ move_minibuffers_onto_frame (f, true);
/* Don't let echo_area_window to remain on a deleted frame. */
if (EQ (f->minibuffer_window, echo_area_window))
if (NILP (force) && !other_frames (f, true, false))
error ("Attempt to make invisible the sole visible or iconified frame");
- /* Don't allow minibuf_window to remain on an invisible frame. */
- check_minibuf_window (frame, EQ (minibuf_window, selected_window));
-
if (FRAME_WINDOW_P (f) && FRAME_TERMINAL (f)->frame_visible_invisible_hook)
FRAME_TERMINAL (f)->frame_visible_invisible_hook (f, false);
}
#endif /* HAVE_WINDOW_SYSTEM */
- /* Don't allow minibuf_window to remain on an iconified frame. */
- check_minibuf_window (frame, EQ (minibuf_window, selected_window));
-
if (FRAME_WINDOW_P (f) && FRAME_TERMINAL (f)->iconify_frame_hook)
FRAME_TERMINAL (f)->iconify_frame_hook (f);
doc: /* Return the currently active minibuffer window, or nil if none. */)
(void)
{
- return minibuf_level ? minibuf_window : Qnil;
+ Lisp_Object frames, frame;
+ struct frame *f;
+ Lisp_Object innermost_MB;
+
+ if (!minibuf_level)
+ return Qnil;
+
+ innermost_MB = nth_minibuffer (minibuf_level);
+ FOR_EACH_FRAME (frames, frame)
+ {
+ f = XFRAME (frame);
+ if (FRAME_LIVE_P (f)
+ && WINDOW_LIVE_P (f->minibuffer_window)
+ && EQ (XWINDOW (f->minibuffer_window)->contents, innermost_MB))
+ return f->minibuffer_window;
+ }
+ return minibuf_window; /* "Can't happen." */
}
DEFUN ("set-minibuffer-window", Fset_minibuffer_window,