diff --git a/ChangeLog b/ChangeLog index eb0b30fba..855b46f95 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2007-10-10 Matthew Allum + + * clutter/clutter-actor.c: + * clutter/clutter-actor.h: + Add missing enter/leave event signals + + * clutter/clutter-main.c: (clutter_do_event): + Set time in crossing events. + Protect against do_pick() failing. + 2007-10-09 Emmanuele Bassi * clutter/clutter-script.c (resolve_alpha_func): Fix the diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index 960926022..0e521eec6 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -31,6 +31,17 @@ * stage. Every object that must appear on the main #ClutterStage must also * be a #ClutterActor, either by using one of the classes provided by * Clutter, or by implementing a new #ClutterActor subclass. + * + * Ordering of tranformations. FIXME. + * + * Notes on clutter actor events: FIXME. + * + * - Actors emit pointer events if set reactive (#clutter_actor_set_reactive) + * - Keyboard events are emitted if actor has focus (#clutter_stage_set_focus) + * - Motion events (motion, enter, leave) are only emitted per actor if + * #clutter_enable_motion_events called with TRUE. If set to FALSE (default) + * then only the stage emits events. + * - One emitted an event emission has two phases - capture and bubble. */ #include "config.h" @@ -93,6 +104,7 @@ enum HIDE, DESTROY, PARENT_SET, + EVENT, EVENT_AFTER, BUTTON_PRESS_EVENT, @@ -103,6 +115,9 @@ enum MOTION_EVENT, FOCUS_IN, FOCUS_OUT, + ENTER_EVENT, + LEAVE_EVENT, + LAST_SIGNAL }; @@ -1430,7 +1445,7 @@ clutter_actor_class_init (ClutterActorClass *klass) * * The ::focus-out signal is emitted when @actor loses key focus. * - * Source: 0.6 + * Since: 0.6 */ actor_signals[FOCUS_OUT] = g_signal_new ("focus-out", @@ -1441,6 +1456,40 @@ clutter_actor_class_init (ClutterActorClass *klass) clutter_marshal_VOID__VOID, G_TYPE_NONE, 0); + /** + * ClutterActor::enter: + * @actor: the actor which the pointer has entered. + * + * The ::enter signal is emitted when the pointer enters the @actor + * + * Since: 0.6 + */ + actor_signals[ENTER_EVENT] = + g_signal_new ("enter-event", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (ClutterActorClass, enter), + NULL, NULL, + clutter_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + /** + * ClutterActor::leave: + * @actor: the actor which the pointer has left + * + * The ::leave signal is emitted when the pointer leaves the @actor. + * + * Since: 0.6 + */ + actor_signals[LEAVE_EVENT] = + g_signal_new ("leave-event", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (ClutterActorClass, leave), + NULL, NULL, + clutter_marshal_VOID__VOID, + G_TYPE_NONE, 0); + klass->show = clutter_actor_real_show; klass->show_all = clutter_actor_show; @@ -2975,6 +3024,12 @@ clutter_actor_event (ClutterActor *actor, case CLUTTER_MOTION: signal_num = MOTION_EVENT; break; + case CLUTTER_ENTER: + signal_num = ENTER_EVENT; + break; + case CLUTTER_LEAVE: + signal_num = LEAVE_EVENT; + break; case CLUTTER_DELETE: case CLUTTER_DESTROY_NOTIFY: case CLUTTER_CLIENT_MESSAGE: diff --git a/clutter/clutter-actor.h b/clutter/clutter-actor.h index 22c3eeb0d..475d6a913 100644 --- a/clutter/clutter-actor.h +++ b/clutter/clutter-actor.h @@ -207,6 +207,10 @@ struct _ClutterActorClass ClutterKeyEvent *event); gboolean (* motion_event) (ClutterActor *actor, ClutterMotionEvent *event); + void (* enter) (ClutterActor *actor, + ClutterCrossingEvent *event); + void (* leave) (ClutterActor *actor, + ClutterCrossingEvent *event); void (* focus_in) (ClutterActor *actor); void (* focus_out) (ClutterActor *actor); diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index 3b35a74f5..b6531362b 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -1173,6 +1173,8 @@ clutter_do_event (ClutterEvent *event) actor = event->crossing.source; + g_return_if_fail (actor != NULL); + while (actor) { if (clutter_actor_is_reactive (actor) || @@ -1247,6 +1249,8 @@ clutter_do_event (ClutterEvent *event) CLUTTER_NOTE (EVENT, "Reactive event received at %i, %i - actor: %p", x, y, actor); + g_return_if_fail (actor != NULL); + if (event->type == CLUTTER_SCROLL) event->scroll.source = g_object_ref (actor); else @@ -1262,7 +1266,7 @@ clutter_do_event (ClutterEvent *event) ClutterEvent cev; cev.crossing.type = CLUTTER_LEAVE; - cev.crossing.time = 0; /* FIXME */ + cev.crossing.time = event->any.time; cev.crossing.flags = 0; cev.crossing.x = x; cev.crossing.y = y; @@ -1272,7 +1276,7 @@ clutter_do_event (ClutterEvent *event) clutter_event_put (&cev); /* copys */ cev.crossing.type = CLUTTER_ENTER; - cev.crossing.time = 0; /* FIXME */ + cev.crossing.time = event->any.time; cev.crossing.flags = 0; cev.crossing.x = x; cev.crossing.y = y;