diff --git a/src/nsterm.m b/src/nsterm.m index 2507053f3a1..f4de0a76c0a 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -1651,8 +1651,13 @@ -(void)remove unblock_input (); } - /* Making a frame invisible seems to break the parent->child - relationship, so reinstate it. */ + /* A child window cannot remain attached while hidden. Per Apple's + documentation, "Calling orderOut(_:) on a child window causes the + window to be removed from its parent window before being removed" + (https://developer.apple.com/documentation/appkit/nswindow/orderout(_:)), + and ns_make_frame_invisible hides the frame with -orderOut:. The + parent->child relationship is therefore broken while invisible, so + reinstate it now that we are making the frame visible again. */ if ([window parentWindow] == nil && FRAME_PARENT_FRAME (f) != NULL) { block_input (); @@ -9979,8 +9984,15 @@ - (void)setParentChildRelationships [ourView toggleFullScreen:self]; #endif - [parentWindow addChildWindow:self - ordered:NSWindowAbove]; + /* -addChildWindow: also orders the child window onto the screen, so + attaching a child frame Emacs considers invisible is what + resurrects a dismissed completion popup (corfu, company-box, ...) + when relationships are rebuilt. Only attach a visible child; a + hidden one is re-attached by ns_make_frame_visible when it is + shown again. */ + if (FRAME_VISIBLE_P (ourFrame)) + [parentWindow addChildWindow:self + ordered:NSWindowAbove]; } /* Check our child windows are configured correctly. */