[metacity] stack-tracker: avoid queueing resync for obvious no-ops



commit 1bee4c9d146208da8bc96634438dc2e4edd77938
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Sat Nov 13 14:07:07 2010 -0500

    stack-tracker: avoid queueing resync for obvious no-ops
    
    Since we can't distinguish a ConfigureEvent that indicates a raise
    from a ConfigureEvent that indicates a move, we get lots of
    STACK_OP_RAISE_ABOVE events for windows that are already in the
    right place in the stacking order. Avoid queueing a restack in that
    case.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=634771

 src/core/stack-tracker.c |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)
---
diff --git a/src/core/stack-tracker.c b/src/core/stack-tracker.c
index c6814be..28f786b 100644
--- a/src/core/stack-tracker.c
+++ b/src/core/stack-tracker.c
@@ -51,8 +51,8 @@
  *
  * When we receive a new event: a) we compare the serial in the event to
  * the serial of the queued requests and remove any that are now
- * no longer pending b) drop the predicted stacking order to recompute
- * it at the next opportunity.
+ * no longer pending b) if necessary, drop the predicted stacking
+ * order to recompute it at the next opportunity.
  *
  * Possible optimizations:
  *  Keep the stacks as an array + reverse-mapping hash table to avoid
@@ -510,6 +510,8 @@ static void
 stack_tracker_event_received (MetaStackTracker *tracker,
                               MetaStackOp      *op)
 {
+  gboolean need_sync = FALSE;
+
   meta_stack_op_dump (op, "Stack op event received: ", "\n");
 
   if (op->any.serial < tracker->server_serial)
@@ -517,7 +519,8 @@ stack_tracker_event_received (MetaStackTracker *tracker,
 
   tracker->server_serial = op->any.serial;
 
-  meta_stack_op_apply (op, tracker->server_stack);
+  if (meta_stack_op_apply (op, tracker->server_stack))
+    need_sync = TRUE;
 
   while (tracker->queued_requests->head)
     {
@@ -527,17 +530,21 @@ stack_tracker_event_received (MetaStackTracker *tracker,
 
       g_queue_pop_head (tracker->queued_requests);
       meta_stack_op_free (queued_op);
+      need_sync = TRUE;
     }
 
-  if (tracker->predicted_stack)
+  if (need_sync)
     {
-      g_array_free (tracker->predicted_stack, TRUE);
-      tracker->predicted_stack = NULL;
+      if (tracker->predicted_stack)
+        {
+          g_array_free (tracker->predicted_stack, TRUE);
+          tracker->predicted_stack = NULL;
+        }
+
+      meta_stack_tracker_queue_sync_stack (tracker);
     }
 
   meta_stack_tracker_dump (tracker);
-
-  meta_stack_tracker_queue_sync_stack (tracker);
 }
 
 void


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