* clutter/clutter-main.c: (generate_enter_leave_events): synthesize

enter event (without related) and corresponding leave event when the
actor the cursor is over has been destroyed.
* clutter/clutter-event.c: (clutter_event_free): only unref the
related_actor when it actually is set.
This commit is contained in:
Øyvind Kolås 2007-12-18 13:03:45 +00:00
parent b14bdfe2bb
commit bf66f7a3ec
3 changed files with 36 additions and 14 deletions

View File

@ -1,3 +1,11 @@
2007-12-18 Øyvind Kolås <pippin@o-hand.com>
* clutter/clutter-main.c: (generate_enter_leave_events): synthesize
enter event (without related) and corresponding leave event when the
actor the cursor is over has been destroyed.
* clutter/clutter-event.c: (clutter_event_free): only unref the
related_actor when it actually is set.
2007-12-18 Emmanuele Bassi <ebassi@openedhand.com> 2007-12-18 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-main.c: * clutter/clutter-main.c:

View File

@ -355,8 +355,9 @@ clutter_event_free (ClutterEvent *event)
{ {
if (G_LIKELY (event)) if (G_LIKELY (event))
{ {
if (event->type == CLUTTER_LEAVE || event->type == CLUTTER_ENTER) if ((event->type == CLUTTER_LEAVE || event->type == CLUTTER_ENTER) &&
g_object_unref (event->crossing.related); event->crossing.related)
g_object_unref (event->crossing.related);
g_slice_free (ClutterEvent, event); g_slice_free (ClutterEvent, event);
} }
} }

View File

@ -1272,21 +1272,24 @@ generate_enter_leave_events (ClutterEvent *event)
if (context->motion_last_actor != motion_current_actor) if (context->motion_last_actor != motion_current_actor)
{ {
if (context->motion_last_actor && motion_current_actor) if (motion_current_actor)
{ {
ClutterEvent cev; ClutterEvent cev;
cev.crossing.type = CLUTTER_LEAVE; if (context->motion_last_actor)
cev.crossing.time = event->any.time; {
cev.crossing.flags = 0; cev.crossing.type = CLUTTER_LEAVE;
cev.crossing.x = event->motion.x; cev.crossing.time = event->any.time;
cev.crossing.y = event->motion.y; cev.crossing.flags = 0;
cev.crossing.source = context->motion_last_actor; cev.crossing.x = event->motion.x;
/* unref in free */ cev.crossing.y = event->motion.y;
cev.crossing.related = g_object_ref (motion_current_actor); cev.crossing.source = context->motion_last_actor;
/* unref in free */
cev.crossing.related = g_object_ref (motion_current_actor);
g_queue_push_head (context->events_queue, g_queue_push_head (context->events_queue,
clutter_event_copy (&cev)); clutter_event_copy (&cev));
}
cev.crossing.type = CLUTTER_ENTER; cev.crossing.type = CLUTTER_ENTER;
cev.crossing.time = event->any.time; cev.crossing.time = event->any.time;
@ -1294,7 +1297,17 @@ 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 (context->motion_last_actor); if (context->motion_last_actor)
{
cev.crossing.related = g_object_ref (context->motion_last_actor);
}
else
{
/* the previous actor we were getting events from seems to have
* vanished
*/
cev.crossing.related = NULL;
}
g_queue_push_head (context->events_queue, g_queue_push_head (context->events_queue,
clutter_event_copy (&cev)); clutter_event_copy (&cev));