[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master acefbcf835 2/3: Minor additions to last change
From: |
Po Lu |
Subject: |
master acefbcf835 2/3: Minor additions to last change |
Date: |
Fri, 29 Jul 2022 05:27:49 -0400 (EDT) |
branch: master
commit acefbcf8351180b4eff46b30491ce758dcc42feb
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
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.
---
doc/emacs/xresources.texi | 4 +++-
etc/NEWS | 11 ++++++++++-
src/xterm.c | 42 ++++++++++++++++++++----------------------
3 files changed, 33 insertions(+), 24 deletions(-)
diff --git a/doc/emacs/xresources.texi b/doc/emacs/xresources.texi
index 8915d2025b..ab0df3563f 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
from being displayed. If set to @samp{extended}, it will enable use
of an alternative frame synchronization protocol, which might be
supported by some compositing window managers that don't support the
-protocol Emacs uses by default.
+protocol Emacs uses by default, and causes Emacs to synchronize
+display with the monitor refresh rate when a compatible compositing
+window manager is in use.
@item @code{verticalScrollBars} (class @code{ScrollBars})
Give frames scroll bars on the left if @samp{left}, on the right if
diff --git a/etc/NEWS b/etc/NEWS
index 43f057a407..cd2897cd6d 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -598,13 +598,22 @@ Only in the Lucid build, this controls colors used for
highlighted
menu item widgets.
+++
-** On X11, Emacs now tries to synchronize window resize with the window
manager.
+** On X, Emacs now tries to synchronize window resize with the window manager.
This leads to less flicker and empty areas of a frame being displayed
when a frame is being resized. Unfortunately, it does not work on
some ancient buggy window managers, so if Emacs appears to freeze, but
is still responsive to input, you can turn it off by setting the X
resource "synchronizeResize" to "off".
++++
+** On X, Emacs can optionally synchronize display with the graphics hardware.
+When this is enabled by setting the X resource "synchronizeResize" to
+"extended", frame content "tearing" is drastically reduced. This is
+only supported on the Motif, Lucid, and no-toolkit builds, and
+requires an X compositing manager supporting the extended frame
+synchronization protocol (see
+https://fishsoup.net/misc/wm-spec-synchronization.html).
+
+++
** New frame parameter 'alpha-background' and X resource "alphaBackground".
This controls the opacity of the text background when running on a
diff --git a/src/xterm.c b/src/xterm.c
index d3ffd432dd..4d4febcc36 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -6653,14 +6653,8 @@ x_sync_update_begin (struct frame *f)
if (XSyncValueLow32 (value) % 2)
return;
- /* Wait for a pending frame draw event if the last frame has not yet
- been drawn if F isn't double buffered. (In double buffered
- frames, this happens before buffer flipping). */
-
-#ifdef HAVE_XDBE
- if (!FRAME_X_DOUBLE_BUFFERED_P (f))
-#endif
- x_sync_wait_for_frame_drawn_event (f);
+ /* Wait for the last frame to be drawn before drawing this one. */
+ x_sync_wait_for_frame_drawn_event (f);
/* Since Emacs needs a non-urgent redraw, ensure that value % 4 ==
0. */
@@ -6672,11 +6666,10 @@ x_sync_update_begin (struct frame *f)
XSyncValueAdd (&FRAME_X_COUNTER_VALUE (f),
value, add, &overflow);
- if (XSyncValueLow32 (FRAME_X_COUNTER_VALUE (f)) % 4 != 1)
- emacs_abort ();
-
if (overflow)
- XSyncIntToValue (&FRAME_X_COUNTER_VALUE (f), 1);
+ XSyncIntToValue (&FRAME_X_COUNTER_VALUE (f), 3);
+
+ eassert (XSyncValueLow32 (FRAME_X_COUNTER_VALUE (f)) % 4 != 1);
XSyncSetCounter (FRAME_X_DISPLAY (f),
FRAME_X_EXTENDED_COUNTER (f),
@@ -6741,7 +6734,10 @@ static void
x_update_begin (struct frame *f)
{
#if defined HAVE_XSYNC && !defined USE_GTK
- x_sync_update_begin (f);
+ /* If F is double-buffered, we can make the entire frame center
+ around XdbeSwapBuffers. */
+ if (!FRAME_X_DOUBLE_BUFFERED_P (f))
+ x_sync_update_begin (f);
#else
/* Nothing to do. */
#endif
@@ -6847,6 +6843,9 @@ show_back_buffer (struct frame *f)
/* Wait for drawing of the previous frame to complete before
displaying this new frame. */
x_sync_wait_for_frame_drawn_event (f);
+
+ /* Begin a new frame. */
+ x_sync_update_begin (f);
#endif
#ifdef USE_CAIRO
@@ -6858,7 +6857,13 @@ show_back_buffer (struct frame *f)
swap_info.swap_window = FRAME_X_WINDOW (f);
swap_info.swap_action = XdbeCopied;
XdbeSwapBuffers (FRAME_X_DISPLAY (f), &swap_info, 1);
+
+#if defined HAVE_XSYNC && !defined USE_GTK
+ /* Finish the frame here. */
+ x_sync_update_finish (f);
+#endif
}
+
FRAME_X_NEED_BUFFER_FLIP (f) = false;
unblock_input ();
@@ -6883,10 +6888,7 @@ x_flip_and_flush (struct frame *f)
block_input ();
#ifdef HAVE_XDBE
if (FRAME_X_NEED_BUFFER_FLIP (f))
- {
- show_back_buffer (f);
- x_sync_update_finish (f);
- }
+ show_back_buffer (f);
#endif
x_flush (f);
unblock_input ();
@@ -6941,11 +6943,6 @@ XTframe_up_to_date (struct frame *f)
if (!buffer_flipping_blocked_p ()
&& FRAME_X_NEED_BUFFER_FLIP (f))
show_back_buffer (f);
-
-#if defined HAVE_XSYNC && !defined USE_GTK
- if (FRAME_X_DOUBLE_BUFFERED_P (f))
- x_sync_update_finish (f);
-#endif
#endif
#ifdef HAVE_XSYNC
@@ -17027,6 +17024,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
XSyncIntsToValue (&FRAME_X_COUNTER_VALUE (f),
event->xclient.data.l[2],
event->xclient.data.l[3]);
+
FRAME_X_OUTPUT (f)->ext_sync_end_pending_p = true;
}