]> git.eshelyaron.com Git - emacs.git/commitdiff
Minor additions to last change
authorPo Lu <luangruo@yahoo.com>
Fri, 29 Jul 2022 09:14:05 +0000 (17:14 +0800)
committerPo Lu <luangruo@yahoo.com>
Fri, 29 Jul 2022 09:27:36 +0000 (17:27 +0800)
* 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
etc/NEWS
src/xterm.c

index 8915d2025ba46728c1dee75ef507b73c74a6dd99..ab0df3563f5ddb1aeaa4a13703fb96a0aef46d98 100644 (file)
@@ -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
index 43f057a407b45a28040f5b0062951494eb5e4fbb..cd2897cd6ddf44cb1774c5873304ead591661ee0 100644 (file)
--- 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
index d3ffd432dd273ec9dc5b3f946bcf901e79a9cb00..4d4febcc3685c1fd25a5adfb0b7ee7851006fd70 100644 (file)
@@ -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;
                      }