Prevent the selected window being a dead mini-window when switching frames
This fixes bug #48249 and also a situation where, with recursive minibuffers
enabled and minibuffer-follows-selected-frame t, switching frames when a
minibuffer was open would leave the mini-window selected on the old frame.
* lisp/window.el (record-window-buffer): Add extra parameter DO-MINIBUF, and
amend the code such that minibuffers only get processed when that parameter is
non-nil.
* src/minibuf.c (zip_minibuffer_stacks, read_minibuf): Call
Qrecord_window_buffer with the new argument set to Qt.
(move_minibuffers_onto_frame): Set the selected window on the old frame when
this would otherwise remain the mini-window.