summaryrefslogtreecommitdiff
path: root/src/xfns.c
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2022-07-29 16:20:32 +0800
committerPo Lu <luangruo@yahoo.com>2022-07-29 17:27:36 +0800
commitee93a06b8b1922b31e12cfe60566779f185ddeba (patch)
tree31d1e4e2ec3c64ea78c077b91a5546e6322ef274 /src/xfns.c
parentdb03eda6369a9d4af3c72a8ab6ec29e3cc58acc4 (diff)
downloademacs-ee93a06b8b1922b31e12cfe60566779f185ddeba.tar.gz
Implement monitor refresh rate synchronization on X
* src/xfns.c (x_set_parent_frame, Fx_create_frame): Disable vsync on child and embedded frames. * src/xmenu.c (x_menu_show): Fix XMenu position calculation in child frames. * src/xterm.c (x_sync_is_frame_drawn_event) (x_sync_wait_for_frame_drawn_event): New functions. (x_sync_update_begin): Wait for frame to be drawn if not double buffered. (x_sync_update_finish): Set FRAME_X_WAITING_FOR_DRAW (f). (show_back_buffer): Wait for frame to be drawn before flipping buffers. (XTframe_up_to_date): Set FRAME_X_WAITING_FOR_DRAW if bumped. (handle_one_xevent): Handle frame drawn events. * src/xterm.h (struct x_output): New fields for frame dirtyness and vsync.
Diffstat (limited to 'src/xfns.c')
-rw-r--r--src/xfns.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/xfns.c b/src/xfns.c
index 076cd97875a..579237068a2 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -976,6 +976,16 @@ x_set_parent_frame (struct frame *f, Lisp_Object new_value, Lisp_Object old_valu
gdk_x11_window_set_frame_sync_enabled (window, FALSE);
}
#endif
+
+#if defined HAVE_XSYNC && !defined USE_GTK
+ /* Frame synchronization can't be used in child frames since
+ they are not directly managed by the compositing manager.
+ Re-enabling vsync in former child frames also leads to
+ inconsistent display. In addition, they can only be updated
+ outside of a toplevel frame. */
+ FRAME_X_OUTPUT (f)->use_vsync_p = false;
+ FRAME_X_WAITING_FOR_DRAW (f) = false;
+#endif
unblock_input ();
fset_parent_frame (f, new_value);
@@ -5113,7 +5123,10 @@ This function is an internal primitive--use `make-frame' instead. */)
}
#ifdef HAVE_XSYNC
- if (dpyinfo->xsync_supported_p)
+ if (dpyinfo->xsync_supported_p
+ /* Frame synchronization isn't supported in child frames. */
+ && NILP (parent_frame)
+ && !f->output_data.x->explicit_parent)
{
#ifndef HAVE_GTK3
XSyncValue initial_value;
@@ -5149,6 +5162,12 @@ This function is an internal primitive--use `make-frame' instead. */)
((STRINGP (value)
&& !strcmp (SSDATA (value), "extended")) ? 2 : 1));
#endif
+
+#ifndef USE_GTK
+ if (FRAME_X_EXTENDED_COUNTER (f))
+ FRAME_X_OUTPUT (f)->use_vsync_p
+ = x_wm_supports (f, dpyinfo->Xatom_net_wm_frame_drawn);
+#endif
}
#endif