mirror of
https://github.com/brl/mutter.git
synced 2025-01-23 18:09:10 +00:00
Use a dynamic array for the actors when delivering events
Instead of using a fixed size array for storing the scenegraph sub-node during event delivery we should use a GPtrArray. The benefits are: - a smaller allocation - no undocumented yet binding constraint on the scenegraph size
This commit is contained in:
parent
64db7896db
commit
3409a941a4
@ -1734,17 +1734,15 @@ static inline void
|
|||||||
emit_event (ClutterEvent *event,
|
emit_event (ClutterEvent *event,
|
||||||
gboolean is_key_event)
|
gboolean is_key_event)
|
||||||
{
|
{
|
||||||
#define MAX_EVENT_DEPTH 512
|
static gboolean lock = FALSE;
|
||||||
|
|
||||||
static ClutterActor **event_tree = NULL;
|
GPtrArray *event_tree = NULL;
|
||||||
static gboolean lock = FALSE;
|
ClutterActor *actor;
|
||||||
|
gint i = 0;
|
||||||
ClutterActor *actor;
|
|
||||||
gint i = 0, n_tree_events = 0;
|
|
||||||
|
|
||||||
if (!event->any.source)
|
if (!event->any.source)
|
||||||
{
|
{
|
||||||
g_warning ("No event source set, discarding event");
|
CLUTTER_NOTE (EVENT, "No source set, discarding event");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1754,14 +1752,12 @@ emit_event (ClutterEvent *event,
|
|||||||
|
|
||||||
lock = TRUE;
|
lock = TRUE;
|
||||||
|
|
||||||
/* Sorry Mr Bassi. */
|
event_tree = g_ptr_array_sized_new (64);
|
||||||
if (G_UNLIKELY (event_tree == NULL))
|
|
||||||
event_tree = g_new0 (ClutterActor *, MAX_EVENT_DEPTH);
|
|
||||||
|
|
||||||
actor = event->any.source;
|
actor = event->any.source;
|
||||||
|
|
||||||
/* Build 'tree' of emitters for the event */
|
/* Build 'tree' of emitters for the event */
|
||||||
while (actor && n_tree_events < MAX_EVENT_DEPTH)
|
while (actor)
|
||||||
{
|
{
|
||||||
ClutterActor *parent;
|
ClutterActor *parent;
|
||||||
|
|
||||||
@ -1771,30 +1767,29 @@ emit_event (ClutterEvent *event,
|
|||||||
parent == NULL || /* stage gets all events */
|
parent == NULL || /* stage gets all events */
|
||||||
is_key_event) /* keyboard events are always emitted */
|
is_key_event) /* keyboard events are always emitted */
|
||||||
{
|
{
|
||||||
event_tree[n_tree_events++] = g_object_ref (actor);
|
g_ptr_array_add (event_tree, g_object_ref (actor));
|
||||||
}
|
}
|
||||||
|
|
||||||
actor = parent;
|
actor = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Capture */
|
/* Capture */
|
||||||
for (i = n_tree_events-1; i >= 0; i--)
|
for (i = event_tree->len - 1; i >= 0; i--)
|
||||||
if (clutter_actor_event (event_tree[i], event, TRUE))
|
if (clutter_actor_event (g_ptr_array_index (event_tree, i), event, TRUE))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
/* Bubble */
|
/* Bubble */
|
||||||
for (i = 0; i < n_tree_events; i++)
|
for (i = 0; i < event_tree->len; i++)
|
||||||
if (clutter_actor_event (event_tree[i], event, FALSE))
|
if (clutter_actor_event (g_ptr_array_index (event_tree, i), event, FALSE))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
for (i = 0; i < event_tree->len; i++)
|
||||||
|
g_object_unref (g_ptr_array_index (event_tree, i));
|
||||||
|
|
||||||
for (i = 0; i < n_tree_events; i++)
|
g_ptr_array_free (event_tree, TRUE);
|
||||||
g_object_unref (event_tree[i]);
|
|
||||||
|
|
||||||
lock = FALSE;
|
lock = FALSE;
|
||||||
|
|
||||||
#undef MAX_EVENT_DEPTH
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user