[mutter] clutter/stage: Only queue compressible events



commit 5c617ac2864a7e040dd3646fbef9f5cd9c5fb788
Author: Daniel van Vugt <daniel van vugt canonical com>
Date:   Fri Aug 2 19:30:31 2019 +0800

    clutter/stage: Only queue compressible events
    
    Incompressible events already pass through unmodified, so queuing them
    just wasted time and memory.
    
    We would however like to keep the ordering of events so we can only
    apply this optimization if the queue is empty.
    
    This reduces the input latency of incompressible events like touchpad
    scrolling or drawing tablets by up to one frame. It also means the same
    series of events now arrives at the client more smoothly and not in
    bursts.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/711

 clutter/clutter/clutter-stage.c | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)
---
diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c
index 107da475d..eece2450b 100644
--- a/clutter/clutter/clutter-stage.c
+++ b/clutter/clutter/clutter-stage.c
@@ -875,15 +875,6 @@ _clutter_stage_queue_event (ClutterStage *stage,
   if (copy_event)
     event = clutter_event_copy (event);
 
-  g_queue_push_tail (priv->event_queue, event);
-
-  if (first_event)
-    {
-      ClutterMasterClock *master_clock = _clutter_master_clock_get_default ();
-      _clutter_master_clock_start_running (master_clock);
-      _clutter_stage_schedule_update (stage);
-    }
-
   /* if needed, update the state of the input device of the event.
    * we do it here to avoid calling the same code from every backend
    * event processing function
@@ -904,6 +895,28 @@ _clutter_stage_queue_event (ClutterStage *stage,
       _clutter_input_device_set_state (device, event_state);
       _clutter_input_device_set_time (device, event_time);
     }
+
+  if (first_event)
+    {
+      gboolean compressible = event->type == CLUTTER_MOTION ||
+                              event->type == CLUTTER_TOUCH_UPDATE;
+
+      if (!compressible)
+        {
+          _clutter_process_event (event);
+          clutter_event_free (event);
+          return;
+        }
+    }
+
+  g_queue_push_tail (priv->event_queue, event);
+
+  if (first_event)
+    {
+      ClutterMasterClock *master_clock = _clutter_master_clock_get_default ();
+      _clutter_master_clock_start_running (master_clock);
+      _clutter_stage_schedule_update (stage);
+    }
 }
 
 gboolean


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