stage: Allow tracking dragged actors

We should be able to internally attach the actor currently being dragged
to the device that is dragging it.

https://bugzilla.gnome.org/show_bug.cgi?id=652842
This commit is contained in:
Emmanuele Bassi 2011-06-17 16:51:05 +01:00
parent e4756fd764
commit 530a13f02f
2 changed files with 56 additions and 0 deletions

View File

@ -99,6 +99,14 @@ void _clutter_stage_release_pick_id (ClutterStage *stage,
ClutterActor * _clutter_stage_get_actor_by_pick_id (ClutterStage *stage,
gint32 pick_id);
void _clutter_stage_add_drag_actor (ClutterStage *stage,
ClutterInputDevice *device,
ClutterActor *actor);
ClutterActor * _clutter_stage_get_drag_actor (ClutterStage *stage,
ClutterInputDevice *device);
void _clutter_stage_remove_drag_actor (ClutterStage *stage,
ClutterInputDevice *device);
G_END_DECLS
#endif /* __CLUTTER_STAGE_PRIVATE_H__ */

View File

@ -4091,3 +4091,51 @@ _clutter_stage_get_actor_by_pick_id (ClutterStage *stage,
return _clutter_id_pool_lookup (priv->pick_id_pool, pick_id);
}
void
_clutter_stage_add_drag_actor (ClutterStage *stage,
ClutterInputDevice *device,
ClutterActor *actor)
{
GHashTable *drag_actors;
drag_actors = g_object_get_data (G_OBJECT (stage), "__clutter_stage_drag_actors");
if (drag_actors == NULL)
{
drag_actors = g_hash_table_new (NULL, NULL);
g_object_set_data_full (G_OBJECT (stage), "__clutter_stage_drag_actors",
drag_actors,
(GDestroyNotify) g_hash_table_destroy);
}
g_hash_table_replace (drag_actors, device, actor);
}
ClutterActor *
_clutter_stage_get_drag_actor (ClutterStage *stage,
ClutterInputDevice *device)
{
GHashTable *drag_actors;
drag_actors = g_object_get_data (G_OBJECT (stage), "__clutter_stage_drag_actors");
if (drag_actors == NULL)
return NULL;
return g_hash_table_lookup (drag_actors, device);
}
void
_clutter_stage_remove_drag_actor (ClutterStage *stage,
ClutterInputDevice *device)
{
GHashTable *drag_actors;
drag_actors = g_object_get_data (G_OBJECT (stage), "__clutter_stage_drag_actors");
if (drag_actors == NULL)
return;
g_hash_table_remove (drag_actors, device);
if (g_hash_table_size (drag_actors) == 0)
g_object_set_data (G_OBJECT (stage), "__clutter_stage_drag_actors", NULL);
}