[gtk+/wip/frame-synchronization] Fix up for newer draft of wm-spec



commit b095a5338e180f67c386f5384ca3a15e03b348ed
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Wed Dec 19 12:01:52 2012 -0500

    Fix up for newer draft of wm-spec
    
    * 64-bit quantities are consistently ordered low-32-bits / high-32-bits
    * data.l[4] in _NET_WM_SYNC_REQUEST indicates which counter to update

 gdk/x11/gdkdisplay-x11.c |    8 +++++---
 gdk/x11/gdkwindow-x11.c  |   29 +++++++++++++++++------------
 gdk/x11/gdkwindow-x11.h  |    7 ++++++-
 3 files changed, 28 insertions(+), 16 deletions(-)
---
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index fc5c72d..23f1c0c 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -763,6 +763,7 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
       if (!is_substructure && toplevel && display_x11->use_sync && toplevel->pending_counter_value != 0)
 	{
 	  toplevel->configure_counter_value = toplevel->pending_counter_value;
+	  toplevel->configure_counter_value_is_extended = toplevel->pending_counter_value_is_extended;
 	  toplevel->pending_counter_value = 0;
 	}
 #endif
@@ -1107,8 +1108,8 @@ _gdk_wm_protocols_filter (GdkXEvent *xev,
           guint32 d2 = xevent->xclient.data.l[2];
           guint32 d3 = xevent->xclient.data.l[3];
 
-          guint64 serial = ((guint64)d0 << 32) | d1;
-          gint64 frame_drawn_time = ((guint64)d2 << 32) | d3;
+          guint64 serial = ((guint64)d1 << 32) | d0;
+          gint64 frame_drawn_time = ((guint64)d3 << 32) | d2;
           gint64 refresh_interval, presentation_time;
 
           GdkPaintClock *clock = gdk_window_get_paint_clock (event->any.window);
@@ -1145,7 +1146,7 @@ _gdk_wm_protocols_filter (GdkXEvent *xev,
           guint32 d2 = xevent->xclient.data.l[2];
           guint32 d3 = xevent->xclient.data.l[3];
 
-          guint64 serial = ((guint64)d0 << 32) | d1;
+          guint64 serial = ((guint64)d1 << 32) | d0;
 
           GdkPaintClock *clock = gdk_window_get_paint_clock (event->any.window);
           GdkFrameTimings *timings = find_frame_timings (clock, serial);
@@ -1239,6 +1240,7 @@ _gdk_wm_protocols_filter (GdkXEvent *xev,
 	{
 #ifdef HAVE_XSYNC
 	  toplevel->pending_counter_value = xevent->xclient.data.l[2] + ((gint64)xevent->xclient.data.l[3] << 32);
+	  toplevel->pending_counter_value_is_extended = xevent->xclient.data.l[4] != 0;
 #endif
 	}
       return GDK_FILTER_REMOVE;
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index 2900c87..d284556 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -5004,20 +5004,25 @@ gdk_x11_window_configure_finished (GdkWindow *window)
 	  GDK_X11_DISPLAY (display)->use_sync &&
 	  toplevel->configure_counter_value != 0)
 	{
-	  set_sync_counter (GDK_WINDOW_XDISPLAY (window),
-			    toplevel->update_counter,
-			    toplevel->configure_counter_value);
-
-	  toplevel->current_counter_value = toplevel->configure_counter_value;
-	  if ((toplevel->current_counter_value % 2) == 1)
-	    toplevel->current_counter_value += 1;
+          if (toplevel->configure_counter_value_is_extended)
+            {
+              toplevel->current_counter_value = toplevel->configure_counter_value;
+              if ((toplevel->current_counter_value % 2) == 1)
+                toplevel->current_counter_value += 1;
 
-	  toplevel->configure_counter_value = 0;
+              toplevel->configure_counter_value = 0;
 
-	  set_sync_counter (GDK_WINDOW_XDISPLAY (window),
-			    toplevel->extended_update_counter,
-			    toplevel->current_counter_value);
-	}
+              set_sync_counter (GDK_WINDOW_XDISPLAY (window),
+                                toplevel->extended_update_counter,
+                                toplevel->current_counter_value);
+            }
+          else
+            {
+              set_sync_counter (GDK_WINDOW_XDISPLAY (window),
+                                toplevel->update_counter,
+                                toplevel->configure_counter_value);
+            }
+        }
     }
 #endif
 }
diff --git a/gdk/x11/gdkwindow-x11.h b/gdk/x11/gdkwindow-x11.h
index 7eb95a0..d58d7e3 100644
--- a/gdk/x11/gdkwindow-x11.h
+++ b/gdk/x11/gdkwindow-x11.h
@@ -131,7 +131,12 @@ struct _GdkToplevelX11
 
   /* If we're expecting a response from the compositor after painting a frame */
   guint frame_pending : 1;
-  
+
+  /* Whether pending_counter_value/configure_counter_value are updates
+   * to the extended update counter */
+  guint pending_counter_value_is_extended : 1;
+  guint configure_counter_value_is_extended : 1;
+
   gulong map_serial;	/* Serial of last transition from unmapped */
   
   cairo_surface_t *icon_pixmap;



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