From 1fbdfa8ca7111267dce37e85cd621924ab30faa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 16 Sep 2021 11:31:34 +0200 Subject: [PATCH] clutter/backend/native: Keep a pointer to the actual backend This eliminates going via a global variable. Part-of: --- src/backends/native/meta-backend-native.c | 2 +- .../native/meta-clutter-backend-native.c | 22 +++++++++++++++++-- .../native/meta-clutter-backend-native.h | 3 +++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/backends/native/meta-backend-native.c b/src/backends/native/meta-backend-native.c index 2cc9add75..99b11a69d 100644 --- a/src/backends/native/meta-backend-native.c +++ b/src/backends/native/meta-backend-native.c @@ -117,7 +117,7 @@ meta_backend_native_dispose (GObject *object) static ClutterBackend * meta_backend_native_create_clutter_backend (MetaBackend *backend) { - return g_object_new (META_TYPE_CLUTTER_BACKEND_NATIVE, NULL); + return CLUTTER_BACKEND (meta_clutter_backend_native_new (backend)); } static ClutterSeat * diff --git a/src/backends/native/meta-clutter-backend-native.c b/src/backends/native/meta-clutter-backend-native.c index a28ecea99..87963e78e 100644 --- a/src/backends/native/meta-clutter-backend-native.c +++ b/src/backends/native/meta-clutter-backend-native.c @@ -54,6 +54,8 @@ struct _MetaClutterBackendNative { ClutterBackend parent; + + MetaBackend *backend; }; G_DEFINE_TYPE (MetaClutterBackendNative, meta_clutter_backend_native, @@ -63,7 +65,9 @@ static CoglRenderer * meta_clutter_backend_native_get_renderer (ClutterBackend *clutter_backend, GError **error) { - MetaBackend *backend = meta_get_backend (); + MetaClutterBackendNative *clutter_backend_nativen = + META_CLUTTER_BACKEND_NATIVE (clutter_backend); + MetaBackend *backend = clutter_backend_nativen->backend; MetaRenderer *renderer = meta_backend_get_renderer (backend); return meta_renderer_create_cogl_renderer (renderer); @@ -83,7 +87,9 @@ meta_clutter_backend_native_create_stage (ClutterBackend *clutter_backend, static ClutterSeat * meta_clutter_backend_native_get_default_seat (ClutterBackend *clutter_backend) { - MetaBackend *backend = meta_get_backend (); + MetaClutterBackendNative *clutter_backend_nativen = + META_CLUTTER_BACKEND_NATIVE (clutter_backend); + MetaBackend *backend = clutter_backend_nativen->backend; return meta_backend_get_default_seat (backend); } @@ -109,3 +115,15 @@ meta_clutter_backend_native_class_init (MetaClutterBackendNativeClass *klass) clutter_backend_class->get_default_seat = meta_clutter_backend_native_get_default_seat; clutter_backend_class->is_display_server = meta_clutter_backend_native_is_display_server; } + +MetaClutterBackendNative * +meta_clutter_backend_native_new (MetaBackend *backend) +{ + MetaClutterBackendNative *clutter_backend_native; + + clutter_backend_native = g_object_new (META_TYPE_CLUTTER_BACKEND_NATIVE, + NULL); + clutter_backend_native->backend = backend; + + return clutter_backend_native; +} diff --git a/src/backends/native/meta-clutter-backend-native.h b/src/backends/native/meta-clutter-backend-native.h index dea35988c..432c72083 100644 --- a/src/backends/native/meta-clutter-backend-native.h +++ b/src/backends/native/meta-clutter-backend-native.h @@ -27,6 +27,7 @@ #include +#include "backends/meta-backend-types.h" #include "backends/native/meta-stage-native.h" #include "clutter/clutter.h" @@ -35,4 +36,6 @@ G_DECLARE_FINAL_TYPE (MetaClutterBackendNative, meta_clutter_backend_native, META, CLUTTER_BACKEND_NATIVE, ClutterBackend) +MetaClutterBackendNative * meta_clutter_backend_native_new (MetaBackend *backend); + #endif /* META_CLUTTER_BACKEND_NATIVE_H */