aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlan Third2018-03-19 15:04:40 +0000
committerAlan Third2018-03-19 17:16:14 +0000
commit903e3d43310638014a33fec64700e7db8e0774d0 (patch)
tree542a10151ab1d98152fbb9b0362f67873298fde0 /src
parent1979bce57d1887d89de6d728bb34dcd0f6478b2f (diff)
downloademacs-903e3d43310638014a33fec64700e7db8e0774d0.tar.gz
emacs-903e3d43310638014a33fec64700e7db8e0774d0.zip
Fix frame resize flicker on macOS (bug#30699)
* src/nsterm.h (ns_enable_screen_updates): New function. * src/nsterm.m (ns_enable_screen_updates): (ns_disable_screen_updates): New functions. (disable_screen_updates_count): Count of number of times we've called NSDisableScreenUpdates. (x_set_window_size): Disable screen updates when not in a live resize loop. * src/xdisp.c (redisplay_internal): Reenable screen updates when redisplay doesn't complete due to a popup. (unwind_redisplay): Reenable screen updates.
Diffstat (limited to 'src')
-rw-r--r--src/nsterm.h3
-rw-r--r--src/nsterm.m46
-rw-r--r--src/xdisp.c16
3 files changed, 64 insertions, 1 deletions
diff --git a/src/nsterm.h b/src/nsterm.h
index 8b985930ecb..df59a7dbd9a 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -1160,6 +1160,9 @@ extern void ns_release_autorelease_pool (void *);
1160extern const char *ns_get_defaults_value (const char *key); 1160extern const char *ns_get_defaults_value (const char *key);
1161extern void ns_init_locale (void); 1161extern void ns_init_locale (void);
1162 1162
1163#ifdef NS_IMPL_COCOA
1164extern void ns_enable_screen_updates (void);
1165#endif
1163 1166
1164/* in nsmenu */ 1167/* in nsmenu */
1165extern void update_frame_tool_bar (struct frame *f); 1168extern void update_frame_tool_bar (struct frame *f);
diff --git a/src/nsterm.m b/src/nsterm.m
index 75e0b837c67..f9107c43ce1 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -288,6 +288,9 @@ static BOOL gsaved = NO;
288static BOOL ns_fake_keydown = NO; 288static BOOL ns_fake_keydown = NO;
289#ifdef NS_IMPL_COCOA 289#ifdef NS_IMPL_COCOA
290static BOOL ns_menu_bar_is_hidden = NO; 290static BOOL ns_menu_bar_is_hidden = NO;
291
292/* The number of times NSDisableScreenUpdates has been called. */
293static int disable_screen_updates_count = 0;
291#endif 294#endif
292/*static int debug_lock = 0; */ 295/*static int debug_lock = 0; */
293 296
@@ -727,6 +730,40 @@ ns_release_autorelease_pool (void *pool)
727} 730}
728 731
729 732
733#ifdef NS_IMPL_COCOA
734/* Disabling screen updates can be used to make several actions appear
735 "atomic" to the end user. It seems some actions can still update
736 the display, though.
737
738 When we re-enable screen updates the number of calls to
739 NSEnableScreenUpdates should match the number to
740 NSDisableScreenUpdates.
741
742 We use these functions to prevent the user seeing a blank frame
743 after it has been resized. x_set_window_size disables updates and
744 when redisplay completes unwind_redisplay enables them again
745 (bug#30699). */
746
747static void
748ns_disable_screen_updates (void)
749{
750 NSDisableScreenUpdates ();
751 disable_screen_updates_count++;
752}
753
754void
755ns_enable_screen_updates (void)
756/* Re-enable screen updates. Called from unwind_redisplay. */
757{
758 while (disable_screen_updates_count > 0)
759 {
760 NSEnableScreenUpdates ();
761 disable_screen_updates_count--;
762 }
763}
764#endif
765
766
730static BOOL 767static BOOL
731ns_menu_bar_should_be_hidden (void) 768ns_menu_bar_should_be_hidden (void)
732/* True, if the menu bar should be hidden. */ 769/* True, if the menu bar should be hidden. */
@@ -1877,6 +1914,15 @@ x_set_window_size (struct frame *f,
1877 1914
1878 block_input (); 1915 block_input ();
1879 1916
1917#ifdef NS_IMPL_COCOA
1918 /* To prevent showing the user a blank frame, stop updates being
1919 flushed to the screen until after redisplay has completed. This
1920 breaks live resize (resizing with a mouse), so don't do it if
1921 we're in a live resize loop. */
1922 if (![view inLiveResize])
1923 ns_disable_screen_updates ();
1924#endif
1925
1880 if (pixelwise) 1926 if (pixelwise)
1881 { 1927 {
1882 pixelwidth = FRAME_TEXT_TO_PIXEL_WIDTH (f, width); 1928 pixelwidth = FRAME_TEXT_TO_PIXEL_WIDTH (f, width);
diff --git a/src/xdisp.c b/src/xdisp.c
index a97d4db6070..4778f532cd4 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -13918,7 +13918,15 @@ redisplay_internal (void)
13918 13918
13919#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS) 13919#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS)
13920 if (popup_activated ()) 13920 if (popup_activated ())
13921 return; 13921 {
13922#ifdef NS_IMPL_COCOA
13923 /* On macOS we may have disabled screen updates due to window
13924 resizing. We should re-enable them so the popup can be
13925 displayed. */
13926 ns_enable_screen_updates ();
13927#endif
13928 return;
13929 }
13922#endif 13930#endif
13923 13931
13924 /* I don't think this happens but let's be paranoid. */ 13932 /* I don't think this happens but let's be paranoid. */
@@ -14722,6 +14730,12 @@ unwind_redisplay (void)
14722{ 14730{
14723 redisplaying_p = false; 14731 redisplaying_p = false;
14724 unblock_buffer_flips (); 14732 unblock_buffer_flips ();
14733#ifdef NS_IMPL_COCOA
14734 /* On macOS we may have disabled screen updates due to window
14735 resizing. When redisplay completes we want to re-enable
14736 them. */
14737 ns_enable_screen_updates ();
14738#endif
14725} 14739}
14726 14740
14727 14741