2007-10-08 Matthew Allum <mallum@openedhand.com>

* clutter/clutter-actor.c:
        * clutter/clutter-actor.h:
        * clutter/clutter-private.h:
        * clutter/clutter-main.c:
        Add a hash to global clutter context mapping all parented actor
        id's to actors.
        Add clutter_get_actor_by_id() call.
        Convert picking machinery to use above.
        (performance/simpler composite actor creation)

        * clutter/clutter-stage.c: (clutter_stage_fullscreen),
        (clutter_stage_unfullscreen), (clutter_stage_event):
        Only set the fullscreen property on stage state fullscreen event(#545)
        Experimental as could be painful to implement on non X backends.
This commit is contained in:
Matthew Allum 2007-10-08 16:18:33 +00:00
parent 9e81870d0b
commit 34a40de3c5
6 changed files with 86 additions and 25 deletions

View File

@ -1,3 +1,20 @@
2007-10-08 Matthew Allum <mallum@openedhand.com>
* clutter/clutter-actor.c:
* clutter/clutter-actor.h:
* clutter/clutter-private.h:
* clutter/clutter-main.c:
Add a hash to global clutter context mapping all parented actor
id's to actors.
Add clutter_get_actor_by_id() call.
Convert picking machinery to use above.
(performance/simpler composite actor creation)
* clutter/clutter-stage.c: (clutter_stage_fullscreen),
(clutter_stage_unfullscreen), (clutter_stage_event):
Only set the fullscreen property on stage state fullscreen event(#545)
Experimental as could be painful to implement on non X backends.
2007-10-08 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-script.c (json_parse_end):

View File

@ -2655,9 +2655,14 @@ void
clutter_actor_set_parent (ClutterActor *self,
ClutterActor *parent)
{
ClutterMainContext *clutter_context;
clutter_context = clutter_context_get_default ();
g_return_if_fail (CLUTTER_IS_ACTOR (self));
g_return_if_fail (CLUTTER_IS_ACTOR (parent));
g_return_if_fail (self != parent);
g_return_if_fail (clutter_context != NULL);
if (self->priv->parent_actor != NULL)
{
@ -2674,6 +2679,10 @@ clutter_actor_set_parent (ClutterActor *self,
return;
}
g_hash_table_insert (clutter_context->actor_hash,
(gpointer)clutter_actor_get_id(self),
(gpointer)self);
g_object_ref_sink (self);
self->priv->parent_actor = parent;
g_signal_emit (self, actor_signals[PARENT_SET], 0, NULL);
@ -2718,8 +2727,12 @@ void
clutter_actor_unparent (ClutterActor *self)
{
ClutterActor *old_parent;
ClutterMainContext *clutter_context;
clutter_context = clutter_context_get_default ();
g_return_if_fail (CLUTTER_IS_ACTOR (self));
g_return_if_fail (clutter_context != NULL);
if (self->priv->parent_actor == NULL)
return;
@ -2737,6 +2750,9 @@ clutter_actor_unparent (ClutterActor *self)
self->priv->parent_actor = NULL;
g_signal_emit (self, actor_signals[PARENT_SET], 0, old_parent);
g_hash_table_remove (clutter_context->actor_hash,
(gconstpointer)clutter_actor_get_id(self));
g_object_unref (self);
}

View File

@ -373,6 +373,8 @@ clutter_actor_unset_reactive (ClutterActor *actor);
gboolean
clutter_actor_is_reactive (ClutterActor *actor);
ClutterActor*
clutter_get_actor_by_id (guint32 id);
G_END_DECLS

View File

@ -232,10 +232,9 @@ _clutter_do_pick (ClutterStage *stage,
/* Decode color back into an ID, taking into account fb depth */
id = pixel[2]>>(8-b) | pixel[1]<<b>>(8-g) | pixel[0]<<(g+b)>>(8-r);
return clutter_container_find_child_by_id (CLUTTER_CONTAINER (stage), id);
return clutter_get_actor_by_id (id);
}
/**
* clutter_main_quit:
*
@ -761,6 +760,8 @@ pre_parse_hook (GOptionContext *context,
clutter_context->font_map = PANGO_FT2_FONT_MAP (pango_ft2_font_map_new ());
pango_ft2_font_map_set_resolution (clutter_context->font_map, 96.0, 96.0);
clutter_context->actor_hash = g_hash_table_new (NULL, NULL);
backend = clutter_context->backend;
g_assert (CLUTTER_IS_BACKEND (backend));
@ -1318,6 +1319,27 @@ clutter_do_event (ClutterEvent *event)
}
}
/**
* clutter_get_actor_by_id
* @id: a #ClutterActor ID.
*
* FIXME.
*
* Since: 0.6
*/
ClutterActor*
clutter_get_actor_by_id (guint32 id)
{
ClutterMainContext *context;
context = clutter_context_get_default ();
g_return_val_if_fail (context != NULL, NULL);
g_return_val_if_fail (context->actor_hash != NULL, NULL);
return g_hash_table_lookup (context->actor_hash, (gconstpointer)id);
}
void
clutter_base_init (void)
{
@ -1336,3 +1358,4 @@ clutter_base_init (void)
foo = clutter_actor_get_type ();
}
}

View File

@ -65,22 +65,20 @@ typedef struct _ClutterMainContext ClutterMainContext;
struct _ClutterMainContext
{
/* holds a pointer to the backend, which controls the stage */
ClutterBackend *backend;
/* the main event queue */
GQueue *events_queue;
ClutterBackend *backend; /* holds a pointer to the windowing
system backend */
GQueue *events_queue; /* the main event queue */
PangoFT2FontMap *font_map;
guint update_idle; /* repaint idler id */
guint update_idle;
guint is_initialized : 1;
guint is_initialized : 1;
GTimer *timer; /* Used for debugging scheduler */
ClutterPickMode pick_mode; /* Indicates pick render mode */
guint motion_events_per_actor : 1;
guint motion_events_per_actor : 1;/* set for enter/leave events */
gint num_reactives; /* Num of reactive actors */
GHashTable *actor_hash; /* Hash of all actors mapped to id */
};
#define CLUTTER_CONTEXT() (clutter_context_get_default ())

View File

@ -608,13 +608,12 @@ clutter_stage_fullscreen (ClutterStage *stage)
priv = stage->priv;
if (!priv->is_fullscreen)
{
/* Only set if backend implements */
/* Only set if backend implements.
* Also see clutter_stage_event() for setting priv->is_fullscreen
* on state change event.
*/
if (CLUTTER_STAGE_GET_CLASS (stage)->set_fullscreen)
{
priv->is_fullscreen = TRUE;
CLUTTER_STAGE_GET_CLASS (stage)->set_fullscreen (stage, TRUE);
g_object_notify (G_OBJECT (stage), "fullscreen");
}
CLUTTER_STAGE_GET_CLASS (stage)->set_fullscreen (stage, TRUE);
}
}
@ -640,11 +639,7 @@ clutter_stage_unfullscreen (ClutterStage *stage)
{
/* Only set if backend implements */
if (CLUTTER_STAGE_GET_CLASS (stage)->set_fullscreen)
{
priv->is_fullscreen = FALSE;
CLUTTER_STAGE_GET_CLASS (stage)->set_fullscreen (stage, FALSE);
g_object_notify (G_OBJECT (stage), "fullscreen");
}
CLUTTER_STAGE_GET_CLASS (stage)->set_fullscreen (stage, FALSE);
}
}
@ -819,9 +814,13 @@ gboolean
clutter_stage_event (ClutterStage *stage,
ClutterEvent *event)
{
ClutterStagePrivate *priv;
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
priv = stage->priv;
if (event->type == CLUTTER_DELETE)
return TRUE;
@ -835,9 +834,15 @@ clutter_stage_event (ClutterStage *stage,
if (event->stage_state.changed_mask & CLUTTER_STAGE_STATE_FULLSCREEN)
{
if (event->stage_state.new_state & CLUTTER_STAGE_STATE_FULLSCREEN)
g_signal_emit (stage, stage_signals[FULLSCREEN], 0);
{
priv->is_fullscreen = TRUE;
g_signal_emit (stage, stage_signals[FULLSCREEN], 0);
}
else
g_signal_emit (stage, stage_signals[UNFULLSCREEN], 0);
{
priv->is_fullscreen = FALSE;
g_signal_emit (stage, stage_signals[UNFULLSCREEN], 0);
}
}
if (event->stage_state.changed_mask & CLUTTER_STAGE_STATE_ACTIVATED)