Subject: bug#31440: closed (Re: bug#31440: Can't redefine parent-frame on NS)

From: [email-masked] (GNU bug Tracking System)
Date: Sun, 03 Jun 2018 19:35:02 +0000

Your bug report

#31440: Can't redefine parent-frame on NS

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
31440: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=31440
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#31440: Can't redefine parent-frame on NS
From: Alan Third <[email-masked]>
To: [email-masked]
Date: Sun, 03 Jun 2018 20:34:22 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Alan Third <[email-masked]> writes:

> Patch attached.
>
> If this is too late for 26.1 I don’t think that will be a huge issue
> as it seems redefining parent-frame is not something people want to
> do, and it’s unlikely to be something a user does by accident.

Pushed to Emacs 26.2.
-- 
Alan Third

Subject: Can't redefine parent-frame on NS
From: Alan Third <[email-masked]>
To: [email-masked]
Date: Sun, 13 May 2018 10:40:54 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

from emacs -Q:

set up three frames, a, b and c:

    (set-frame-parameter c 'parent-frame a)

c becomes child of a.

(set-frame-parameter c 'parent-frame b)

expected: c becomes child of b and is no longer child of a.

actual: c remains child of a, and b now cannot be raised above a and b.

(set-frame-parameter c 'parent-frame nil)

expected: c ceases to be a child frame.

actual: emacs crashes.

Patch attached.

If this is too late for 26.1 I don’t think that will be a huge issue
as it seems redefining parent-frame is not something people want to
do, and it’s unlikely to be something a user does by accident.
-- 
Alan Third
>From a33d6248a7369fc18111e42b6157a6bf84c5578a Mon Sep 17 00:00:00 2001
From: Alan Third <[email-masked]>
Date: Sun, 13 May 2018 10:33:44 +0100
Subject: [PATCH] Fix redefinition of child frames on NS

* src/nsterm.m (x_set_parent_frame): If the NSWindow has an existing
parent frame, remove it.
---
 src/nsterm.m | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/nsterm.m b/src/nsterm.m
index c8ae31abc0..df883346de 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -1958,12 +1958,20 @@ so some key presses (TAB) are swallowed by the system. */
 
   if (p != FRAME_PARENT_FRAME (f))
     {
-      parent = [FRAME_NS_VIEW (p) window];
+      block_input ();
       child = [FRAME_NS_VIEW (f) window];
 
-      block_input ();
-      [parent addChildWindow: child
-                     ordered: NSWindowAbove];
+      if ([child parentWindow] != nil)
+        [[child parentWindow] removeChildWindow:child];
+
+      if (!NILP (new_value))
+        {
+          parent = [FRAME_NS_VIEW (p) window];
+
+          [parent addChildWindow: child
+                         ordered: NSWindowAbove];
+        }
+
       unblock_input ();
 
       fset_parent_frame (f, new_value);
-- 
2.16.1