Subject: Re: bug#36672: 27.0.50; NS build: Creating child frame leads to empty space

From: Alan Third <[email-masked]>
Date: Sun, 1 Mar 2020 17:16:08 +0100 (CET)

On Fri, Feb 14, 2020 at 10:23:22AM +0200, Andrii Kolomoiets wrote:
> Andrii Kolomoiets <[email-masked]> writes:
> 
> >> On Jul 16, 2019, at 22:28, Alan Third <[email-masked]> 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

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 ‘in_fullscreen_transition’
be a better name?

> +#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
> +          // child frame must not be in fullscreen
> +          if ([view fsIsNative] && [view isFullscreen]){

Opening braces go on a new line.

> +- (void)waitFullScreenTransition
> +{
> +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
> +  while ([self isFullScreenTransition]){

Opening brace, again.

>  - (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;
> +      }

And again. That ‘} else {’ should also be over three lines.

>  #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;
>      }

Should that final #if #endif not be within the outer #if #endif? And
the opening brace again.
-- 
Alan Third