diff options
author | Daniel van Vugt <daniel.van.vugt@canonical.com> | 2019-08-02 19:30:31 +0800 |
---|---|---|
committer | Marco Trevisan <mail@3v1n0.net> | 2019-08-20 23:52:49 +0000 |
commit | 5c617ac2864a7e040dd3646fbef9f5cd9c5fb788 (patch) | |
tree | 96d3478cc8d9d4f2f13f77a44c903c962ba96b2c | |
parent | bc08ad2fbbc127762b275c1db72ddd36b1fee8b4 (diff) | |
download | mutter-5c617ac2864a7e040dd3646fbef9f5cd9c5fb788.tar.gz |
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
-rw-r--r-- | clutter/clutter/clutter-stage.c | 31 |
1 files 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 |