[mutter/wip/frame-synchronization] Tweak frame synchronization for final wm-spec changes



commit 42f6ddf34407f59c791ad39321076dea11594efd
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Tue Dec 18 13:20:22 2012 -0500

    Tweak frame synchronization for final wm-spec changes
    
    * Consistently send 64-bit values as low-32-bits / high-32-bits
    * Use data.l[4] in _NET_WM_SYNC_REQUEST to say which counter
      should be changed
    * Update frame ounter for _NET_WM_SYNC_REQUEST by 240 not by 100
    * Include the frame delay in _NET_WM_FRAME_TIMINGS

 src/compositor/compositor-private.h |    2 ++
 src/compositor/compositor.c         |    2 +-
 src/compositor/meta-window-actor.c  |   14 ++++++++------
 src/core/window.c                   |    5 ++---
 4 files changed, 13 insertions(+), 10 deletions(-)
---
diff --git a/src/compositor/compositor-private.h b/src/compositor/compositor-private.h
index 07eaf14..27bcca6 100644
--- a/src/compositor/compositor-private.h
+++ b/src/compositor/compositor-private.h
@@ -61,6 +61,8 @@ struct _MetaCompScreen
   MetaPluginManager *plugin_mgr;
 };
 
+#define META_SYNC_DELAY 2
+
 void meta_switch_workspace_completed (MetaScreen    *screen);
 
 gboolean meta_begin_modal_for_plugin (MetaScreen       *screen,
diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c
index 2d062d4..948ac20 100644
--- a/src/compositor/compositor.c
+++ b/src/compositor/compositor.c
@@ -530,7 +530,7 @@ meta_compositor_manage_screen (MetaCompositor *compositor,
                           G_CALLBACK (after_stage_paint), info);
 
   /* Wait 6-ms after vblank before starting to draw next frame */
-  clutter_stage_set_sync_delay (CLUTTER_STAGE (info->stage), 2);
+  clutter_stage_set_sync_delay (CLUTTER_STAGE (info->stage), META_SYNC_DELAY);
 
   meta_screen_get_size (screen, &width, &height);
   clutter_actor_realize (info->stage);
diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c
index fba103b..47c24df 100644
--- a/src/compositor/meta-window-actor.c
+++ b/src/compositor/meta-window-actor.c
@@ -2478,10 +2478,10 @@ meta_window_actor_post_paint (MetaWindowActor *self)
       ev.window = meta_window_get_xwindow (priv->window);
       ev.message_type = display->atom__NET_WM_FRAME_DRAWN;
       ev.format = 32;
-      ev.data.l[0] = frame->sync_request_serial >> 32;
-      ev.data.l[1] = frame->sync_request_serial & G_GUINT64_CONSTANT(0xffffffff);
-      ev.data.l[2] = frame->frame_drawn_time >> 32;
-      ev.data.l[3] = frame->frame_drawn_time & G_GUINT64_CONSTANT(0xffffffff);
+      ev.data.l[0] = frame->sync_request_serial & G_GUINT64_CONSTANT(0xffffffff);
+      ev.data.l[1] = frame->sync_request_serial >> 32;
+      ev.data.l[2] = frame->frame_drawn_time & G_GUINT64_CONSTANT(0xffffffff);
+      ev.data.l[3] = frame->frame_drawn_time >> 32;
 
       meta_error_trap_push (display);
       XSendEvent (xdisplay, ev.window, False, 0, (XEvent*) &ev);
@@ -2511,8 +2511,8 @@ send_frame_timings (MetaWindowActor  *self,
   ev.window = meta_window_get_xwindow (priv->window);
   ev.message_type = display->atom__NET_WM_FRAME_TIMINGS;
   ev.format = 32;
-  ev.data.l[0] = frame->sync_request_serial >> 32;
-  ev.data.l[1] = frame->sync_request_serial & G_GUINT64_CONSTANT(0xffffffff);
+  ev.data.l[0] = frame->sync_request_serial & G_GUINT64_CONSTANT(0xffffffff);
+  ev.data.l[1] = frame->sync_request_serial >> 32;
 
   if (frame_timings)
     {
@@ -2537,6 +2537,8 @@ send_frame_timings (MetaWindowActor  *self,
         }
     }
 
+  ev.data.l[4] = 1000 * META_SYNC_DELAY;
+
   meta_error_trap_push (display);
   XSendEvent (xdisplay, ev.window, False, 0, (XEvent*) &ev);
   XFlush (xdisplay);
diff --git a/src/core/window.c b/src/core/window.c
index f38591d..89a14de 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -4495,9 +4495,7 @@ send_sync_request (MetaWindow *window)
    * pick an even (unfrozen) value sufficiently ahead of the last serial
    * that we received from the client; the same code still works
    * for the old style */
-  wait_serial = window->sync_request_serial + 100;
-  if (wait_serial % 2 == 1)
-    wait_serial++;
+  wait_serial = window->sync_request_serial + 240;
 
   window->display->grab_sync_counter_wait_serial = wait_serial;
 
@@ -4514,6 +4512,7 @@ send_sync_request (MetaWindow *window)
   ev.data.l[1] = meta_display_get_current_time (window->display);
   ev.data.l[2] = wait_serial & G_GUINT64_CONSTANT(0xffffffff);
   ev.data.l[3] = wait_serial >> 32;
+  ev.data.l[4] = window->extended_sync_request_counter ? 1 : 0;
 
   /* We don't need to trap errors here as we are already
    * inside an error_trap_push()/pop() pair.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]