From d0f1186e1d06e08078b2adcdaf827a2b002474d4 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 23 Mar 2007 17:55:13 +0000 Subject: [PATCH] 2007-03-23 Emmanuele Bassi * clutter/clutter-private.h: * clutter/clutter-backend.h: Move the backend functions into the private header. * clutter/glx/clutter-stage-glx.c: * clutter/glx/clutter-event-glx.c: * clutter/clutter-main.c: * clutter/clutter-stage.c: Update the calls to the private backend functions. * clutter/clutter-backend.[ch]: Add an ::init_features vfunc to ClutterBackend. --- ChangeLog | 15 ++++++ clutter/clutter-backend.c | 81 +++++++++++++++++++++++++++++---- clutter/clutter-backend.h | 44 ++++++++---------- clutter/clutter-main.c | 12 ++--- clutter/clutter-private.h | 13 ++++++ clutter/clutter-stage.c | 2 +- clutter/glx/clutter-event-glx.c | 2 +- clutter/glx/clutter-stage-glx.c | 4 +- 8 files changed, 128 insertions(+), 45 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0623c33a7..a86bf8d7e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2007-03-23 Emmanuele Bassi + + * clutter/clutter-private.h: + * clutter/clutter-backend.h: Move the backend functions + into the private header. + + * clutter/glx/clutter-stage-glx.c: + * clutter/glx/clutter-event-glx.c: + * clutter/clutter-main.c: + * clutter/clutter-stage.c: Update the calls to the private + backend functions. + + * clutter/clutter-backend.[ch]: Add an ::init_features + vfunc to ClutterBackend. + 2007-03-23 Emmanuele Bassi * clutter/glx/clutter-stage-glx.c: diff --git a/clutter/clutter-backend.c b/clutter/clutter-backend.c index 871a58229..163bdae13 100644 --- a/clutter/clutter-backend.c +++ b/clutter/clutter-backend.c @@ -55,7 +55,7 @@ clutter_backend_init (ClutterBackend *backend) } ClutterActor * -clutter_backend_get_stage (ClutterBackend *backend) +_clutter_backend_get_stage (ClutterBackend *backend) { g_return_val_if_fail (CLUTTER_IS_BACKEND (backend), NULL); @@ -63,8 +63,8 @@ clutter_backend_get_stage (ClutterBackend *backend) } void -clutter_backend_add_options (ClutterBackend *backend, - GOptionGroup *group) +_clutter_backend_add_options (ClutterBackend *backend, + GOptionGroup *group) { g_return_if_fail (CLUTTER_IS_BACKEND (backend)); @@ -72,8 +72,8 @@ clutter_backend_add_options (ClutterBackend *backend, } gboolean -clutter_backend_pre_parse (ClutterBackend *backend, - GError **error) +_clutter_backend_pre_parse (ClutterBackend *backend, + GError **error) { ClutterBackendClass *klass; @@ -87,8 +87,8 @@ clutter_backend_pre_parse (ClutterBackend *backend, } gboolean -clutter_backend_post_parse (ClutterBackend *backend, - GError **error) +_clutter_backend_post_parse (ClutterBackend *backend, + GError **error) { ClutterBackendClass *klass; @@ -102,8 +102,8 @@ clutter_backend_post_parse (ClutterBackend *backend, } gboolean -clutter_backend_init_stage (ClutterBackend *backend, - GError **error) +_clutter_backend_init_stage (ClutterBackend *backend, + GError **error) { ClutterBackendClass *klass; @@ -117,7 +117,7 @@ clutter_backend_init_stage (ClutterBackend *backend, } void -clutter_backend_init_events (ClutterBackend *backend) +_clutter_backend_init_events (ClutterBackend *backend) { ClutterBackendClass *klass; @@ -128,6 +128,48 @@ clutter_backend_init_events (ClutterBackend *backend) klass->init_events (backend); } +void +_clutter_backend_init_features (ClutterBackend *backend) +{ + ClutterBackendClass *klass; + + g_return_if_fail (CLUTTER_IS_BACKEND (backend)); + + klass = CLUTTER_BACKEND_GET_CLASS (backend); + if (klass->init_features) + klass->init_features (backend); +} + +/** + * clutter_get_default_backend: + * + * FIXME + * + * Return value: the default backend. You should not ref or + * unref the returned object + * + * Since: 0.4 + */ +ClutterBackend * +clutter_get_default_backend (void) +{ + ClutterMainContext *clutter_context; + + clutter_context = clutter_context_get_default (); + + return clutter_context->backend; +} + +/** + * clutter_backend_get_event: + * @backend: a #ClutterBackend + * + * FIXME + * + * Return value: the #ClutterEvent removed from the queue + * + * Since: 0.4 + */ ClutterEvent * clutter_backend_get_event (ClutterBackend *backend) { @@ -137,6 +179,16 @@ clutter_backend_get_event (ClutterBackend *backend) return _clutter_event_queue_pop (backend); } +/** + * clutter_backend_peek_event: + * @backend: a #ClutterBackend + * + * FIXME + * + * Return value: a copy of the first #ClutterEvent in the queue + * + * Since: 0.4 + */ ClutterEvent * clutter_backend_peek_event (ClutterBackend *backend) { @@ -145,6 +197,15 @@ clutter_backend_peek_event (ClutterBackend *backend) return _clutter_event_queue_peek (backend); } +/** + * clutter_backend_put_event: + * @backend: a #ClutterBackend + * @event: a #ClutterEvent + * + * FIXME + * + * Since: 0.4 + */ void clutter_backend_put_event (ClutterBackend *backend, ClutterEvent *event) diff --git a/clutter/clutter-backend.h b/clutter/clutter-backend.h index 7a5952e5b..0bae88bb1 100644 --- a/clutter/clutter-backend.h +++ b/clutter/clutter-backend.h @@ -47,6 +47,7 @@ struct _ClutterBackend GObject parent_instance; /*< private >*/ + /* events queue: every backend must implement one */ GQueue *events_queue; gpointer queue_head; @@ -67,34 +68,27 @@ struct _ClutterBackendClass GObjectClass parent_class; /* vfuncs */ - gboolean (* pre_parse) (ClutterBackend *backend, - GError **error); - gboolean (* post_parse) (ClutterBackend *backend, - GError **error); - gboolean (* init_stage) (ClutterBackend *backend, - GError **error); - void (* init_events) (ClutterBackend *backend); - ClutterActor *(* get_stage) (ClutterBackend *backend); - void (* add_options) (ClutterBackend *backend, - GOptionGroup *group); + gboolean (* pre_parse) (ClutterBackend *backend, + GError **error); + gboolean (* post_parse) (ClutterBackend *backend, + GError **error); + gboolean (* init_stage) (ClutterBackend *backend, + GError **error); + void (* init_events) (ClutterBackend *backend); + void (* init_features) (ClutterBackend *backend); + ClutterActor *(* get_stage) (ClutterBackend *backend); + void (* add_options) (ClutterBackend *backend, + GOptionGroup *group); }; -GType clutter_backend_get_type (void) G_GNUC_CONST; -ClutterActor *clutter_backend_get_stage (ClutterBackend *backend); -void clutter_backend_add_options (ClutterBackend *backend, - GOptionGroup *group); -gboolean clutter_backend_pre_parse (ClutterBackend *backend, - GError **error); -gboolean clutter_backend_post_parse (ClutterBackend *backend, - GError **error); -gboolean clutter_backend_init_stage (ClutterBackend *backend, - GError **error); -void clutter_backend_init_events (ClutterBackend *backend); +GType clutter_backend_get_type (void) G_GNUC_CONST; -ClutterEvent *clutter_backend_get_event (ClutterBackend *backend); -ClutterEvent *clutter_backend_peek_event (ClutterBackend *backend); -void clutter_backend_put_event (ClutterBackend *backend, - ClutterEvent *event); +ClutterBackend *clutter_get_default_backend (void); + +ClutterEvent * clutter_backend_get_event (ClutterBackend *backend); +ClutterEvent * clutter_backend_peek_event (ClutterBackend *backend); +void clutter_backend_put_event (ClutterBackend *backend, + ClutterEvent *event); G_END_DECLS diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index 70eec2180..2d57f7af0 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -112,7 +112,7 @@ clutter_redraw (void) ctx = clutter_context_get_default (); if (ctx->backend) - clutter_actor_paint (clutter_backend_get_stage (ctx->backend)); + clutter_actor_paint (_clutter_backend_get_stage (ctx->backend)); } static void @@ -125,7 +125,7 @@ clutter_main_do_event (ClutterEvent *event, context = clutter_context_get_default (); backend = context->backend; - stage = clutter_backend_get_stage (backend); + stage = _clutter_backend_get_stage (backend); if (!stage) return; @@ -469,7 +469,7 @@ clutter_get_option_group (void) g_option_group_add_entries (group, clutter_args); /* add backend-specific options */ - clutter_backend_add_options (context->backend, group); + _clutter_backend_add_options (context->backend, group); return group; } @@ -547,13 +547,13 @@ clutter_init_with_args (int *argc, clutter_context = clutter_context_get_default (); stage_error = NULL; - if (!clutter_backend_init_stage (clutter_context->backend, &stage_error)) + if (!_clutter_backend_init_stage (clutter_context->backend, &stage_error)) { g_propagate_error (error, stage_error); return CLUTTER_INIT_ERROR_INTERNAL; } - clutter_backend_init_events (clutter_context->backend); + _clutter_backend_init_events (clutter_context->backend); return CLUTTER_INIT_SUCCESS; } @@ -621,7 +621,7 @@ clutter_init (int *argc, context = clutter_context_get_default (); stage_error = NULL; - if (!clutter_backend_init_stage (context->backend, &stage_error)) + if (!_clutter_backend_init_stage (context->backend, &stage_error)) { g_critical (stage_error->message); g_error_free (stage_error); diff --git a/clutter/clutter-private.h b/clutter/clutter-private.h index 4ed17add5..abdef2b5a 100644 --- a/clutter/clutter-private.h +++ b/clutter/clutter-private.h @@ -96,6 +96,19 @@ ClutterEvent *_clutter_event_queue_pop (ClutterBackend *backend); ClutterEvent *_clutter_event_queue_peek (ClutterBackend *backend); gboolean _clutter_event_queue_check_pending (ClutterBackend *backend); +ClutterActor *_clutter_backend_get_stage (ClutterBackend *backend); +void _clutter_backend_add_options (ClutterBackend *backend, + GOptionGroup *group); +gboolean _clutter_backend_pre_parse (ClutterBackend *backend, + GError **error); +gboolean _clutter_backend_post_parse (ClutterBackend *backend, + GError **error); +gboolean _clutter_backend_init_stage (ClutterBackend *backend, + GError **error); +void _clutter_backend_init_events (ClutterBackend *backend); +void _clutter_backend_init_features (ClutterBackend *backend); + + /* signal accumulators */ gboolean _clutter_boolean_accumulator (GSignalInvocationHint *ihint, GValue *return_accu, diff --git a/clutter/clutter-stage.c b/clutter/clutter-stage.c index 7a6e9cefc..5066ed6ed 100644 --- a/clutter/clutter-stage.c +++ b/clutter/clutter-stage.c @@ -419,7 +419,7 @@ clutter_stage_get_default (void) context = clutter_context_get_default (); g_assert (context != NULL); - return clutter_backend_get_stage (context->backend); + return _clutter_backend_get_stage (context->backend); } /** diff --git a/clutter/glx/clutter-event-glx.c b/clutter/glx/clutter-event-glx.c index 638c22f3b..ddbc80d87 100644 --- a/clutter/glx/clutter-event-glx.c +++ b/clutter/glx/clutter-event-glx.c @@ -211,7 +211,7 @@ clutter_event_translate (ClutterBackend *backend, Window xwindow, stage_xwindow; backend_glx = CLUTTER_BACKEND_GLX (backend); - stage = CLUTTER_STAGE (clutter_backend_get_stage (backend)); + stage = CLUTTER_STAGE (_clutter_backend_get_stage (backend)); stage_xwindow = clutter_glx_get_stage_window (stage); xwindow = xevent->xany.window; diff --git a/clutter/glx/clutter-stage-glx.c b/clutter/glx/clutter-stage-glx.c index ef0ec7299..3cf950814 100644 --- a/clutter/glx/clutter-stage-glx.c +++ b/clutter/glx/clutter-stage-glx.c @@ -515,7 +515,7 @@ clutter_stage_glx_set_cursor_visible (ClutterStage *stage, XFixesShowCursor (stage_glx->xdpy, stage_glx->xwin); #else XUndefineCursor (stage_glx->xdpy, stage_glx->xwin); -#endif +#endif /* HAVE_XFIXES */ } else { @@ -534,7 +534,7 @@ clutter_stage_glx_set_cursor_visible (ClutterStage *stage, 1, 1); XFreePixmap (stage_glx->xdpy, pix); XDefineCursor (stage_glx->xdpy, stage_glx->xwin, curs); -#endif +#endif /* HAVE_XFIXES */ } sync_viewport (stage_glx);