From 3dfe3a248db5ae9e27e850682cfe203fd0b9e3d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Sun, 16 Aug 2020 21:35:16 +0200 Subject: [PATCH] stage-view/cogl: Add frame listener in constructor() The onscreens are set on construction now, so no need to wait for it to be set after. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1407 --- clutter/clutter/cogl/clutter-stage-cogl.c | 39 ++++++++++++----------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/clutter/clutter/cogl/clutter-stage-cogl.c b/clutter/clutter/cogl/clutter-stage-cogl.c index 4b07a4057..b53a6c16a 100644 --- a/clutter/clutter/cogl/clutter-stage-cogl.c +++ b/clutter/clutter/cogl/clutter-stage-cogl.c @@ -756,22 +756,6 @@ frame_cb (CoglOnscreen *onscreen, clutter_stage_view_notify_presented (view, &clutter_frame_info); } -static void -on_framebuffer_set (ClutterStageView *view) -{ - CoglFramebuffer *framebuffer; - - framebuffer = clutter_stage_view_get_onscreen (view); - - if (framebuffer && cogl_is_onscreen (framebuffer)) - { - cogl_onscreen_add_frame_callback (COGL_ONSCREEN (framebuffer), - frame_cb, - view, - NULL); - } -} - static void clutter_stage_view_cogl_dispose (GObject *object) { @@ -785,6 +769,25 @@ clutter_stage_view_cogl_dispose (GObject *object) G_OBJECT_CLASS (clutter_stage_view_cogl_parent_class)->dispose (object); } +static void +clutter_stage_view_cogl_constructed (GObject *object) +{ + ClutterStageView *view = CLUTTER_STAGE_VIEW (view_cogl); + CoglFramebuffer *framebuffer; + + framebuffer = clutter_stage_view_get_onscreen (view); + + if (framebuffer && cogl_is_onscreen (framebuffer)) + { + cogl_onscreen_add_frame_callback (COGL_ONSCREEN (framebuffer), + frame_cb, + view, + NULL); + } + + G_OBJECT_CLASS (clutter_stage_view_cogl_parent_class)->constructed (object); +} + static void clutter_stage_view_cogl_init (ClutterStageViewCogl *view_cogl) { @@ -792,9 +795,6 @@ clutter_stage_view_cogl_init (ClutterStageViewCogl *view_cogl) clutter_stage_view_cogl_get_instance_private (view_cogl); view_priv->damage_history = clutter_damage_history_new (); - - g_signal_connect (view_cogl, "notify::framebuffer", - G_CALLBACK (on_framebuffer_set), NULL); } static void @@ -802,5 +802,6 @@ clutter_stage_view_cogl_class_init (ClutterStageViewCoglClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); + object_class->constructed = clutter_stage_view_cogl_constructed; object_class->dispose = clutter_stage_view_cogl_dispose; }