[mutter/gbsneto/cleanup-x11-from-meta-window: 1/5] window: Move _NET_WM_SYNC_REQUEST and family to MetaWindowX11



commit f8577ce32135ed5cb2d97f21064dcf26b2e30c25
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Sat Dec 22 17:27:32 2018 -0200

    window: Move _NET_WM_SYNC_REQUEST and family to MetaWindowX11
    
    The code to react to _NET_WM_SYNC_REQUEST and family (counter,
    alarm, etc) currently lives in MetaWindow, even though most of
    its management is done by MetaWindowX11.
    
    In an ideal Wayland-as-default world, MetaWindow is completely
    agnostic to the display server implementation, delegating to
    MetaWindowX11 and MetaWindowWayland their respective display
    server internals.
    
    To help this goal, move the X11-specific code to deal with
    _NET_WM_SYNC_REQUEST to MetaWindowX11.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/372

 src/compositor/meta-window-actor-x11.c |   9 +-
 src/core/window-private.h              |  15 ---
 src/core/window.c                      |  19 +--
 src/x11/window-props.c                 |  29 +----
 src/x11/window-x11-private.h           |  22 ++++
 src/x11/window-x11.c                   | 210 +++++++++++++++++++++++++--------
 src/x11/window-x11.h                   |   6 +
 7 files changed, 199 insertions(+), 111 deletions(-)
---
diff --git a/src/compositor/meta-window-actor-x11.c b/src/compositor/meta-window-actor-x11.c
index a364323fe..ca0cc6515 100644
--- a/src/compositor/meta-window-actor-x11.c
+++ b/src/compositor/meta-window-actor-x11.c
@@ -30,6 +30,7 @@
 #include "meta/meta-x11-errors.h"
 #include "meta/window.h"
 #include "x11/meta-x11-display-private.h"
