From b14bdfe2bbac3b1e458780c33bc72def2aa2ebe1 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 18 Dec 2007 10:49:29 +0000 Subject: [PATCH] 2007-12-18 Emmanuele Bassi * 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. --- ChangeLog | 11 +++++++++++ clutter/clutter-main.c | 40 +++++++++++++++++++++++++++++++-------- clutter/clutter-private.h | 2 ++ 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index b5848ad62..e7de56961 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2007-12-18 Emmanuele Bassi + + * 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 * clutter/clutter-actor.c: diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index 0da0053ce..97cda3b7d 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -1256,16 +1256,23 @@ emit_keyboard_event (ClutterEvent *event) emit_event (event, TRUE); } +static void +unset_motion_last_actor (ClutterActor *actor) +{ + ClutterMainContext *context = ClutterCntx; + + context->motion_last_actor = NULL; +} + static inline void generate_enter_leave_events (ClutterEvent *event) { - ClutterMainContext *context = ClutterCntx; - static ClutterActor *motion_last_actor = NULL; - ClutterActor *motion_current_actor = event->motion.source; + ClutterMainContext *context = ClutterCntx; + 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; @@ -1274,7 +1281,7 @@ generate_enter_leave_events (ClutterEvent *event) cev.crossing.flags = 0; cev.crossing.x = event->motion.x; cev.crossing.y = event->motion.y; - cev.crossing.source = motion_last_actor; + cev.crossing.source = context->motion_last_actor; /* unref in free */ 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.y = event->motion.y; 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, 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; } /** diff --git a/clutter/clutter-private.h b/clutter/clutter-private.h index 42187a418..a3f7a4454 100644 --- a/clutter/clutter-private.h +++ b/clutter/clutter-private.h @@ -94,6 +94,8 @@ struct _ClutterMainContext (or NULL if there is no pointer grab) */ GSList *shaders; /* stack of overridden shaders */ + + ClutterActor *motion_last_actor; }; #define CLUTTER_CONTEXT() (clutter_context_get_default ())