From 8a579838d54d2b6f552fd32d9772f6e04f178179 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 14 Jan 2010 17:14:33 +0000 Subject: [PATCH] device: Unset the cursor actor when leaving the stage When an InputDevice leaves a stage we set the stage member of InputDevice to NULL. We should also unset the cursor_actor (as the device is obviously not on an actor any more). When the device re-enters the Stage the ENTER/LEAVE event generation machinery will then be able to emit the ENTER event on the Stage. --- clutter/clutter-input-device.c | 45 ++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/clutter/clutter-input-device.c b/clutter/clutter-input-device.c index 2e04edbe9..07958e7e8 100644 --- a/clutter/clutter-input-device.c +++ b/clutter/clutter-input-device.c @@ -210,22 +210,6 @@ _clutter_input_device_set_time (ClutterInputDevice *device, device->current_time = time_; } -/* - * _clutter_input_device_set_stage: - * @device: a #ClutterInputDevice - * @stage: a #ClutterStage - * - * Stores the stage under the device - */ -void -_clutter_input_device_set_stage (ClutterInputDevice *device, - ClutterStage *stage) -{ - g_return_if_fail (CLUTTER_IS_INPUT_DEVICE (device)); - - device->stage = stage; -} - /* * cursor_weak_unref: * @@ -242,6 +226,35 @@ cursor_weak_unref (gpointer user_data, device->cursor_actor = NULL; } +/* + * _clutter_input_device_set_stage: + * @device: a #ClutterInputDevice + * @stage: a #ClutterStage or %NULL + * + * Stores the stage under the device + */ +void +_clutter_input_device_set_stage (ClutterInputDevice *device, + ClutterStage *stage) +{ + g_return_if_fail (CLUTTER_IS_INPUT_DEVICE (device)); + + device->stage = stage; + + /* if we left the stage then we also need to unset the + * cursor actor (and update its :has-pointer property) + */ + if (device->stage == NULL && device->cursor_actor != NULL) + { + _clutter_actor_set_has_pointer (device->cursor_actor, FALSE); + g_object_weak_unref (G_OBJECT (device->cursor_actor), + cursor_weak_unref, + device); + + device->cursor_actor = NULL; + } +} + /* * _clutter_input_device_set_actor: * @device: a #ClutterInputDevice