aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPo Lu2022-07-29 17:14:05 +0800
committerPo Lu2022-07-29 17:27:36 +0800
commitacefbcf8351180b4eff46b30491ce758dcc42feb (patch)
tree7e7a5d8a6622684d5284589e68722ea0178891f9
parentee93a06b8b1922b31e12cfe60566779f185ddeba (diff)
downloademacs-acefbcf8351180b4eff46b30491ce758dcc42feb.tar.gz
emacs-acefbcf8351180b4eff46b30491ce758dcc42feb.zip
Minor additions to last change
* doc/emacs/xresources.texi (Table of Resources): Update description of `extended'. * etc/NEWS: Announce frame tearing reduction. * src/xterm.c (x_sync_update_finish, x_sync_update_begin) (x_update_begin, x_update_end, show_back_buffer, x_flip_and_flush) (XTframe_up_to_date, handle_one_xevent): Minor redesign of frame synchronization feature. Fix crash with overflow and checking.
-rw-r--r--doc/emacs/xresources.texi4
-rw-r--r--etc/NEWS11
-rw-r--r--src/xterm.c42
3 files changed, 33 insertions, 24 deletions
diff --git a/doc/emacs/xresources.texi b/doc/emacs/xresources.texi
index 8915d2025ba..ab0df3563f5 100644
--- a/doc/emacs/xresources.texi
+++ b/doc/emacs/xresources.texi
@@ -382,7 +382,9 @@ which prevents blank areas of a frame that have not yet been painted
382from being displayed. If set to @samp{extended}, it will enable use 382from being displayed. If set to @samp{extended}, it will enable use
383of an alternative frame synchronization protocol, which might be 383of an alternative frame synchronization protocol, which might be
384supported by some compositing window managers that don't support the 384supported by some compositing window managers that don't support the
385protocol Emacs uses by default. 385protocol Emacs uses by default, and causes Emacs to synchronize
386display with the monitor refresh rate when a compatible compositing
387window manager is in use.
386 388
387@item @code{verticalScrollBars} (class @code{ScrollBars}) 389@item @code{verticalScrollBars} (class @code{ScrollBars})
388Give frames scroll bars on the left if @samp{left}, on the right if 390Give frames scroll bars on the left if @samp{left}, on the right if
diff --git a/etc/NEWS b/etc/NEWS
index 43f057a407b..cd2897cd6dd 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -598,7 +598,7 @@ Only in the Lucid build, this controls colors used for highlighted
598menu item widgets. 598menu item widgets.
599 599
600+++ 600+++
601** On X11, Emacs now tries to synchronize window resize with the window manager. 601** On X, Emacs now tries to synchronize window resize with the window manager.
602This leads to less flicker and empty areas of a frame being displayed 602This leads to less flicker and empty areas of a frame being displayed
603when a frame is being resized. Unfortunately, it does not work on 603when a frame is being resized. Unfortunately, it does not work on
604some ancient buggy window managers, so if Emacs appears to freeze, but 604some ancient buggy window managers, so if Emacs appears to freeze, but
@@ -606,6 +606,15 @@ is still responsive to input, you can turn it off by setting the X
606resource "synchronizeResize" to "off". 606resource "synchronizeResize" to "off".
607 607
608+++ 608+++
609** On X, Emacs can optionally synchronize display with the graphics hardware.
610When this is enabled by setting the X resource "synchronizeResize" to
611"extended", frame content "tearing" is drastically reduced. This is
612only supported on the Motif, Lucid, and no-toolkit builds, and
613requires an X compositing manager supporting the extended frame
614synchronization protocol (see
615https://fishsoup.net/misc/wm-spec-synchronization.html).
616
617+++
609** New frame parameter 'alpha-background' and X resource "alphaBackground". 618** New frame parameter 'alpha-background' and X resource "alphaBackground".
610This controls the opacity of the text background when running on a 619This controls the opacity of the text background when running on a
611composited display. 620composited display.
diff --git a/src/xterm.c b/src/xterm.c
index d3ffd432dd2..4d4febcc368 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -6653,14 +6653,8 @@ x_sync_update_begin (struct frame *f)
6653 if (XSyncValueLow32 (value) % 2) 6653 if (XSyncValueLow32 (value) % 2)
6654 return; 6654 return;
6655 6655
6656 /* Wait for a pending frame draw event if the last frame has not yet 6656 /* Wait for the last frame to be drawn before drawing this one. */
6657 been drawn if F isn't double buffered. (In double buffered 6657 x_sync_wait_for_frame_drawn_event (f);
6658 frames, this happens before buffer flipping). */
6659
6660#ifdef HAVE_XDBE
6661 if (!FRAME_X_DOUBLE_BUFFERED_P (f))
6662#endif
6663 x_sync_wait_for_frame_drawn_event (f);
6664 6658
6665 /* Since Emacs needs a non-urgent redraw, ensure that value % 4 == 6659 /* Since Emacs needs a non-urgent redraw, ensure that value % 4 ==
6666 0. */ 6660 0. */
@@ -6672,11 +6666,10 @@ x_sync_update_begin (struct frame *f)
6672 XSyncValueAdd (&FRAME_X_COUNTER_VALUE (f), 6666 XSyncValueAdd (&FRAME_X_COUNTER_VALUE (f),
6673 value, add, &overflow); 6667 value, add, &overflow);
6674 6668
6675 if (XSyncValueLow32 (FRAME_X_COUNTER_VALUE (f)) % 4 != 1)
6676 emacs_abort ();
6677
6678 if (overflow) 6669 if (overflow)
6679 XSyncIntToValue (&FRAME_X_COUNTER_VALUE (f), 1); 6670 XSyncIntToValue (&FRAME_X_COUNTER_VALUE (f), 3);
6671
6672 eassert (XSyncValueLow32 (FRAME_X_COUNTER_VALUE (f)) % 4 != 1);
6680 6673
6681 XSyncSetCounter (FRAME_X_DISPLAY (f), 6674 XSyncSetCounter (FRAME_X_DISPLAY (f),
6682 FRAME_X_EXTENDED_COUNTER (f), 6675 FRAME_X_EXTENDED_COUNTER (f),
@@ -6741,7 +6734,10 @@ static void
6741x_update_begin (struct frame *f) 6734x_update_begin (struct frame *f)
6742{ 6735{
6743#if defined HAVE_XSYNC && !defined USE_GTK 6736#if defined HAVE_XSYNC && !defined USE_GTK
6744 x_sync_update_begin (f); 6737 /* If F is double-buffered, we can make the entire frame center
6738 around XdbeSwapBuffers. */
6739 if (!FRAME_X_DOUBLE_BUFFERED_P (f))
6740 x_sync_update_begin (f);
6745#else 6741#else
6746 /* Nothing to do. */ 6742 /* Nothing to do. */
6747#endif 6743#endif
@@ -6847,6 +6843,9 @@ show_back_buffer (struct frame *f)
6847 /* Wait for drawing of the previous frame to complete before 6843 /* Wait for drawing of the previous frame to complete before
6848 displaying this new frame. */ 6844 displaying this new frame. */
6849 x_sync_wait_for_frame_drawn_event (f); 6845 x_sync_wait_for_frame_drawn_event (f);
6846
6847 /* Begin a new frame. */
6848 x_sync_update_begin (f);
6850#endif 6849#endif
6851 6850
6852#ifdef USE_CAIRO 6851#ifdef USE_CAIRO
@@ -6858,7 +6857,13 @@ show_back_buffer (struct frame *f)
6858 swap_info.swap_window = FRAME_X_WINDOW (f); 6857 swap_info.swap_window = FRAME_X_WINDOW (f);
6859 swap_info.swap_action = XdbeCopied; 6858 swap_info.swap_action = XdbeCopied;
6860 XdbeSwapBuffers (FRAME_X_DISPLAY (f), &swap_info, 1); 6859 XdbeSwapBuffers (FRAME_X_DISPLAY (f), &swap_info, 1);
6860
6861#if defined HAVE_XSYNC && !defined USE_GTK
6862 /* Finish the frame here. */
6863 x_sync_update_finish (f);
6864#endif
6861 } 6865 }
6866
6862 FRAME_X_NEED_BUFFER_FLIP (f) = false; 6867 FRAME_X_NEED_BUFFER_FLIP (f) = false;
6863 6868
6864 unblock_input (); 6869 unblock_input ();
@@ -6883,10 +6888,7 @@ x_flip_and_flush (struct frame *f)
6883 block_input (); 6888 block_input ();
6884#ifdef HAVE_XDBE 6889#ifdef HAVE_XDBE
6885 if (FRAME_X_NEED_BUFFER_FLIP (f)) 6890 if (FRAME_X_NEED_BUFFER_FLIP (f))
6886 { 6891 show_back_buffer (f);
6887 show_back_buffer (f);
6888 x_sync_update_finish (f);
6889 }
6890#endif 6892#endif
6891 x_flush (f); 6893 x_flush (f);
6892 unblock_input (); 6894 unblock_input ();
@@ -6941,11 +6943,6 @@ XTframe_up_to_date (struct frame *f)
6941 if (!buffer_flipping_blocked_p () 6943 if (!buffer_flipping_blocked_p ()
6942 && FRAME_X_NEED_BUFFER_FLIP (f)) 6944 && FRAME_X_NEED_BUFFER_FLIP (f))
6943 show_back_buffer (f); 6945 show_back_buffer (f);
6944
6945#if defined HAVE_XSYNC && !defined USE_GTK
6946 if (FRAME_X_DOUBLE_BUFFERED_P (f))
6947 x_sync_update_finish (f);
6948#endif
6949#endif 6946#endif
6950 6947
6951#ifdef HAVE_XSYNC 6948#ifdef HAVE_XSYNC
@@ -17027,6 +17024,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
17027 XSyncIntsToValue (&FRAME_X_COUNTER_VALUE (f), 17024 XSyncIntsToValue (&FRAME_X_COUNTER_VALUE (f),
17028 event->xclient.data.l[2], 17025 event->xclient.data.l[2],
17029 event->xclient.data.l[3]); 17026 event->xclient.data.l[3]);
17027
17030 FRAME_X_OUTPUT (f)->ext_sync_end_pending_p = true; 17028 FRAME_X_OUTPUT (f)->ext_sync_end_pending_p = true;
17031 } 17029 }
17032 17030