[mutter/wip/carlosg/move-pointer-onscreen: 7/8] tests/utils: Add meta_wait_for_paint() helper




commit 055f915d08d7fb5762063ec128632f10f3ccebec
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Fri Jan 14 22:12:36 2022 +0100

    tests/utils: Add meta_wait_for_paint() helper
    
    This function queues a full stage redraw, then waits for every view to
    receive the "presented" signal before returning.

 src/tests/meta-test-utils.c | 25 +++++++++++++++++++++++++
 src/tests/meta-test-utils.h |  3 +++
 2 files changed, 28 insertions(+)
---
diff --git a/src/tests/meta-test-utils.c b/src/tests/meta-test-utils.c
index 9701ce2500..bfda457a56 100644
--- a/src/tests/meta-test-utils.c
+++ b/src/tests/meta-test-utils.c
@@ -614,3 +614,28 @@ meta_set_custom_monitor_config (MetaBackend *backend,
                                              &error))
     g_error ("Failed to set custom config: %s", error->message);
 }
+
+static void
+on_view_presented (ClutterStage      *stage,
+                   ClutterStageView  *view,
+                   ClutterFrameInfo  *frame_info,
+                   GList            **presented_views)
+{
+  *presented_views = g_list_remove (*presented_views, view);
+}
+
+void
+meta_wait_for_paint (MetaContext *context)
+{
+  MetaBackend *backend = meta_context_get_backend (context);
+  ClutterActor *stage = meta_backend_get_stage (backend);
+  MetaRenderer *renderer = meta_backend_get_renderer (backend);
+  GList *views;
+
+  clutter_actor_queue_redraw (stage);
+
+  views = g_list_copy (meta_renderer_get_views (renderer));
+  g_signal_connect (stage, "presented", G_CALLBACK (on_view_presented), &views);
+  while (views)
+    g_main_context_iteration (NULL, TRUE);
+}
diff --git a/src/tests/meta-test-utils.h b/src/tests/meta-test-utils.h
index cf9df9d41b..685d4febe0 100644
--- a/src/tests/meta-test-utils.h
+++ b/src/tests/meta-test-utils.h
@@ -112,4 +112,7 @@ META_EXPORT
 void meta_set_custom_monitor_config (MetaBackend *backend,
                                      const char  *filename);
 
+META_EXPORT
+void meta_wait_for_paint (MetaContext *context);
+
 #endif /* TEST_UTILS_H */


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