Subject: bug#3303: delete-frame raises old (invisible) frame

From: David Reitter <[email-masked]>
Date: Fri, 15 May 2009 18:09:11 -0700

Emacs -Q under NS, then

(progn
   (make-frame-invisible nil t)
   (make-frame)
   (delete-frame (selected-frame) t))

will unexpectedly leave one frame visible and raised.  It should  
actually hide all frames.

The code that does it come in via the NS port (75f88b1c by arobert on  
2008-07-15), in do_switch_frame():

#ifdef NS_IMPL_COCOA
   /* term gets no other notification of this */
   if (for_deletion)
     Fraise_frame(Qnil);
#endif

	(do_switch_frame): When for_deletion under Cocoa, add
	Fraise_frame(Qnil).

This seems needed in order to raise another (visible) frame -  
otherwise no frame gets raised (or visibly selected).

The change below would address this - but is Fselect_frame() intended  
to make frames visible (on other platforms)?

diff --git a/src/frame.c b/src/frame.c
index de857af..fbef938 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -868,7 +868,7 @@ do_switch_frame (frame, track, for_deletion,  
norecord)

  #ifdef NS_IMPL_COCOA
    /* term gets no other notification of this */
-  if (for_deletion)
+  if (for_deletion && FRAME_VISIBLE_P (XFRAME (frame)))
      Fraise_frame(Qnil);
  #endif