2007-12-18 Emmanuele Bassi <ebassi@openedhand.com>

* clutter/clutter-main.c:
	(unset_motion_last_actor),
	(generate_enter_leave_events): Attach a callback to the destroy
	signal on the last motion actor, so if it goes away while the
	pointer is in the middle of it we can unset the pointer.

	* clutter/clutter-private.h: Store the last motion actor inside
	the global context.
This commit is contained in:
Emmanuele Bassi 2007-12-18 10:49:29 +00:00
parent 98c537365c
commit b14bdfe2bb
3 changed files with 45 additions and 8 deletions

View File

@ -1,3 +1,14 @@
2007-12-18 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-main.c:
(unset_motion_last_actor),
(generate_enter_leave_events): Attach a callback to the destroy
signal on the last motion actor, so if it goes away while the
pointer is in the middle of it we can unset the pointer.
* clutter/clutter-private.h: Store the last motion actor inside
the global context.
2007-12-17 Emmanuele Bassi <ebassi@openedhand.com> 2007-12-17 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-actor.c: * clutter/clutter-actor.c:

View File

@ -1256,16 +1256,23 @@ emit_keyboard_event (ClutterEvent *event)
emit_event (event, TRUE); emit_event (event, TRUE);
} }
static void
unset_motion_last_actor (ClutterActor *actor)
{
ClutterMainContext *context = ClutterCntx;
context->motion_last_actor = NULL;
}
static inline void static inline void
generate_enter_leave_events (ClutterEvent *event) generate_enter_leave_events (ClutterEvent *event)
{ {
ClutterMainContext *context = ClutterCntx; ClutterMainContext *context = ClutterCntx;
static ClutterActor *motion_last_actor = NULL; ClutterActor *motion_current_actor = event->motion.source;
ClutterActor *motion_current_actor = event->motion.source;
if (motion_last_actor != motion_current_actor) if (context->motion_last_actor != motion_current_actor)
{ {
if (motion_last_actor && motion_current_actor) if (context->motion_last_actor && motion_current_actor)
{ {
ClutterEvent cev; ClutterEvent cev;
@ -1274,7 +1281,7 @@ generate_enter_leave_events (ClutterEvent *event)
cev.crossing.flags = 0; cev.crossing.flags = 0;
cev.crossing.x = event->motion.x; cev.crossing.x = event->motion.x;
cev.crossing.y = event->motion.y; cev.crossing.y = event->motion.y;
cev.crossing.source = motion_last_actor; cev.crossing.source = context->motion_last_actor;
/* unref in free */ /* unref in free */
cev.crossing.related = g_object_ref (motion_current_actor); cev.crossing.related = g_object_ref (motion_current_actor);
@ -1287,13 +1294,30 @@ generate_enter_leave_events (ClutterEvent *event)
cev.crossing.x = event->motion.x; cev.crossing.x = event->motion.x;
cev.crossing.y = event->motion.y; cev.crossing.y = event->motion.y;
cev.crossing.source = motion_current_actor; cev.crossing.source = motion_current_actor;
cev.crossing.related = g_object_ref (motion_last_actor); cev.crossing.related = g_object_ref (context->motion_last_actor);
g_queue_push_head (context->events_queue, g_queue_push_head (context->events_queue,
clutter_event_copy (&cev)); clutter_event_copy (&cev));
} }
} }
motion_last_actor = motion_current_actor;
if (context->motion_last_actor &&
context->motion_last_actor != motion_current_actor)
{
g_signal_handlers_disconnect_by_func (context->motion_last_actor,
G_CALLBACK (unset_motion_last_actor),
NULL);
}
if (motion_current_actor &&
context->motion_last_actor != motion_current_actor)
{
g_signal_connect (motion_current_actor, "destroy",
G_CALLBACK (unset_motion_last_actor),
NULL);
}
context->motion_last_actor = motion_current_actor;
} }
/** /**

View File

@ -94,6 +94,8 @@ struct _ClutterMainContext
(or NULL if there is no pointer grab) (or NULL if there is no pointer grab)
*/ */
GSList *shaders; /* stack of overridden shaders */ GSList *shaders; /* stack of overridden shaders */
ClutterActor *motion_last_actor;
}; };
#define CLUTTER_CONTEXT() (clutter_context_get_default ()) #define CLUTTER_CONTEXT() (clutter_context_get_default ())