[mutter] clutter/backend/native: Keep a pointer to the actual backend



commit 1fbdfa8ca7111267dce37e85cd621924ab30faa3
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Thu Sep 16 11:31:34 2021 +0200

    clutter/backend/native: Keep a pointer to the actual backend
    
    This eliminates going via a global variable.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>

 src/backends/native/meta-backend-native.c         |  2 +-
 src/backends/native/meta-clutter-backend-native.c | 22 ++++++++++++++++++++--
 src/backends/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 2cc9add75d..99b11a69d8 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 a28ecea995..87963e78e6 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 dea35988c0..432c72083e 100644
--- a/src/backends/native/meta-clutter-backend-native.h
+++ b/src/backends/native/meta-clutter-backend-native.h
@@ -27,6 +27,7 @@
 
 #include <glib-object.h>
 
+#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 */


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