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

@@ -11,6 +11,8 @@
#include "st-clickable.h"
#include "st-private.h"
G_DEFINE_TYPE (StClickable, st_clickable, ST_TYPE_BIN);
struct _StClickablePrivate {
@@ -69,17 +71,6 @@ set_pressed (StClickable *self,
g_object_notify (G_OBJECT (self), "pressed");
}
static gboolean
st_clickable_contains (StClickable *self,
ClutterActor *actor)
{
while (actor != NULL && actor != (ClutterActor*)self)
{
actor = clutter_actor_get_parent (actor);
}
return actor != NULL;
}
static gboolean
st_clickable_enter_event (ClutterActor *actor,
ClutterCrossingEvent *event)
@@ -130,7 +121,7 @@ st_clickable_button_press_event (ClutterActor *actor,
if (self->priv->held)
return TRUE;
if (!st_clickable_contains (self, event->source))
if (!_st_actor_contains (actor, event->source))
return FALSE;
self->priv->held = TRUE;
@@ -157,7 +148,7 @@ st_clickable_button_release_event (ClutterActor *actor,
self->priv->held = FALSE;
clutter_ungrab_pointer ();
if (!st_clickable_contains (self, event->source))
if (!_st_actor_contains (actor, event->source))
return FALSE;
set_pressed (self, FALSE);