aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-07-29 17:14:05 +0800
committerPo Lu2022-07-29 17:27:36 +0800
commitacefbcf8351180b4eff46b30491ce758dcc42feb (patch)
tree7e7a5d8a6622684d5284589e68722ea0178891f9 /src
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.
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c42
1 files changed, 20 insertions, 22 deletions
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