]> git.eshelyaron.com Git - emacs.git/commitdiff
Correctly handle frame synchronization on fullscreen KWin
authorPo Lu <luangruo@yahoo.com>
Tue, 6 Sep 2022 11:39:05 +0000 (19:39 +0800)
committerPo Lu <luangruo@yahoo.com>
Tue, 6 Sep 2022 11:39:24 +0000 (19:39 +0800)
* src/xfns.c (x_set_use_frame_synchronization): Announce that we
do not want the compositor to unredirect the frame while
fullscreen.
* src/xterm.c (x_atom_refs): New atom
`_NET_WM_BYPASS_COMPOSITOR'.
* src/xterm.h (struct x_display_info): Likewise.

src/xfns.c
src/xterm.c
src/xterm.h

index 2da1e7bcf80a52ba5e4eedf3f097c5d6aa40d33b..fc8b30a9d6ffac72b71c0c34e6423ada20088ae6 100644 (file)
@@ -2423,14 +2423,33 @@ x_set_use_frame_synchronization (struct frame *f, Lisp_Object arg,
 {
 #if defined HAVE_XSYNC && !defined USE_GTK && defined HAVE_CLOCK_GETTIME
   struct x_display_info *dpyinfo;
+  unsigned long bypass_compositor;
 
   dpyinfo = FRAME_DISPLAY_INFO (f);
 
   if (!NILP (arg) && FRAME_X_EXTENDED_COUNTER (f))
-    FRAME_X_OUTPUT (f)->use_vsync_p
-      = x_wm_supports (f, dpyinfo->Xatom_net_wm_frame_drawn);
+    {
+      FRAME_X_OUTPUT (f)->use_vsync_p
+       = x_wm_supports (f, dpyinfo->Xatom_net_wm_frame_drawn);
+
+      /* At the same time, write the bypass compositor property to the
+        outer window.  2 means to never bypass the compositor, as we
+        need its cooperation for frame synchronization.  */
+      bypass_compositor = 2;
+      XChangeProperty (dpyinfo->display, FRAME_OUTER_WINDOW (f),
+                      dpyinfo->Xatom_net_wm_bypass_compositor,
+                      XA_CARDINAL, 32, PropModeReplace,
+                      (unsigned char *) &bypass_compositor, 1);
+    }
   else
-    FRAME_X_OUTPUT (f)->use_vsync_p = false;
+    {
+      FRAME_X_OUTPUT (f)->use_vsync_p = false;
+
+      /* Remove the compositor bypass property from the outer
+        window.  */
+      XDeleteProperty (dpyinfo->display, FRAME_OUTER_WINDOW (f),
+                      dpyinfo->Xatom_net_wm_bypass_compositor);
+    }
 
   store_frame_param (f, Quse_frame_synchronization,
                     FRAME_X_OUTPUT (f)->use_vsync_p ? Qt : Qnil);
index c58f2d15da24a9ed07cc0c4ec2745889e68e97d6..6f76622bfe2424996fa90d806ca357c615488f60 100644 (file)
@@ -998,6 +998,7 @@ static const struct x_atom_ref x_atom_refs[] =
     ATOM_REFS_INIT ("_NET_WM_SYNC_REQUEST", Xatom_net_wm_sync_request)
     ATOM_REFS_INIT ("_NET_WM_SYNC_REQUEST_COUNTER", Xatom_net_wm_sync_request_counter)
     ATOM_REFS_INIT ("_NET_WM_SYNC_FENCES", Xatom_net_wm_sync_fences)
+    ATOM_REFS_INIT ("_NET_WM_BYPASS_COMPOSITOR", Xatom_net_wm_bypass_compositor)
     ATOM_REFS_INIT ("_NET_WM_FRAME_DRAWN", Xatom_net_wm_frame_drawn)
     ATOM_REFS_INIT ("_NET_WM_FRAME_TIMINGS", Xatom_net_wm_frame_timings)
     ATOM_REFS_INIT ("_NET_WM_USER_TIME", Xatom_net_wm_user_time)
index 7c5a889af30757700bd569e3446114b8a22c17b6..d6ff15e40f76e52cc4af8f4fd6f39c19627c078c 100644 (file)
@@ -656,7 +656,8 @@ struct x_display_info
     Xatom_net_wm_sync_request, Xatom_net_wm_sync_request_counter,
     Xatom_net_wm_sync_fences, Xatom_net_wm_frame_drawn, Xatom_net_wm_frame_timings,
     Xatom_net_wm_user_time, Xatom_net_wm_user_time_window,
-    Xatom_net_client_list_stacking, Xatom_net_wm_pid;
+    Xatom_net_client_list_stacking, Xatom_net_wm_pid,
+    Xatom_net_wm_bypass_compositor;
 
   /* XSettings atoms and windows.  */
   Atom Xatom_xsettings_sel, Xatom_xsettings_prop, Xatom_xsettings_mgr;