unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Andrii Kolomoiets <andreyk.mad@gmail.com>
To: Alan Third <alan@idiocy.org>
Cc: 36672@debbugs.gnu.org
Subject: bug#36672: 27.0.50; NS build: Creating child frame leads to empty space
Date: Wed, 17 Jul 2019 21:51:47 +0300	[thread overview]
Message-ID: <213A995F-5DF6-4CE1-9365-1E227B732CE7@gmail.com> (raw)
In-Reply-To: <20190716192822.GA63701@breton.holly.idiocy.org>

[-- Attachment #1: Type: text/plain, Size: 2500 bytes --]

On Jul 16, 2019, at 22:28, Alan Third <alan@idiocy.org> wrote:
> 
> On Mon, Jul 15, 2019 at 08:38:31PM +0300, Andrii Kolomoiets wrote:
>> Assume there are only one space - Desktop
>> 1. emacs -Q
>> 2. M-x toggle-frame-fullscreen
>>   Now there are two spaces - Desktop and *scratch*
>> 3. eval (make-frame `((parent-frame . ,(window-frame))))
>>   Now there are three spaces:
>>   - Desktop
>>   - Empty space named *scratch* with emacs menu
>>   - *scratch* with emacs frames but without menu
> 
> I hit C-x C-c at this point to exit Emacs and it completely crashed my
> session. Not great...
> 
> The patch looks good to me, but lets see if we can find solutions to
> these other issues. To be honest, given that Apple don’t provide any
> way to properly deal with spaces, I’d expect this stuff to be handled
> sensibly by default, but I guess that’s too much to ask.
> 
>> 1. Removing parent-frame property leaves the frame is same space:
>> 
>> (let ((new-frame (make-frame `((parent-frame . ,(window-frame))))))
>>  (modify-frame-parameters new-frame `((parent-frame . nil))))
>> 
>> Maybe child frame must go fullscreen if ex-parent frame is in
>> fullscreen.
> 
> I suppose the best thing to do would be to move it onto the first
> space, but there’s no API for that, apparently. Going fullscreen seems
> like a reasonable work‐around to me.
> 

I manage to make this code work. Please see attached updated patch.
But this patch is not completely ready as it missing compilation conditions.
Just hope you find it useful.

>> 2. Setting parent frame after frame creation:
>> 
>> (let ((frame (window-frame))
>>      (new-frame (make-frame)))
>>  (modify-frame-parameters new-frame `((parent-frame . ,frame))))
> 
> What do you see happening in this case? I’ve got spaces turned on and
> everything I do just seems to create a new fullscreen space (except
> when it crashes my session).
> 

I see same result as in the first case: Desktop, empty blank space
with Emacs menu, space with Emacs frame and no menu/titlebar.

Still can't make this case work. Probably window animation stand in the way:

nsterm.m  : 1869: [  376]  ns_set_parent_frame
nsterm.m  : 1912: [  377]  | child frame must not be in fullscreen
2019-07-17 21:20:49.027 Emacs[91925:3597098] not in fullscreen state

If ns_set_parent_frame is called while window is still in process of going
full screen then maybe it must be deferred until animation ends.

[-- Attachment #2: ns-emacs-spaces-wip.patch --]
[-- Type: application/octet-stream, Size: 2923 bytes --]

diff --git a/src/nsterm.h b/src/nsterm.h
index 9773eb3e66..d16588718e 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -1274,6 +1274,7 @@ extern char gnustep_base_version[];  /* version tracking */
 #if !defined (NS_IMPL_COCOA) || !defined (MAC_OS_X_VERSION_10_7)
 #define NSFullScreenWindowMask                      (1 << 14)
 #define NSWindowCollectionBehaviorFullScreenPrimary (1 << 7)
+#define NSWindowCollectionBehaviorFullScreenAuxiliary (1 << 8)
 #define NSApplicationPresentationFullScreen         (1 << 10)
 #define NSApplicationPresentationAutoHideToolbar    (1 << 11)
 #define NSAppKitVersionNumber10_7                   1138
diff --git a/src/nsterm.m b/src/nsterm.m
index 02331826d9..8725520d4a 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -1884,6 +1884,8 @@ so some key presses (TAB) are swallowed by the system.  */
 
       if ([child parentWindow] != nil)
         {
+          parent = [child parentWindow];
+
           [[child parentWindow] removeChildWindow:child];
 #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
 #if MAC_OS_X_VERSION_MIN_REQUIRED < 101000
@@ -1891,10 +1893,28 @@ so some key presses (TAB) are swallowed by the system.  */
 #endif
               [child setAccessibilitySubrole:NSAccessibilityStandardWindowSubrole];
 #endif
+          if (NILP (new_value)){
+            NSTRACE ("child setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary");
+            [child setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
+            // TODO check parents of parent
+            if (([parent styleMask] & NSWindowStyleMaskFullScreen) != 0){
+              // if current parent in fullscreen and not new parent make child fullscreen
+              NSTRACE ("make child fullscreen");
+              [child toggleFullScreen:child];
+            }
+          }
         }
 
       if (!NILP (new_value))
         {
+          // child frame must not be in fullscreen
+          if (([child styleMask] & NSWindowStyleMaskFullScreen) != 0){
+            NSTRACE ("child frame must not be in fullscreen");
+            [child toggleFullScreen:child];
+          }
+          NSTRACE ("child setCollectionBehavior:NSWindowCollectionBehaviorFullScreenAuxiliary");
+          [child setCollectionBehavior:NSWindowCollectionBehaviorFullScreenAuxiliary];
+
           parent = [FRAME_NS_VIEW (p) window];
 
           [parent addChildWindow: child
@@ -7365,7 +7385,10 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f
 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
   if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_7)
 #endif
-    [win setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
+    if (FRAME_PARENT_FRAME (f))
+      [win setCollectionBehavior:NSWindowCollectionBehaviorFullScreenAuxiliary];
+    else
+      [win setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
 #endif
 
   wr = [win frame];

  parent reply	other threads:[~2019-07-17 18:51 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-15 17:38 bug#36672: 27.0.50; NS build: Creating child frame leads to empty space Andrii Kolomoiets
2019-07-16 19:28 ` Alan Third
2019-07-17  8:39   ` martin rudalics
2019-07-17 18:51   ` Andrii Kolomoiets [this message]
2019-07-23 18:14   ` Andrii Kolomoiets
2020-02-14  8:23     ` Andrii Kolomoiets
2020-02-20 23:23       ` Alan Third
2020-03-01 16:16       ` Alan Third
2020-03-10  8:42         ` Andrii Kolomoiets
2020-03-12 23:27           ` Alan Third
2020-03-13  9:38             ` martin rudalics
2020-03-13 15:13               ` Alan Third
2020-03-13 16:29                 ` martin rudalics
2020-03-13 17:45                   ` martin rudalics
2020-03-13 23:53                   ` Alan Third
2020-03-14  8:48                     ` martin rudalics

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=213A995F-5DF6-4CE1-9365-1E227B732CE7@gmail.com \
    --to=andreyk.mad@gmail.com \
    --cc=36672@debbugs.gnu.org \
    --cc=alan@idiocy.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).