Don't switch to another frame if window is not on the selected frame.
* lisp/window.el (window--quit-restore-select-window): Add optional arg 'frame'. Don't switch to another frame if window is not on the selected frame (bug#71386). (quit-restore-window): Provide the 'frame' arg to 'window--quit-restore-select-window' calls. Patch by martin rudalics <rudalics@gmx.at>. * test/lisp/tab-bar-tests.el (tab-bar-tests-quit-restore-window): No need to reselect the frame after 'quit-window'.
This commit is contained in:
parent
054a181d2d
commit
9f4347e00c
2 changed files with 13 additions and 9 deletions
|
@ -5335,13 +5335,19 @@ the window has never shown before."
|
|||
:version "31.1"
|
||||
:group 'windows)
|
||||
|
||||
(defun window--quit-restore-select-window (window)
|
||||
(defun window--quit-restore-select-window (window &optional frame)
|
||||
"Select WINDOW after having quit another one.
|
||||
Do not select an inactive minibuffer window."
|
||||
(when (and (window-live-p window)
|
||||
(or (not (window-minibuffer-p window))
|
||||
(minibuffer-window-active-p window)))
|
||||
(select-window window)))
|
||||
;; If WINDOW is not on the selected frame, don't switch to
|
||||
;; another frame.
|
||||
(unless (and (eq frame (selected-frame))
|
||||
(not (eq frame (window-frame window))))
|
||||
(setq frame (window-frame window))
|
||||
(set-frame-selected-window frame window)
|
||||
(select-frame-set-input-focus frame))))
|
||||
|
||||
(defun quit-restore-window (&optional window bury-or-kill)
|
||||
"Quit WINDOW and deal with its buffer.
|
||||
|
@ -5400,6 +5406,7 @@ elsewhere. This value is used by `quit-windows-on'."
|
|||
(unless (eq (car buf) buffer)
|
||||
(throw 'prev-buffer (car buf))))))
|
||||
(dedicated (window-dedicated-p window))
|
||||
(frame (window-frame window))
|
||||
quad entry reset-prev)
|
||||
(cond
|
||||
;; First try to delete dedicated windows that are not side windows.
|
||||
|
@ -5407,7 +5414,7 @@ elsewhere. This value is used by `quit-windows-on'."
|
|||
(window--delete
|
||||
window 'dedicated (memq bury-or-kill '(kill killing))))
|
||||
;; If the previously selected window is still alive, select it.
|
||||
(window--quit-restore-select-window quit-restore-2))
|
||||
(window--quit-restore-select-window quit-restore-2 frame))
|
||||
((and (not prev-buffer)
|
||||
(or (memq (nth 1 quit-restore) '(frame tab))
|
||||
(and (eq (nth 1 quit-restore) 'window)
|
||||
|
@ -5419,7 +5426,7 @@ elsewhere. This value is used by `quit-windows-on'."
|
|||
;; Delete WINDOW if possible.
|
||||
(window--delete window nil (eq bury-or-kill 'kill)))
|
||||
;; If the previously selected window is still alive, select it.
|
||||
(window--quit-restore-select-window quit-restore-2))
|
||||
(window--quit-restore-select-window quit-restore-2 frame))
|
||||
((and (or (and quit-restore-window-no-switch (not prev-buffer))
|
||||
;; Ignore first of the previous buffers if
|
||||
;; 'quit-restore-window-no-switch' says so.
|
||||
|
@ -5429,7 +5436,7 @@ elsewhere. This value is used by `quit-windows-on'."
|
|||
(window--delete
|
||||
window nil (memq bury-or-kill '(kill killing))))
|
||||
;; If the previously selected window is still alive, select it.
|
||||
(window--quit-restore-select-window quit-restore-2))
|
||||
(window--quit-restore-select-window quit-restore-2 frame))
|
||||
((or (and (listp (setq quad (nth 1 quit-restore-prev)))
|
||||
(buffer-live-p (car quad))
|
||||
(eq (nth 3 quit-restore-prev) buffer)
|
||||
|
|
|
@ -89,9 +89,6 @@
|
|||
(should (eq (length (window-list)) 2))
|
||||
(should (equal (buffer-name) "*info*"))
|
||||
(quit-window)
|
||||
;; 'quit-window' unexpectedly selects the original frame,
|
||||
;; so move back to the created frame
|
||||
(select-frame (car (frame-list)))
|
||||
(should (eq (length (window-list)) 1))
|
||||
(should (eq (length (frame-list)) 2))
|
||||
(should (equal (buffer-name) "*Messages*"))
|
||||
|
@ -99,7 +96,7 @@
|
|||
(should (eq (length (frame-list)) 2))
|
||||
;; Delete the created frame afterwards because with tty frames
|
||||
;; the output of 'message' is bound to the original frame
|
||||
(delete-frame))
|
||||
(delete-frame (car (frame-list))))
|
||||
|
||||
;; 2.1. 'quit-restore-window' should close the tab
|
||||
;; from initial window (bug#59862)
|
||||
|
|
Loading…
Add table
Reference in a new issue