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: Fri, 14 Feb 2020 10:23:22 +0200 Message-ID: References: <04CF7A6F-C1E7-4FE5-B648-8DA8CBD3B1ED@gmail.com> <20190716192822.GA63701@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="50180"; 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 Fri Feb 14 09:24:12 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 1j2WGi-000Cxc-8h for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 14 Feb 2020 09:24:12 +0100 Original-Received: from localhost ([::1]:35992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2WGh-0000QX-1f for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 14 Feb 2020 03:24:11 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36026) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2WGZ-0000QR-T7 for bug-gnu-emacs@gnu.org; Fri, 14 Feb 2020 03:24:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j2WGY-0001bE-9N for bug-gnu-emacs@gnu.org; Fri, 14 Feb 2020 03:24:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54833) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j2WGY-0001b5-1z for bug-gnu-emacs@gnu.org; Fri, 14 Feb 2020 03:24:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j2WGX-0006tn-Ug for bug-gnu-emacs@gnu.org; Fri, 14 Feb 2020 03:24:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Andrii Kolomoiets Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 14 Feb 2020 08:24: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.158166861326484 (code B ref 36672); Fri, 14 Feb 2020 08:24:01 +0000 Original-Received: (at 36672) by debbugs.gnu.org; 14 Feb 2020 08:23:33 +0000 Original-Received: from localhost ([127.0.0.1]:60806 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j2WG5-0006t5-1x for submit@debbugs.gnu.org; Fri, 14 Feb 2020 03:23:33 -0500 Original-Received: from mail-lj1-f173.google.com ([209.85.208.173]:41634) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j2WG3-0006ss-Aj for 36672@debbugs.gnu.org; Fri, 14 Feb 2020 03:23:32 -0500 Original-Received: by mail-lj1-f173.google.com with SMTP id h23so9730702ljc.8 for <36672@debbugs.gnu.org>; Fri, 14 Feb 2020 00:23:31 -0800 (PST) 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=fF5t9qa5adR/1PMXoymk5V9/dpTw1cY8U9CCwB8mm+M=; b=hXeYVySUAIhtVoo4sz3UzuBOj4vq5Q0RbNGCEamjZwFJkxatfAvqqVtYHvyFy+xv6W 1oucSNvMn/wgFAPi4NUU+kxawipHyHiVcvUbaeU/X/zRMvvIcO+8+Lt7wBJo1yINJWsu 3koMEEUbGH4E6EmgbfoVVuBz2134w31DlAaVbB9yIvWid49V9gGlZ6SAFYQ+U7QV+y5N xHgWaxDYMXsC+5oyuMEiP9L8qIxLDBBz5yCjP+ExgipWG50F8bnhOUbY369AcOX75a4I ClLA6ZpWBT3BwM1zbxghncPGjAK9FVckzzgXEggfGStG0MjuPNoMurXzcLq4Pmstqw4z m4Gg== 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=fF5t9qa5adR/1PMXoymk5V9/dpTw1cY8U9CCwB8mm+M=; b=Qh6UQX6G6T+8UIApRpBVl3UPSR/ZkZjFBQ2InNZakThMPtEPOaCxZYV6UXzhdptSAk cDtxToS2upMCvx955r19oqrVzPZ276tIEGAVEn8QLKia8g1zgcR4v8r73p6p2vRJgs5K 7ypgk3AsbSLZcv4JTmlXAH70uvVRVN9tnsw2OWzen+nNxDLsFrZiGwFGRnA5LVVRpV8h cWZLW5h2RcMP4zCCjenz6qB+nrInxoIY245gjSGDjPwbtPQqUX7I54eCBy2sVV0QPLOF JxbWZ+eO2HL/PkJwTqyy4BqM73pCk13YtVwsE/iclsD2mJRtMtEoOqQADN7XKm5YDPmw Gc5w== X-Gm-Message-State: APjAAAWz6b/e98UwE47OjX2tQuwiKbSadRApDS6AW/jU3g/c9iYMvv2N uzWcBSPHfzCBnOtp22j9L9ed8vFg X-Google-Smtp-Source: APXvYqwVvurC8ohhqT2dr6qPz6jzT+Bd6ATOJFkGvJv4iZ5rQhJPGRT2Q1nf0mKKYXC5uVVjT+htVw== X-Received: by 2002:a2e:2201:: with SMTP id i1mr1326365lji.110.1581668604397; Fri, 14 Feb 2020 00:23:24 -0800 (PST) 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 x23sm2680473lff.24.2020.02.14.00.23.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Feb 2020 00:23:23 -0800 (PST) In-Reply-To: (Andrii Kolomoiets's message of "Tue, 23 Jul 2019 21:14:19 +0300") 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:176035 Archived-At: --=-=-= Content-Type: text/plain Andrii Kolomoiets writes: >> On Jul 16, 2019, at 22:28, Alan Third wrote: >> >> The patch looks good to me, but lets see if we can find solutions to >> these other issues. > > I made some progress on this issue. > > The idea is to wait for fullscreen transition to complete: > - Set property isFullScreenTransition on windowWillEnterFullScreen and > windowWillExitFullScreen events; > - Clear that property on windowDidEnterFullScreen and > windowDidExitFullScreen events; > - Wait for property to be cleared when we need to. Updated patch to work with latest master --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=ns-emacs-spaces-updated.patch 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 7c6197f128..243d66be60 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -417,6 +417,7 @@ #define NSTRACE_UNSILENCE() int maximized_width, maximized_height; NSWindow *nonfs_window; BOOL fs_is_native; + BOOL is_fullscreen_transition; #ifdef NS_IMPL_COCOA CGContextRef drawingBuffer; #endif @@ -451,6 +452,8 @@ #define NSTRACE_UNSILENCE() - (void) toggleFullScreen: (id) sender; - (BOOL) fsIsNative; - (BOOL) isFullscreen; +- (BOOL) isFullScreenTransition; +- (void) waitFullScreenTransition; #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 - (void) updateCollectionBehavior; #endif @@ -1270,6 +1273,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 2cf6774a1f..b290fd3d95 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -1588,9 +1588,11 @@ -(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]) + if ([view fsIsNative] && [view isFullscreen]) { + // maybe it is not necessary to wait + [view waitFullScreenTransition]; return; + } if (f->want_fullscreen != FULLSCREEN_NONE) { @@ -1976,19 +1978,52 @@ 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 @@ -7411,6 +7446,7 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f #endif fs_is_native = ns_use_native_fullscreen; #endif + is_fullscreen_transition = NO; maximized_width = maximized_height = -1; nonfs_window = nil; @@ -7442,7 +7478,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]; @@ -7565,11 +7604,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); + // } } } @@ -7769,6 +7809,7 @@ - (NSApplicationPresentationOptions)window:(NSWindow *)window - (void)windowWillEnterFullScreen:(NSNotification *)notification { NSTRACE ("[EmacsView windowWillEnterFullScreen:]"); + is_fullscreen_transition = YES; [self windowWillEnterFullScreen]; } - (void)windowWillEnterFullScreen /* provided for direct calls */ @@ -7781,6 +7822,7 @@ - (void)windowDidEnterFullScreen:(NSNotification *)notification { NSTRACE ("[EmacsView windowDidEnterFullScreen:]"); [self windowDidEnterFullScreen]; + is_fullscreen_transition = NO; } - (void)windowDidEnterFullScreen /* provided for direct calls */ @@ -7819,6 +7861,7 @@ - (void)windowDidEnterFullScreen /* provided for direct calls */ - (void)windowWillExitFullScreen:(NSNotification *)notification { NSTRACE ("[EmacsView windowWillExitFullScreen:]"); + is_fullscreen_transition = YES; [self windowWillExitFullScreen]; } @@ -7838,6 +7881,7 @@ - (void)windowDidExitFullScreen:(NSNotification *)notification { NSTRACE ("[EmacsView windowDidExitFullScreen:]"); [self windowDidExitFullScreen]; + is_fullscreen_transition = NO; } - (void)windowDidExitFullScreen /* provided for direct calls */ @@ -7867,6 +7911,21 @@ - (void)windowDidExitFullScreen /* provided for direct calls */ [[self window] performZoom:self]; } +- (BOOL)isFullScreenTransition +{ + return is_fullscreen_transition; +} + +- (void)waitFullScreenTransition +{ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 + while ([self isFullScreenTransition]){ + NSTRACE ("wait for fullscreen"); + wait_reading_process_output (0, 300000000, 0, 1, Qnil, NULL, 0); + } +#endif +} + - (BOOL)fsIsNative { return fs_is_native; @@ -7904,10 +7963,17 @@ - (void)updateCollectionBehavior { NSWindow *win = [self window]; NSWindowCollectionBehavior b = [win collectionBehavior]; - if (ns_use_native_fullscreen) - b |= NSWindowCollectionBehaviorFullScreenPrimary; - else + if (ns_use_native_fullscreen) { + if ([win parentWindow]) { + b &= ~NSWindowCollectionBehaviorFullScreenPrimary; + b |= NSWindowCollectionBehaviorFullScreenAuxiliary; + } else { + b |= NSWindowCollectionBehaviorFullScreenPrimary; + b &= ~NSWindowCollectionBehaviorFullScreenAuxiliary; + } + } else { b &= ~NSWindowCollectionBehaviorFullScreenPrimary; + } [win setCollectionBehavior: b]; #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 >= 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; } --=-=-=--