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

@@ -65,6 +65,7 @@
#include "st-texture-cache.h"
#include "st-marshal.h"
#include "st-clipboard.h"
#include "st-private.h"
#define HAS_FOCUS(actor) (clutter_actor_get_stage (actor) && clutter_stage_get_key_focus ((ClutterStage *) clutter_actor_get_stage (actor)) == actor)
@@ -577,22 +578,13 @@ st_entry_key_focus_in (ClutterActor *actor)
clutter_actor_grab_key_focus (priv->entry);
}
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_entry_enter_event (ClutterActor *actor,
ClutterCrossingEvent *event)
{
StEntryPrivate *priv = ST_ENTRY_PRIV (actor);
if (actor_contains (actor, event->source)
if (_st_actor_contains (actor, event->source)
&& priv->hint && priv->hint_visible)
{
st_widget_set_hover (ST_WIDGET (actor), TRUE);
@@ -605,7 +597,7 @@ static gboolean
st_entry_leave_event (ClutterActor *actor,
ClutterCrossingEvent *event)
{
if (!actor_contains (actor, event->related))
if (!_st_actor_contains (actor, event->related))
st_widget_set_hover (ST_WIDGET (actor), FALSE);
return CLUTTER_ACTOR_CLASS (st_entry_parent_class)->leave_event (actor, event);