From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Andrii Kolomoiets Newsgroups: gmane.emacs.bugs Subject: bug#36672: 27.0.50; NS build: Creating child frame leads to empty space Date: Tue, 10 Mar 2020 10:42:11 +0200 Message-ID: References: <04CF7A6F-C1E7-4FE5-B648-8DA8CBD3B1ED@gmail.com> <20190716192822.GA63701@breton.holly.idiocy.org> <20200301161605.GA8290@breton.holly.idiocy.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="48388"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (darwin) Cc: 36672@debbugs.gnu.org To: Alan Third Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Mar 10 09:43:34 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jBaU9-000CTT-Ts for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 10 Mar 2020 09:43:34 +0100 Original-Received: from localhost ([::1]:55426 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBaU8-0000EZ-PV for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 10 Mar 2020 04:43:32 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58912) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBaTj-00007l-AV for bug-gnu-emacs@gnu.org; Tue, 10 Mar 2020 04:43:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBaTe-0004ZI-Fd for bug-gnu-emacs@gnu.org; Tue, 10 Mar 2020 04:43:07 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45849) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jBaTe-0004Xq-47 for bug-gnu-emacs@gnu.org; Tue, 10 Mar 2020 04:43:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jBaTd-00029D-VM for bug-gnu-emacs@gnu.org; Tue, 10 Mar 2020 04:43:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Andrii Kolomoiets Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 10 Mar 2020 08:43:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36672 X-GNU-PR-Package: emacs Original-Received: via spool by 36672-submit@debbugs.gnu.org id=B36672.15838297438207 (code B ref 36672); Tue, 10 Mar 2020 08:43:01 +0000 Original-Received: (at 36672) by debbugs.gnu.org; 10 Mar 2020 08:42:23 +0000 Original-Received: from localhost ([127.0.0.1]:51822 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jBaT0-00028J-Tp for submit@debbugs.gnu.org; Tue, 10 Mar 2020 04:42:23 -0400 Original-Received: from mail-lf1-f44.google.com ([209.85.167.44]:42940) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jBaSy-000285-Iu for 36672@debbugs.gnu.org; Tue, 10 Mar 2020 04:42:21 -0400 Original-Received: by mail-lf1-f44.google.com with SMTP id t21so10121862lfe.9 for <36672@debbugs.gnu.org>; Tue, 10 Mar 2020 01:42:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=OJ23412HPwjYe5kY+5pFR+fKKzXBsKt53UVYrAINFRY=; b=ItcjRvLaKFkMwQ8YsNprVVD0xxyW2yPkiy1WMY9wIMh6FGuXJmAgf+cuDUtWEdmwU1 K01hPGjDaCSJjzyoWgYgUqa3sVWAKpNIBTnfK3l8qD1DAGpAgZJwf49esWI8Zs+1q41S MqJzNSebx1Hdw7QxOiT3ZQX8mnYmnnevzKDZXrKhyKGod46DLuSrLCL8fQbdUTmQadHp LKchK8oS7mk0Z2y9BI3rvqJIyhnLYu93A0eAFnF3+w4fEKlXpUWLxKyDMZsSIYONVOxR 6DTF5iVb01uOJEmT/JPF4FQvb6CLEYHI6MsTozJbA3naXYj8KoaAZJkRfnf/Sf1+mmRr h4cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=OJ23412HPwjYe5kY+5pFR+fKKzXBsKt53UVYrAINFRY=; b=APsgURZb23vA2vp683jHvDD5bQDEnBq8bIqr2C3LQ4Uxmpr/GSdL/auEkiR5phzj/s XN8uMEgPIy+rWKbJLijLYTS3okmmrGxdDWY37sJ5EjH6k2qx9zuSDpWfV0F2WLzmqY5B KmzV2ue7wDJaamy3XnaVI4g/5wFTLrBP+x8W1+fZJjeYRFzleBWVuKAn4EWF9Y+nQEp+ 2T/b49AXcuL6meddAiPGvZfZUk0zyBruqYrByb+sdMvAiezNj9SFF2723wPzZyvM90XO j6A1t/z1Oqd3uAhHqwRU1AfDhAbvf07TaedeFU90eoi1EQes3XYk280ah+VErgBvbYvr soiA== X-Gm-Message-State: ANhLgQ3J5Irfp2aXfyZVKXqN/C0PlnjsllKlp5y39uytTrQ6FNmDZi2r JXMGICak1xV/iQdbfXKZ4lIvM/Qf X-Google-Smtp-Source: ADFU+vte1yQwUIKuykuKEpD+N6xuGHllR8bVGR89YpxmB0vW5i6O8wZcJKH2teht0x1wjwzx0ACh2w== X-Received: by 2002:a19:9d2:: with SMTP id 201mr12074043lfj.159.1583829734025; Tue, 10 Mar 2020 01:42:14 -0700 (PDT) Original-Received: from 10-1-1-147.office.area (188-42-207-82.ip.ukrtel.net. [82.207.42.188]) by smtp.gmail.com with ESMTPSA id e2sm21313920ljp.55.2020.03.10.01.42.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Mar 2020 01:42:12 -0700 (PDT) In-Reply-To: <20200301161605.GA8290@breton.holly.idiocy.org> (Alan Third's message of "Sun, 1 Mar 2020 17:16:08 +0100 (CET)") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:177123 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Alan Third writes: > Thanks! This looks much better than what we had before. No crashes for > one! > > A few nitpicks: > >> + BOOL is_fullscreen_transition; > > I may be misunderstanding this, but would =E2=80=98in_fullscreen_transiti= on=E2=80=99 > be a better name? OK, renamed.=20 > Opening braces go on a new line. Braces style is fixed to match Emacs code style. > And again. That =E2=80=98} else {=E2=80=99 should also be over three line= s. > >> #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 >> @@ -7932,9 +7998,14 @@ - (void)toggleFullScreen: (id)sender >> { >> #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >=3D 1070 >> #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 >> - if ([[self window] respondsToSelector: @selector(toggleFullScreen= :)]) >> + if ([[self window] respondsToSelector: @selector(toggleFullScreen= :)]){ >> #endif >> [[self window] toggleFullScreen:sender]; >> + // wait for fullscreen animation complete (bug#28496) >> + [self waitFullScreenTransition]; >> +#endif >> +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 >> + } >> #endif >> return; >> } > > Should that final #if #endif not be within the outer #if #endif? Yes. Fixed. Thanks! Please see attached patch. Log message is also provided. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-NS-child-frame-in-native-fullscreen.patch >From a9705617188c9a5ef77a8f2d5cc796b86dda9fa6 Mon Sep 17 00:00:00 2001 From: Andrii Kolomoiets Date: Tue, 10 Mar 2020 10:14:59 +0200 Subject: [PATCH] NS child frame in native fullscreen * lisp/frame.el (toggle-frame-fullscreen): Don't sleep on cocoa. Fullscreen animation waiting is moved to src/nsterm.m. * src/nsterm.h (EmacsView): Add in_fullscreen_transition, inFullScreenTransition, waitFullScreenTransition. (NSWindowCollectionBehaviorFullScreenAuxiliary): New define. * src/nsterm.m (ns_make_frame_visible): Wait for fullscreen animation. (ns_set_parent_frame): Set frame collection behavior; make child frames non-fullscreen; make non-child frames fullscreen if parent was fullscreen. ([EmacsView initFrameFromEmacs]): Set in_fullscreen_transition; set frame collection behavior according to parent frame. ([EmacsView windowDidMove]): Remove code by commenting with "fixme". ([EmacsView windowWillEnterFullScreen], [EmacsView windowDidEnterFullScreen]) ([EmacsView windowWillExitFullScreen], [EmacsView windowDidExitFullScreen]): Set in_fullscreen_transition. ([EmacsView inFullScreenTransition], [EmacsView waitFullScreenTransition]): New methods. ([EmacsView updateCollectionBehavior]): Set collection behavior according to parent frame. ([EmacsView toggleFullScreen]): Wait for fullscreen animation. --- lisp/frame.el | 6 +--- src/nsterm.h | 4 +++ src/nsterm.m | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++------- 3 files changed, 100 insertions(+), 17 deletions(-) diff --git a/lisp/frame.el b/lisp/frame.el index 16ee7580f8..7ed3e23f3c 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -2676,11 +2676,7 @@ toggle-frame-fullscreen (set-frame-parameter frame 'fullscreen fullscreen-restore) (set-frame-parameter frame 'fullscreen nil))) (modify-frame-parameters - frame `((fullscreen . fullboth) (fullscreen-restore . ,fullscreen)))) - ;; Manipulating a frame without waiting for the fullscreen - ;; animation to complete can cause a crash, or other unexpected - ;; behavior, on macOS (bug#28496). - (when (featurep 'cocoa) (sleep-for 0.5)))) + frame `((fullscreen . fullboth) (fullscreen-restore . ,fullscreen)))))) ;;;; Key bindings diff --git a/src/nsterm.h b/src/nsterm.h index db966e1581..8396a542f7 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -433,6 +433,7 @@ #define NS_DRAW_TO_BUFFER 1 int maximized_width, maximized_height; NSWindow *nonfs_window; BOOL fs_is_native; + BOOL in_fullscreen_transition; #ifdef NS_DRAW_TO_BUFFER CGContextRef drawingBuffer; #endif @@ -467,6 +468,8 @@ #define NS_DRAW_TO_BUFFER 1 - (void) toggleFullScreen: (id) sender; - (BOOL) fsIsNative; - (BOOL) isFullscreen; +- (BOOL) inFullScreenTransition; +- (void) waitFullScreenTransition; #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 - (void) updateCollectionBehavior; #endif @@ -1286,6 +1289,7 @@ #define SCREENMAXBOUND(x) (IN_BOUND (-SCREENMAX, x, SCREENMAX)) #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 851a5617d7..96a7fdc018 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -1571,9 +1571,12 @@ -(void)remove /* Making a new frame from a fullscreen frame will make the new frame fullscreen also. So skip handleFS as this will print an error. */ - if ([view fsIsNative] && f->want_fullscreen == FULLSCREEN_BOTH - && [view isFullscreen]) - return; + if ([view fsIsNative] && [view isFullscreen]) + { + // maybe it is not necessary to wait + [view waitFullScreenTransition]; + return; + } if (f->want_fullscreen != FULLSCREEN_NONE) { @@ -1959,19 +1962,55 @@ so some key presses (TAB) are swallowed by the system. */ block_input (); child = [FRAME_NS_VIEW (f) window]; +#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 + EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f); +#endif + if ([child parentWindow] != nil) { +#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 + parent = [child parentWindow]; +#endif + [[child parentWindow] removeChildWindow:child]; #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 #if MAC_OS_X_VERSION_MIN_REQUIRED < 101000 if ([child respondsToSelector:@selector(setAccessibilitySubrole:)]) #endif [child setAccessibilitySubrole:NSAccessibilityStandardWindowSubrole]; +#endif +#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 + if (NILP (new_value)) + { + NSTRACE ("child setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary"); + [child setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; + // if current parent in fullscreen and no new parent make child fullscreen + while (parent) { + if (([parent styleMask] & NSWindowStyleMaskFullScreen) != 0) + { + [view toggleFullScreen:child]; + break; + } + // check all parents + parent = [parent parentWindow]; + } + } #endif } if (!NILP (new_value)) { +#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 + // child frame must not be in fullscreen + if ([view fsIsNative] && [view isFullscreen]) + { + // in case child is going fullscreen + [view waitFullScreenTransition]; + [view toggleFullScreen:child]; + } + NSTRACE ("child setCollectionBehavior:NSWindowCollectionBehaviorFullScreenAuxiliary"); + [child setCollectionBehavior:NSWindowCollectionBehaviorFullScreenAuxiliary]; +#endif parent = [FRAME_NS_VIEW (p) window]; [parent addChildWindow: child @@ -7398,6 +7437,7 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f #endif fs_is_native = ns_use_native_fullscreen; #endif + in_fullscreen_transition = NO; maximized_width = maximized_height = -1; nonfs_window = nil; @@ -7431,7 +7471,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]; @@ -7554,11 +7597,12 @@ - (void)windowDidMove: sender emacsframe->top_pos = NS_PARENT_WINDOW_TOP_POS (emacsframe) - (r.origin.y + r.size.height); - if (emacs_event) - { - emacs_event->kind = MOVE_FRAME_EVENT; - EV_TRAILER ((id)nil); - } + // FIXME: after event part below didExitFullScreen is not received + // if (emacs_event) + // { + // emacs_event->kind = MOVE_FRAME_EVENT; + // EV_TRAILER ((id)nil); + // } } } @@ -7758,6 +7802,7 @@ - (NSApplicationPresentationOptions)window:(NSWindow *)window - (void)windowWillEnterFullScreen:(NSNotification *)notification { NSTRACE ("[EmacsView windowWillEnterFullScreen:]"); + in_fullscreen_transition = YES; [self windowWillEnterFullScreen]; } - (void)windowWillEnterFullScreen /* provided for direct calls */ @@ -7770,6 +7815,7 @@ - (void)windowDidEnterFullScreen:(NSNotification *)notification { NSTRACE ("[EmacsView windowDidEnterFullScreen:]"); [self windowDidEnterFullScreen]; + in_fullscreen_transition = NO; } - (void)windowDidEnterFullScreen /* provided for direct calls */ @@ -7808,6 +7854,7 @@ - (void)windowDidEnterFullScreen /* provided for direct calls */ - (void)windowWillExitFullScreen:(NSNotification *)notification { NSTRACE ("[EmacsView windowWillExitFullScreen:]"); + in_fullscreen_transition = YES; [self windowWillExitFullScreen]; } @@ -7827,6 +7874,7 @@ - (void)windowDidExitFullScreen:(NSNotification *)notification { NSTRACE ("[EmacsView windowDidExitFullScreen:]"); [self windowDidExitFullScreen]; + in_fullscreen_transition = NO; } - (void)windowDidExitFullScreen /* provided for direct calls */ @@ -7856,6 +7904,22 @@ - (void)windowDidExitFullScreen /* provided for direct calls */ [[self window] performZoom:self]; } +- (BOOL)inFullScreenTransition +{ + return in_fullscreen_transition; +} + +- (void)waitFullScreenTransition +{ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 + while ([self inFullScreenTransition]) + { + NSTRACE ("wait for fullscreen"); + wait_reading_process_output (0, 300000000, 0, 1, Qnil, NULL, 0); + } +#endif +} + - (BOOL)fsIsNative { return fs_is_native; @@ -7894,9 +7958,22 @@ - (void)updateCollectionBehavior NSWindow *win = [self window]; NSWindowCollectionBehavior b = [win collectionBehavior]; if (ns_use_native_fullscreen) - b |= NSWindowCollectionBehaviorFullScreenPrimary; + { + if ([win parentWindow]) + { + b &= ~NSWindowCollectionBehaviorFullScreenPrimary; + b |= NSWindowCollectionBehaviorFullScreenAuxiliary; + } + else + { + b |= NSWindowCollectionBehaviorFullScreenPrimary; + b &= ~NSWindowCollectionBehaviorFullScreenAuxiliary; + } + } else - b &= ~NSWindowCollectionBehaviorFullScreenPrimary; + { + b &= ~NSWindowCollectionBehaviorFullScreenPrimary; + } [win setCollectionBehavior: b]; #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 @@ -7922,8 +7999,14 @@ - (void)toggleFullScreen: (id)sender #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 if ([[self window] respondsToSelector: @selector(toggleFullScreen:)]) + { +#endif + [[self window] toggleFullScreen:sender]; + // wait for fullscreen animation complete (bug#28496) + [self waitFullScreenTransition]; +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 + } #endif - [[self window] toggleFullScreen:sender]; #endif return; } -- 2.15.1 --=-=-=--