Subject: Re: bug#30699: 26.0.91; buffer contents flicker on macOS frames when frames are resized

From: Eli Zaretskii <[email-masked]>
Date: Sat, 10 Mar 2018 10:30:27 +0200

> Date: Sat, 10 Mar 2018 00:25:55 +0000
> From: Alan Third <[email-masked]>
> Cc: [email-masked], [email-masked]
> 
> diff --git a/src/nsterm.m b/src/nsterm.m
> index 1919c6defa..b4ec384aaf 100644
> --- a/src/nsterm.m
> +++ b/src/nsterm.m
> @@ -288,6 +288,7 @@ - (NSColor *)colorUsingDefaultColorSpace
>  static BOOL ns_fake_keydown = NO;
>  #ifdef NS_IMPL_COCOA
>  static BOOL ns_menu_bar_is_hidden = NO;
> +static int disable_screen_updates_count = 0;

Doesn't making this static mean potential trouble if redisplay is run
from a non-main thread?

> diff --git a/src/xdisp.c b/src/xdisp.c
> index 9170d6b777..d4fdb44b32 100644
> --- a/src/xdisp.c
> +++ b/src/xdisp.c
> @@ -14599,6 +14599,9 @@ redisplay_internal (void)
>   end_of_redisplay:
>  #ifdef HAVE_NS
>    ns_set_doc_edited ();
> +#ifdef NS_IMPL_COCOA
> +  ns_enable_screen_updates ();
> +#endif
>  #endif

Can x_set_window_size be called only from redisplay_internal?  If not,
doesn't this risk leaving the updates disabled, if x_set_window_size
is called from some other place?

Also, redisplay_internal has a few early returns which don't go
through end_of_redisplay -- are you sure they can never happen in this
situation?  For example, what if popup_activated returns non-zero?

Finally, this code needs comments that explain why this is done.

Thanks.