diff --git a/clutter/clutter/clutter-backend-private.h b/clutter/clutter/clutter-backend-private.h index d7d998801..3a0619ee3 100644 --- a/clutter/clutter/clutter-backend-private.h +++ b/clutter/clutter/clutter-backend-private.h @@ -38,6 +38,8 @@ struct _ClutterBackend /*< private >*/ GObject parent_instance; + ClutterContext *context; + CoglRenderer *cogl_renderer; CoglDisplay *cogl_display; CoglContext *cogl_context; diff --git a/clutter/clutter/clutter-backend.c b/clutter/clutter/clutter-backend.c index bd190f070..954984f91 100644 --- a/clutter/clutter/clutter-backend.c +++ b/clutter/clutter/clutter-backend.c @@ -61,6 +61,15 @@ enum LAST_SIGNAL }; +enum +{ + PROP_0, + PROP_CONTEXT, + N_PROPS +}; + +static GParamSpec *pspecs[N_PROPS] = { 0 }; + G_DEFINE_ABSTRACT_TYPE (ClutterBackend, clutter_backend, G_TYPE_OBJECT) static guint backend_signals[LAST_SIGNAL] = { 0, }; @@ -89,6 +98,44 @@ clutter_backend_dispose (GObject *gobject) G_OBJECT_CLASS (clutter_backend_parent_class)->dispose (gobject); } +static void +clutter_backend_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + ClutterBackend *backend = CLUTTER_BACKEND (object); + + switch (prop_id) + { + case PROP_CONTEXT: + g_value_set_object (value, backend->context); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +clutter_backend_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + ClutterBackend *backend = CLUTTER_BACKEND (object); + + switch (prop_id) + { + case PROP_CONTEXT: + backend->context = g_value_get_object (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + static void clutter_backend_real_resolution_changed (ClutterBackend *backend) { @@ -238,6 +285,8 @@ clutter_backend_class_init (ClutterBackendClass *klass) GObjectClass *gobject_class = G_OBJECT_CLASS (klass); gobject_class->dispose = clutter_backend_dispose; + gobject_class->get_property = clutter_backend_get_property; + gobject_class->set_property = clutter_backend_set_property; /** * ClutterBackend::resolution-changed: @@ -284,6 +333,15 @@ clutter_backend_class_init (ClutterBackendClass *klass) NULL, NULL, NULL, G_TYPE_NONE, 0); + pspecs[PROP_CONTEXT] = + g_param_spec_object ("context", NULL, NULL, + CLUTTER_TYPE_CONTEXT, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS | + G_PARAM_CONSTRUCT_ONLY); + + g_object_class_install_properties (gobject_class, N_PROPS, pspecs); + klass->resolution_changed = clutter_backend_real_resolution_changed; klass->create_context = clutter_backend_real_create_context; diff --git a/clutter/clutter/clutter-context.c b/clutter/clutter/clutter-context.c index 176c9d0f1..f94f17ac9 100644 --- a/clutter/clutter/clutter-context.c +++ b/clutter/clutter/clutter-context.c @@ -267,7 +267,7 @@ clutter_context_new (ClutterBackendConstructor backend_constructor, init_clutter_debug (context); context->show_fps = clutter_show_fps; - context->backend = backend_constructor (user_data); + context->backend = backend_constructor (context, user_data); context->settings = clutter_settings_get_default (); _clutter_settings_set_backend (context->settings, context->backend); diff --git a/clutter/clutter/clutter-context.h b/clutter/clutter/clutter-context.h index c211a56e9..9cc86fe6a 100644 --- a/clutter/clutter/clutter-context.h +++ b/clutter/clutter/clutter-context.h @@ -24,7 +24,8 @@ #include "cogl-pango/cogl-pango.h" -typedef ClutterBackend * (* ClutterBackendConstructor) (gpointer user_data); +typedef ClutterBackend * (* ClutterBackendConstructor) (ClutterContext *context, + gpointer user_data); #define CLUTTER_TYPE_CONTEXT (clutter_context_get_type ()) CLUTTER_EXPORT diff --git a/src/backends/meta-backend-private.h b/src/backends/meta-backend-private.h index 1ffc04c88..a39c6207e 100644 --- a/src/backends/meta-backend-private.h +++ b/src/backends/meta-backend-private.h @@ -55,7 +55,8 @@ struct _MetaBackendClass { GObjectClass parent_class; - ClutterBackend * (* create_clutter_backend) (MetaBackend *backend); + ClutterBackend * (* create_clutter_backend) (MetaBackend *backend, + ClutterContext *context); void (* post_init) (MetaBackend *backend); diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c index 29f2712b3..099be6645 100644 --- a/src/backends/meta-backend.c +++ b/src/backends/meta-backend.c @@ -1201,11 +1201,13 @@ static GSourceFuncs clutter_source_funcs = { }; static ClutterBackend * -meta_clutter_backend_constructor (gpointer user_data) +meta_clutter_backend_constructor (ClutterContext *context, + gpointer user_data) { MetaBackend *backend = META_BACKEND (user_data); - return META_BACKEND_GET_CLASS (backend)->create_clutter_backend (backend); + return META_BACKEND_GET_CLASS (backend)->create_clutter_backend (backend, + context); } static ClutterSeat * diff --git a/src/backends/native/meta-backend-native.c b/src/backends/native/meta-backend-native.c index dee6f7bbc..63b7b5a8e 100644 --- a/src/backends/native/meta-backend-native.c +++ b/src/backends/native/meta-backend-native.c @@ -124,9 +124,10 @@ meta_backend_native_dispose (GObject *object) } static ClutterBackend * -meta_backend_native_create_clutter_backend (MetaBackend *backend) +meta_backend_native_create_clutter_backend (MetaBackend *backend, + ClutterContext *context) { - return CLUTTER_BACKEND (meta_clutter_backend_native_new (backend)); + return CLUTTER_BACKEND (meta_clutter_backend_native_new (backend, context)); } static ClutterSeat * diff --git a/src/backends/native/meta-clutter-backend-native.c b/src/backends/native/meta-clutter-backend-native.c index a644de95b..982e95a27 100644 --- a/src/backends/native/meta-clutter-backend-native.c +++ b/src/backends/native/meta-clutter-backend-native.c @@ -118,11 +118,13 @@ meta_clutter_backend_native_class_init (MetaClutterBackendNativeClass *klass) } MetaClutterBackendNative * -meta_clutter_backend_native_new (MetaBackend *backend) +meta_clutter_backend_native_new (MetaBackend *backend, + ClutterContext *context) { MetaClutterBackendNative *clutter_backend_native; clutter_backend_native = g_object_new (META_TYPE_CLUTTER_BACKEND_NATIVE, + "context", context, NULL); clutter_backend_native->backend = backend; diff --git a/src/backends/native/meta-clutter-backend-native.h b/src/backends/native/meta-clutter-backend-native.h index 1ff74c855..3e4f23a25 100644 --- a/src/backends/native/meta-clutter-backend-native.h +++ b/src/backends/native/meta-clutter-backend-native.h @@ -33,4 +33,5 @@ G_DECLARE_FINAL_TYPE (MetaClutterBackendNative, meta_clutter_backend_native, META, CLUTTER_BACKEND_NATIVE, ClutterBackend) -MetaClutterBackendNative * meta_clutter_backend_native_new (MetaBackend *backend); +MetaClutterBackendNative * meta_clutter_backend_native_new (MetaBackend *backend, + ClutterContext *context); diff --git a/src/backends/x11/meta-backend-x11.c b/src/backends/x11/meta-backend-x11.c index 86aa63810..593ccb613 100644 --- a/src/backends/x11/meta-backend-x11.c +++ b/src/backends/x11/meta-backend-x11.c @@ -609,9 +609,10 @@ meta_backend_x11_post_init (MetaBackend *backend) } static ClutterBackend * -meta_backend_x11_create_clutter_backend (MetaBackend *backend) +meta_backend_x11_create_clutter_backend (MetaBackend *backend, + ClutterContext *context) { - return CLUTTER_BACKEND (meta_clutter_backend_x11_new (backend)); + return CLUTTER_BACKEND (meta_clutter_backend_x11_new (backend, context)); } static MetaColorManager * diff --git a/src/backends/x11/meta-clutter-backend-x11.c b/src/backends/x11/meta-clutter-backend-x11.c index 32ae722dd..626486c71 100644 --- a/src/backends/x11/meta-clutter-backend-x11.c +++ b/src/backends/x11/meta-clutter-backend-x11.c @@ -137,14 +137,17 @@ meta_clutter_backend_x11_class_init (MetaClutterBackendX11Class *klass) } MetaClutterBackendX11 * -meta_clutter_backend_x11_new (MetaBackend *backend) +meta_clutter_backend_x11_new (MetaBackend *backend, + ClutterContext *context) { MetaBackendX11 *backend_x11 = META_BACKEND_X11 (backend); Atom atoms[N_ATOM_NAMES]; MetaClutterBackendX11 *clutter_backend_x11; MetaClutterBackendX11Private *priv; - clutter_backend_x11 = g_object_new (META_TYPE_CLUTTER_BACKEND_X11, NULL); + clutter_backend_x11 = g_object_new (META_TYPE_CLUTTER_BACKEND_X11, + "context", context, + NULL); priv = meta_clutter_backend_x11_get_instance_private (clutter_backend_x11); priv->backend = backend; diff --git a/src/backends/x11/meta-clutter-backend-x11.h b/src/backends/x11/meta-clutter-backend-x11.h index 38e65fc93..982372cd2 100644 --- a/src/backends/x11/meta-clutter-backend-x11.h +++ b/src/backends/x11/meta-clutter-backend-x11.h @@ -56,4 +56,5 @@ G_DECLARE_FINAL_TYPE (MetaClutterBackendX11, meta_clutter_backend_x11, META, CLUTTER_BACKEND_X11, ClutterBackend) -MetaClutterBackendX11 * meta_clutter_backend_x11_new (MetaBackend *backend); +MetaClutterBackendX11 * meta_clutter_backend_x11_new (MetaBackend *backend, + ClutterContext *context);