+#include "x11/window-x11.h"
 
 struct _MetaWindowActorX11
 {
@@ -366,9 +367,12 @@ meta_window_actor_x11_queue_frame_drawn (MetaWindowActor *actor,
   if (meta_window_actor_is_destroyed (actor))
     return;
 
+  g_assert (META_IS_WINDOW_X11 (window));
+
   frame = g_slice_new0 (FrameData);
   frame->frame_counter = -1;
-  frame->sync_request_serial = window->sync_request_serial;
+  frame->sync_request_serial =
+    meta_window_x11_get_sync_request_serial (META_WINDOW_X11 (window));
 
   actor_x11->frames = g_list_prepend (actor_x11->frames, frame);
 
@@ -485,13 +489,14 @@ meta_window_actor_x11_constructed (GObject *object)
   MetaWindowActor *window_actor = META_WINDOW_ACTOR (object);
   MetaWindow *window =
     meta_window_actor_get_meta_window (window_actor);
+  MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
 
   G_OBJECT_CLASS (meta_window_actor_x11_parent_class)->constructed (object);
 
   /* If a window doesn't start off with updates frozen, we should
    * we should send a _NET_WM_FRAME_DRAWN immediately after the first drawn.
    */
-  if (window->extended_sync_request_counter &&
+  if (meta_window_x11_has_extended_sync_request_counter (window_x11) &&
       !meta_window_updates_are_frozen (window))
     meta_window_actor_queue_frame_drawn (window_actor, FALSE);
 }
diff --git a/src/core/window-private.h b/src/core/window-private.h
index 1babd307f..8b1a15f7a 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -407,9 +407,6 @@ struct _MetaWindow
   /* if TRUE we have a grab on the focus click buttons */
   guint have_focus_click_grab : 1;
 
-  /* if TRUE, application is buggy and SYNC resizing is turned off */
-  guint disable_sync : 1;
-
   /* if TRUE, window is attached to its parent */
   guint attached : 1;
 
@@ -435,21 +432,9 @@ struct _MetaWindow
   /* _NET_WM_WINDOW_OPACITY rescaled to 0xFF */
   guint8 opacity;
 
-  /* if TRUE, the we have the new form of sync request counter which
-   * also handles application frames */
-  guint extended_sync_request_counter : 1;
-
   /* Note: can be NULL */
   GSList *struts;
 
-  /* XSync update counter */
-  XSyncCounter sync_request_counter;
-  gint64 sync_request_serial;
-  gint64 sync_request_wait_serial;
-  guint sync_request_timeout_id;
-  /* alarm monitoring client's _NET_WM_SYNC_REQUEST_COUNTER */
-  XSyncAlarm sync_request_alarm;
-
   /* Number of UnmapNotify that are caused by us, if
    * we get UnmapNotify with none pending then the client
    * is withdrawing the window.
diff --git a/src/core/window.c b/src/core/window.c
index 60252c4c1..5c0264a21 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -983,11 +983,6 @@ _meta_window_shared_new (MetaDisplay         *display,
 
   window->workspace = NULL;
 
-  window->sync_request_counter = None;
-  window->sync_request_serial = 0;
-  window->sync_request_timeout_id = 0;
-  window->sync_request_alarm = None;
-
   meta_window_update_sandboxed_app_id (window);
   meta_window_update_desc (window);
 
@@ -1070,7 +1065,6 @@ _meta_window_shared_new (MetaDisplay         *display,
   window->calc_placement = FALSE;
   window->shaken_loose = FALSE;
   window->have_focus_click_grab = FALSE;
-  window->disable_sync = FALSE;
 
   window->unmaps_pending = 0;
 
@@ -1515,12 +1509,6 @@ meta_window_unmanage (MetaWindow  *window,
       invalidate_work_areas (window);
     }
 
-  if (window->sync_request_timeout_id)
-    {
-      g_source_remove (window->sync_request_timeout_id);
-      window->sync_request_timeout_id = 0;
-    }
-
   if (window->display->grab_window == window)
     meta_display_end_grab_op (window->display, timestamp);
 
@@ -5934,8 +5922,8 @@ check_moveresize_frequency (MetaWindow *window,
 
   /* If we are throttling via _NET_WM_SYNC_REQUEST, we don't need
    * an artificial timeout-based throttled */
-  if (!window->disable_sync &&
-      window->sync_request_alarm != None)
+  if (window->client_type == META_WINDOW_CLIENT_TYPE_X11 &&
+      meta_window_x11_has_sync_request_alarm (META_WINDOW_X11 (window)))
     return TRUE;
 
   elapsed = time_diff (&current_time, &window->display->grab_last_moveresize_time);
@@ -6297,7 +6285,8 @@ update_resize (MetaWindow *window,
    * resize the window when the window responds, or when we time
    * the response out.
    */
-  if (window->sync_request_timeout_id != 0)
+  if (window->client_type == META_WINDOW_CLIENT_TYPE_X11 &&
+      meta_window_x11_is_sync_request_scheduled (META_WINDOW_X11 (window)))
     return;
 
   if (!check_moveresize_frequency (window, &remaining) && !force)
diff --git a/src/x11/window-props.c b/src/x11/window-props.c
index 65b77cd7e..4178b74ff 100644
--- a/src/x11/window-props.c
+++ b/src/x11/window-props.c
@@ -1068,34 +1068,9 @@ reload_update_counter (MetaWindow    *window,
                        MetaPropValue *value,
                        gboolean       initial)
 {
-  if (value->type != META_PROP_VALUE_INVALID)
-    {
-      meta_window_x11_destroy_sync_request_alarm (window);
-      window->sync_request_counter = None;
-
-      if (value->v.xcounter_list.n_counters == 0)
-        {
-          meta_warning ("_NET_WM_SYNC_REQUEST_COUNTER is empty\n");
-          return;
-        }
-
-      if (value->v.xcounter_list.n_counters == 1)
-        {
-          window->sync_request_counter = value->v.xcounter_list.counters[0];
-          window->extended_sync_request_counter = FALSE;
-        }
-      else
-        {
-          window->sync_request_counter = value->v.xcounter_list.counters[1];
-          window->extended_sync_request_counter = TRUE;
-        }
-      meta_verbose ("Window has _NET_WM_SYNC_REQUEST_COUNTER 0x%lx (extended=%s)\n",
-                    window->sync_request_counter,
-                    window->extended_sync_request_counter ? "true" : "false");
+  MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
 
-      if (window->extended_sync_request_counter)
-        meta_window_x11_create_sync_request_alarm (window);
-    }
+  meta_window_x11_setup_sync_request_counter (window_x11, value);
 }
 
 #define FLAG_TOGGLED_ON(old,new,flag) \
diff --git a/src/x11/window-x11-private.h b/src/x11/window-x11-private.h
index 268f8bdcf..65e019be5 100644
--- a/src/x11/window-x11-private.h
+++ b/src/x11/window-x11-private.h
@@ -25,6 +25,8 @@
 
 #include "core/window-private.h"
 #include "x11/iconcache.h"
+#include "x11/window-x11.h"
+#include "x11/xprops.h"
 
 G_BEGIN_DECLS
 
@@ -69,8 +71,28 @@ struct _MetaWindowX11Private
   MetaIconCache icon_cache;
   Pixmap wm_hints_pixmap;
   Pixmap wm_hints_mask;
+
+  /* alarm monitoring client's _NET_WM_SYNC_REQUEST_COUNTER */
+  XSyncAlarm sync_request_alarm;
+
+  /* XSync update counter */
+  XSyncCounter sync_request_counter;
+
+  int64_t sync_request_serial;
+  int64_t sync_request_wait_serial;
+  guint sync_request_timeout_id;
+
+  /* if TRUE, application is buggy and SYNC resizing is turned off */
+  guint disable_sync : 1;
+
+  /* if TRUE, the we have the new form of sync request counter which
+   * also handles application frames */
+  guint extended_sync_request_counter : 1;
 };
 
+void meta_window_x11_setup_sync_request_counter (MetaWindowX11 *window_x11,
+                                                 MetaPropValue *value);
+
 G_END_DECLS
 
 #endif
diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c
index eb907c96e..839220d4f 100644
--- a/src/x11/window-x11.c
+++ b/src/x11/window-x11.c
@@ -588,6 +588,12 @@ meta_window_x11_unmanage (MetaWindow *window)
   MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
   MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
 
+  if (priv->sync_request_timeout_id)
+    {
+      g_source_remove (priv->sync_request_timeout_id);
+      priv->sync_request_timeout_id = 0;
+    }
+
   meta_x11_error_trap_push (x11_display);
 
   meta_window_x11_destroy_sync_request_alarm (window);
@@ -858,7 +864,7 @@ meta_window_x11_grab_op_began (MetaWindow *window,
 
   if (meta_grab_op_is_resizing (op))
     {
-      if (window->sync_request_counter != None)
+      if (priv->sync_request_counter != None)
         meta_window_x11_create_sync_request_alarm (window);
 
       if (window->size_hints.width_inc > 2 || window->size_hints.height_inc > 2)
@@ -999,18 +1005,20 @@ static gboolean
 sync_request_timeout (gpointer data)
 {
   MetaWindow *window = data;
+  MetaWindowX11Private *priv =
+    meta_window_x11_get_instance_private (META_WINDOW_X11 (window));
 
-  window->sync_request_timeout_id = 0;
+  priv->sync_request_timeout_id = 0;
 
   /* We have now waited for more than a second for the
    * application to respond to the sync request
    */
-  window->disable_sync = TRUE;
+  priv->disable_sync = TRUE;
 
   /* Reset the wait serial, so we don't continue freezing
    * window updates
    */
-  window->sync_request_wait_serial = 0;
+  priv->sync_request_wait_serial = 0;
   meta_compositor_sync_updates_frozen (window->display->compositor, window);
 
   if (window == window->display->grab_window &&
@@ -1029,6 +1037,9 @@ sync_request_timeout (gpointer data)
 static void
 send_sync_request (MetaWindow *window)
 {
+  MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
+  MetaWindowX11Private *priv =
+    meta_window_x11_get_instance_private (window_x11);
   MetaX11Display *x11_display = window->display->x11_display;
   XClientMessageEvent ev;
   gint64 wait_serial;
@@ -1040,9 +1051,9 @@ send_sync_request (MetaWindow *window)
    * for the old style. The increment of 240 is specified by the EWMH
    * and is (1 second) * (60fps) * (an increment of 4 per frame).
    */
-  wait_serial = window->sync_request_serial + 240;
+  wait_serial = priv->sync_request_serial + 240;
 
-  window->sync_request_wait_serial = wait_serial;
+  priv->sync_request_wait_serial = wait_serial;
 
   ev.type = ClientMessage;
   ev.window = window->xwindow;
@@ -1057,7 +1068,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;
+  ev.data.l[4] = priv->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.
@@ -1069,10 +1080,10 @@ send_sync_request (MetaWindow *window)
    * if this time expires, we consider the window unresponsive
    * and resize it unsynchonized.
    */
-  window->sync_request_timeout_id = g_timeout_add (1000,
-                                                   sync_request_timeout,
-                                                   window);
-  g_source_set_name_by_id (window->sync_request_timeout_id,
+  priv->sync_request_timeout_id = g_timeout_add (1000,
+                                                 sync_request_timeout,
+                                                 window);
+  g_source_set_name_by_id (priv->sync_request_timeout_id,
                            "[mutter] sync_request_timeout");
 
   meta_compositor_sync_updates_frozen (window->display->compositor, window);
@@ -1290,7 +1301,7 @@ meta_window_x11_move_resize_internal (MetaWindow                *window,
    * will be left undisturbed for us to paint to the screen until
    * the client finishes redrawing.
    */
-  if (window->extended_sync_request_counter)
+  if (priv->extended_sync_request_counter)
     configure_frame_first = TRUE;
   else
     configure_frame_first = size_dx + size_dy >= 0;
@@ -1318,10 +1329,10 @@ meta_window_x11_move_resize_internal (MetaWindow                *window,
 
       if (window == window->display->grab_window &&
           meta_grab_op_is_resizing (window->display->grab_op) &&
-          !window->disable_sync &&
-          window->sync_request_counter != None &&
-          window->sync_request_alarm != None &&
-          window->sync_request_timeout_id == 0)
+          !priv->disable_sync &&
+          priv->sync_request_counter != None &&
+          priv->sync_request_alarm != None &&
+          priv->sync_request_timeout_id == 0)
         {
           send_sync_request (window);
         }
@@ -1636,11 +1647,15 @@ meta_window_x11_is_stackable (MetaWindow *window)
 static gboolean
 meta_window_x11_are_updates_frozen (MetaWindow *window)
 {
-  if (window->extended_sync_request_counter &&
-      window->sync_request_serial % 2 == 1)
+  MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
+  MetaWindowX11Private *priv =
+    meta_window_x11_get_instance_private (window_x11);
+
+  if (priv->extended_sync_request_counter &&
+      priv->sync_request_serial % 2 == 1)
     return TRUE;
 
-  if (window->sync_request_serial < window->sync_request_wait_serial)
+  if (priv->sync_request_serial < priv->sync_request_wait_serial)
     return TRUE;
 
   return FALSE;
@@ -3499,12 +3514,15 @@ meta_window_x11_set_allowed_actions_hint (MetaWindow *window)
 void
 meta_window_x11_create_sync_request_alarm (MetaWindow *window)
 {
+  MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
+  MetaWindowX11Private *priv =
+    meta_window_x11_get_instance_private (window_x11);
   MetaX11Display *x11_display = window->display->x11_display;
   XSyncAlarmAttributes values;
   XSyncValue init;
 
-  if (window->sync_request_counter == None ||
-      window->sync_request_alarm != None)
+  if (priv->sync_request_counter == None ||
+      priv->sync_request_alarm != None)
     return;
 
   meta_x11_error_trap_push (x11_display);
@@ -3513,29 +3531,29 @@ meta_window_x11_create_sync_request_alarm (MetaWindow *window)
    * the client before mapping the window. In the old style, we're
    * responsible for setting the initial value of the counter.
    */
-  if (window->extended_sync_request_counter)
+  if (priv->extended_sync_request_counter)
     {
       if (!XSyncQueryCounter(x11_display->xdisplay,
-                             window->sync_request_counter,
+                             priv->sync_request_counter,
                              &init))
         {
           meta_x11_error_trap_pop_with_return (x11_display);
-          window->sync_request_counter = None;
+          priv->sync_request_counter = None;
           return;
         }
 
-      window->sync_request_serial =
+      priv->sync_request_serial =
         XSyncValueLow32 (init) + ((gint64)XSyncValueHigh32 (init) << 32);
     }
   else
     {
       XSyncIntToValue (&init, 0);
       XSyncSetCounter (x11_display->xdisplay,
-                       window->sync_request_counter, init);
-      window->sync_request_serial = 0;
+                       priv->sync_request_counter, init);
+      priv->sync_request_serial = 0;
     }
 
-  values.trigger.counter = window->sync_request_counter;
+  values.trigger.counter = priv->sync_request_counter;
   values.trigger.test_type = XSyncPositiveComparison;
 
   /* Initialize to one greater than the current value */
@@ -3549,36 +3567,38 @@ meta_window_x11_create_sync_request_alarm (MetaWindow *window)
   /* we want events (on by default anyway) */
   values.events = True;
 
-  window->sync_request_alarm = XSyncCreateAlarm (x11_display->xdisplay,
-                                                 XSyncCACounter |
-                                                 XSyncCAValueType |
-                                                 XSyncCAValue |
-                                                 XSyncCATestType |
-                                                 XSyncCADelta |
-                                                 XSyncCAEvents,
-                                                 &values);
+  priv->sync_request_alarm = XSyncCreateAlarm (x11_display->xdisplay,
+                                               XSyncCACounter |
+                                               XSyncCAValueType |
+                                               XSyncCAValue |
+                                               XSyncCATestType |
+                                               XSyncCADelta |
+                                               XSyncCAEvents,
+                                               &values);
 
   if (meta_x11_error_trap_pop_with_return (x11_display) == Success)
-    meta_x11_display_register_sync_alarm (x11_display, &window->sync_request_alarm, window);
+    meta_x11_display_register_sync_alarm (x11_display, &priv->sync_request_alarm, window);
   else
     {
-      window->sync_request_alarm = None;
-      window->sync_request_counter = None;
+      priv->sync_request_alarm = None;
+      priv->sync_request_counter = None;
     }
 }
 
 void
 meta_window_x11_destroy_sync_request_alarm (MetaWindow *window)
 {
+  MetaWindowX11Private *priv =
+    meta_window_x11_get_instance_private (META_WINDOW_X11 (window));
   MetaX11Display *x11_display = window->display->x11_display;
 
-  if (window->sync_request_alarm != None)
+  if (priv->sync_request_alarm != None)
     {
       /* Has to be unregistered _before_ clearing the structure field */
-      meta_x11_display_unregister_sync_alarm (x11_display, window->sync_request_alarm);
+      meta_x11_display_unregister_sync_alarm (x11_display, priv->sync_request_alarm);
       XSyncDestroyAlarm (x11_display->xdisplay,
-                         window->sync_request_alarm);
-      window->sync_request_alarm = None;
+                         priv->sync_request_alarm);
+      priv->sync_request_alarm = None;
     }
 }
 
@@ -3586,31 +3606,34 @@ void
 meta_window_x11_update_sync_request_counter (MetaWindow *window,
                                              gint64      new_counter_value)
 {
+  MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
+  MetaWindowX11Private *priv =
+    meta_window_x11_get_instance_private (window_x11);
   gboolean needs_frame_drawn = FALSE;
   gboolean no_delay_frame = FALSE;
 
-  if (window->extended_sync_request_counter && new_counter_value % 2 == 0)
+  if (priv->extended_sync_request_counter && new_counter_value % 2 == 0)
     {
       needs_frame_drawn = TRUE;
-      no_delay_frame = new_counter_value == window->sync_request_serial + 1;
+      no_delay_frame = new_counter_value == priv->sync_request_serial + 1;
     }
 
-  window->sync_request_serial = new_counter_value;
+  priv->sync_request_serial = new_counter_value;
   meta_compositor_sync_updates_frozen (window->display->compositor, window);
 
   if (window == window->display->grab_window &&
       meta_grab_op_is_resizing (window->display->grab_op) &&
-      new_counter_value >= window->sync_request_wait_serial &&
-      (!window->extended_sync_request_counter || new_counter_value % 2 == 0) &&
-      window->sync_request_timeout_id)
+      new_counter_value >= priv->sync_request_wait_serial &&
+      (!priv->extended_sync_request_counter || new_counter_value % 2 == 0) &&
+      priv->sync_request_timeout_id)
     {
       meta_topic (META_DEBUG_RESIZING,
                   "Alarm event received last motion x = %d y = %d\n",
                   window->display->grab_latest_motion_x,
                   window->display->grab_latest_motion_y);
 
-      g_source_remove (window->sync_request_timeout_id);
-      window->sync_request_timeout_id = 0;
+      g_source_remove (priv->sync_request_timeout_id);
+      priv->sync_request_timeout_id = 0;
 
       /* This means we are ready for another configure;
        * no pointer round trip here, to keep in sync */
@@ -3625,7 +3648,7 @@ meta_window_x11_update_sync_request_counter (MetaWindow *window,
    * the application has come to its senses (maybe it was just
    * busy with a pagefault or a long computation).
    */
-  window->disable_sync = FALSE;
+  priv->disable_sync = FALSE;
 
   if (needs_frame_drawn)
     meta_compositor_queue_frame_drawn (window->display->compositor, window,
@@ -3637,3 +3660,86 @@ meta_window_x11_get_toplevel_xwindow (MetaWindow *window)
 {
   return window->frame ? window->frame->xwindow : window->xwindow;
 }
+
+int64_t
+meta_window_x11_get_sync_request_serial (MetaWindowX11 *window_x11)
+{
+  MetaWindowX11Private *priv =
+    meta_window_x11_get_instance_private (window_x11);
+
+  g_return_val_if_fail (META_IS_WINDOW_X11 (window_x11), -1);
+
+  return priv->sync_request_serial;
+}
+
+gboolean
+meta_window_x11_has_sync_request_alarm (MetaWindowX11 *window_x11)
+{
+  MetaWindowX11Private *priv =
+    meta_window_x11_get_instance_private (window_x11);
+
+  g_return_val_if_fail (META_IS_WINDOW_X11 (window_x11), FALSE);
+
+  return !priv->disable_sync &&
+          priv->sync_request_alarm != None;
+}
+
+gboolean
+meta_window_x11_is_sync_request_scheduled (MetaWindowX11 *window_x11)
+{
+  MetaWindowX11Private *priv =
+    meta_window_x11_get_instance_private (window_x11);
+
+  g_return_val_if_fail (META_IS_WINDOW_X11 (window_x11), FALSE);
+
+  return priv->sync_request_timeout_id != 0;
+}
+
+gboolean
+meta_window_x11_has_extended_sync_request_counter (MetaWindowX11 *window_x11)
+{
+  MetaWindowX11Private *priv =
+    meta_window_x11_get_instance_private (window_x11);
+
+  g_return_val_if_fail (META_IS_WINDOW_X11 (window_x11), FALSE);
+
+  return priv->extended_sync_request_counter;
+}
+
+void
+meta_window_x11_setup_sync_request_counter (MetaWindowX11 *window_x11,
+                                            MetaPropValue *value)
+{
+  MetaWindowX11Private *priv =
+    meta_window_x11_get_instance_private (window_x11);
+  MetaWindow *window = META_WINDOW (window_x11);
+
+  if (value->type == META_PROP_VALUE_INVALID)
+    return;
+
+  meta_window_x11_destroy_sync_request_alarm (window);
+  priv->sync_request_counter = None;
+
+  if (value->v.xcounter_list.n_counters == 0)
+    {
+      meta_warning ("_NET_WM_SYNC_REQUEST_COUNTER is empty\n");
+      return;
+    }
+
+  if (value->v.xcounter_list.n_counters == 1)
+    {
+      priv->sync_request_counter = value->v.xcounter_list.counters[0];
+      priv->extended_sync_request_counter = FALSE;
+    }
+  else
+    {
+      priv->sync_request_counter = value->v.xcounter_list.counters[1];
+      priv->extended_sync_request_counter = TRUE;
+    }
+  meta_verbose ("Window has _NET_WM_SYNC_REQUEST_COUNTER 0x%lx (extended=%s)\n",
+                priv->sync_request_counter,
+                priv->extended_sync_request_counter ? "true" : "false");
+
+  if (priv->extended_sync_request_counter)
+    meta_window_x11_create_sync_request_alarm (window);
+}
diff --git a/src/x11/window-x11.h b/src/x11/window-x11.h
index 383a52129..5c21145a3 100644
--- a/src/x11/window-x11.h
+++ b/src/x11/window-x11.h
@@ -75,4 +75,10 @@ void     meta_window_x11_configure_notify        (MetaWindow      *window,
 
 Window   meta_window_x11_get_toplevel_xwindow    (MetaWindow *window);
 
+int64_t  meta_window_x11_get_sync_request_serial   (MetaWindowX11 *window_x11);
+gboolean meta_window_x11_is_sync_request_scheduled (MetaWindowX11 *window_x11);
+gboolean meta_window_x11_has_sync_request_alarm    (MetaWindowX11 *window_x11);
+
+gboolean meta_window_x11_has_extended_sync_request_counter (MetaWindowX11 *window_x11);
+
 #endif


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