From 9c038ebefb88cd052c1dc9448c58d2d5a9a9bfc7 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 4 Nov 2011 18:50:46 +0000 Subject: [PATCH] stage-window: Add :backend and :wrapper properties MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All StageWindow implementation already have back pointers, but we need a unified API to actually set them from the generic code path; we can use properties on the StageWindow interface — though this requires fixing all backends at the same time, to avoid GObject complaining. --- clutter/clutter-stage-window.c | 19 ++++++++++ clutter/cogl/clutter-stage-cogl.c | 15 ++------ clutter/osx/clutter-stage-osx.c | 46 ++++++++++++++++++++++--- clutter/wayland/clutter-stage-wayland.c | 37 ++++++++++++++++++++ clutter/win32/clutter-stage-win32.c | 35 +++++++++++++++++++ 5 files changed, 135 insertions(+), 17 deletions(-) diff --git a/clutter/clutter-stage-window.c b/clutter/clutter-stage-window.c index 7ca171ee4..1b35103c7 100644 --- a/clutter/clutter-stage-window.c +++ b/clutter/clutter-stage-window.c @@ -15,6 +15,25 @@ G_DEFINE_INTERFACE (ClutterStageWindow, clutter_stage_window, G_TYPE_OBJECT); static void clutter_stage_window_default_init (ClutterStageWindowInterface *iface) { + GParamSpec *pspec; + + pspec = g_param_spec_object ("backend", + "Backend", + "Back pointer to the Backend instance", + CLUTTER_TYPE_BACKEND, + G_PARAM_WRITABLE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + g_object_interface_install_property (iface, pspec); + + pspec = g_param_spec_object ("wrapper", + "Wrapper", + "Back pointer to the Stage actor", + CLUTTER_TYPE_STAGE, + G_PARAM_WRITABLE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + g_object_interface_install_property (iface, pspec); } ClutterActor * diff --git a/clutter/cogl/clutter-stage-cogl.c b/clutter/cogl/clutter-stage-cogl.c index 98af26972..87b6035be 100644 --- a/clutter/cogl/clutter-stage-cogl.c +++ b/clutter/cogl/clutter-stage-cogl.c @@ -565,19 +565,8 @@ _clutter_stage_cogl_class_init (ClutterStageCoglClass *klass) gobject_class->set_property = clutter_stage_cogl_set_property; - g_object_class_install_property (gobject_class, PROP_WRAPPER, - g_param_spec_object ("wrapper", - "Wrapper", - "ClutterStage wrapping this native stage", - CLUTTER_TYPE_STAGE, - CLUTTER_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property (gobject_class, PROP_BACKEND, - g_param_spec_object ("backend", - "ClutterBackend", - "The Clutter backend singleton", - CLUTTER_TYPE_BACKEND, - CLUTTER_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); + g_object_class_override_property (gobject_class, PROP_WRAPPER, "wrapper"); + g_object_class_override_property (gobject_class, PROP_BACKEND, "backend"); } static void diff --git a/clutter/osx/clutter-stage-osx.c b/clutter/osx/clutter-stage-osx.c index f19dbfcb8..8c56e3d1e 100644 --- a/clutter/osx/clutter-stage-osx.c +++ b/clutter/osx/clutter-stage-osx.c @@ -32,6 +32,14 @@ #import +enum +{ + PROP_0, + + PROP_BACKEND, + PROP_WRAPPER +}; + static void clutter_stage_window_iface_init (ClutterStageWindowIface *iface); #define clutter_stage_osx_get_type _clutter_stage_osx_get_type @@ -608,15 +616,17 @@ _clutter_stage_osx_new (ClutterBackend *backend, { ClutterStageOSX *self; - self = g_object_new (CLUTTER_TYPE_STAGE_OSX, NULL); - self->backend = backend; - self->wrapper = wrapper; + self = g_object_new (CLUTTER_TYPE_STAGE_OSX, + "backend", backend, + "wrapper", wrapper, + NULL); + self->isHiding = false; self->haveRealized = false; self->view = NULL; self->window = NULL; - return CLUTTER_STAGE_WINDOW(self); + return CLUTTER_STAGE_WINDOW (self); } /*************************************************************************/ @@ -628,6 +638,30 @@ clutter_stage_osx_init (ClutterStageOSX *self) self->acceptFocus = TRUE; } +static void +clutter_stage_osx_set_property (GObject *gobject, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + ClutterStageOSX *self = CLUTTER_STAGE_OSX (gobject); + + switch (prop_id) + { + case PROP_BACKEND: + self->backend = g_value_get_object (value); + break; + + case PROP_WRAPPER: + self->wrapper = g_value_get_object (value); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); + break; + } +} + static void clutter_stage_osx_finalize (GObject *gobject) { @@ -645,6 +679,10 @@ clutter_stage_osx_class_init (ClutterStageOSXClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + gobject_class->set_property = clutter_stage_osx_set_property; gobject_class->finalize = clutter_stage_osx_finalize; gobject_class->dispose = clutter_stage_osx_dispose; + + g_object_class_override_property (gobject_class, PROP_BACKEND, "backend"); + g_object_class_override_property (gobject_class, PROP_WRAPPER, "wrapper"); } diff --git a/clutter/wayland/clutter-stage-wayland.c b/clutter/wayland/clutter-stage-wayland.c index 427685155..022745ab9 100644 --- a/clutter/wayland/clutter-stage-wayland.c +++ b/clutter/wayland/clutter-stage-wayland.c @@ -58,6 +58,14 @@ wayland_swap_buffers (ClutterStageWayland *stage_wayland); static void clutter_stage_window_iface_init (ClutterStageWindowIface *iface); +enum +{ + PROP_0, + + PROP_BACKEND, + PROP_WRAPPER +}; + G_DEFINE_TYPE_WITH_CODE (ClutterStageWayland, _clutter_stage_wayland, G_TYPE_OBJECT, @@ -427,9 +435,38 @@ clutter_stage_window_iface_init (ClutterStageWindowIface *iface) iface->ignoring_redraw_clips = clutter_stage_wayland_ignoring_redraw_clips; } +static void +clutter_stage_wayland_set_property (GObject *gobject, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + ClutterStageWayland *self = CLUTTER_STAGE_WAYLAND (gobject); + + switch (prop_id) + { + case PROP_BACKEND: + self->backend = g_value_get_object (value); + break; + + case PROP_WRAPPER: + self->wrapper = g_value_get_object (value); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); + } +} + static void _clutter_stage_wayland_class_init (ClutterStageWaylandClass *klass) { + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + + gobject_class->set_property = clutter_stage_wayland_set_property; + + g_object_class_override_property (gobject_class, PROP_BACKEND, "backend"); + g_object_class_override_property (gobject_class, PROP_WRAPPER, "wrapper"); } static void diff --git a/clutter/win32/clutter-stage-win32.c b/clutter/win32/clutter-stage-win32.c index f57f73be6..e89c81769 100644 --- a/clutter/win32/clutter-stage-win32.c +++ b/clutter/win32/clutter-stage-win32.c @@ -42,6 +42,14 @@ static void clutter_stage_window_iface_init (ClutterStageWindowIface *iface); +enum +{ + PROP_0, + + PROP_BACKEND, + PROP_WRAPPER +}; + G_DEFINE_TYPE_WITH_CODE (ClutterStageWin32, clutter_stage_win32, G_TYPE_OBJECT, @@ -544,6 +552,29 @@ clutter_stage_win32_get_active_framebuffer (ClutterStageWindow *stage_window) return COGL_FRAMEBUFFER (stage_win32->onscreen); } +static void +clutter_stage_win32_set_property (GObject *gobject, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + ClutterStageWin32 *self = CLUTTER_STAGE_WIN32 (gobject); + + switch (prop_id) + { + case PROP_BACKEND: + self->backend = g_value_get_object (value); + break; + + case PROP_WRAPPER: + self->wrapper = g_value_get_object (value); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); + } +} + static void clutter_stage_win32_dispose (GObject *gobject) { @@ -569,7 +600,11 @@ clutter_stage_win32_class_init (ClutterStageWin32Class *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + gobject_class->set_property = clutter_stage_win32_set_property; gobject_class->dispose = clutter_stage_win32_dispose; + + g_object_class_override_property (gobject_class, PROP_BACKEND, "backend"); + g_object_class_override_property (gobject_class, PROP_WRAPPER, "wrapper"); } static void