De-duplicate "actor contains actor" code

Add _st_actor_contains() in st-private for use within St, and
monkey-patch in a Clutter.Actor.contains() for use by javascript, and
then replace all the duplicate implementations with one or the other
of those.

https://bugzilla.gnome.org/show_bug.cgi?id=621197
This commit is contained in:
Dan Winship
2010-06-10 08:15:02 -04:00
parent e6a70e4676
commit a4befeba53
10 changed files with 38 additions and 81 deletions

View File

@ -557,15 +557,6 @@ st_widget_get_theme_node (StWidget *widget)
return priv->theme_node;
}
static gboolean
actor_contains (ClutterActor *widget,
ClutterActor *other)
{
while (other != NULL && other != widget)
other = clutter_actor_get_parent (other);
return other != NULL;
}
static gboolean
st_widget_enter (ClutterActor *actor,
ClutterCrossingEvent *event)
@ -574,7 +565,7 @@ st_widget_enter (ClutterActor *actor,
if (priv->track_hover)
{
if (actor_contains (actor, event->source))
if (_st_actor_contains (actor, event->source))
st_widget_set_hover (ST_WIDGET (actor), TRUE);
else
{
@ -600,7 +591,7 @@ st_widget_leave (ClutterActor *actor,
if (priv->track_hover)
{
if (!actor_contains (actor, event->related))
if (!_st_actor_contains (actor, event->related))
st_widget_set_hover (ST_WIDGET (actor), FALSE);
}
@ -1589,17 +1580,13 @@ st_widget_sync_hover (StWidget *widget)
{
ClutterDeviceManager *device_manager;
ClutterInputDevice *pointer;
ClutterActor *actor;
ClutterActor *pointer_actor;
device_manager = clutter_device_manager_get_default ();
pointer = clutter_device_manager_get_core_device (device_manager,
CLUTTER_POINTER_DEVICE);
actor = clutter_input_device_get_pointer_actor (pointer);
while (actor && actor != (ClutterActor *)widget)
actor = clutter_actor_get_parent (actor);
st_widget_set_hover (widget, actor == (ClutterActor *)widget);
pointer_actor = clutter_input_device_get_pointer_actor (pointer);
st_widget_set_hover (widget, _st_actor_contains (CLUTTER_ACTOR (widget), pointer_actor));
}
/**