2007-10-10 Matthew Allum <mallum@openedhand.com>

* 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.
This commit is contained in:
Matthew Allum 2007-10-09 23:45:49 +00:00
parent 475fcc64a7
commit 8faf9b9964
4 changed files with 76 additions and 3 deletions

View File

@ -1,3 +1,13 @@
2007-10-10 Matthew Allum <mallum@openedhand.com>
* 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 <ebassi@openedhand.com>
* clutter/clutter-script.c (resolve_alpha_func): Fix the

View File

@ -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:

View File

@ -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);

View File

@ -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;