event: Fix up clutter_event_copy()

We need to copy the scroll axis data, and we need to copy the private
Event data from the source event to the target event structure.
This commit is contained in:
Emmanuele Bassi 2011-01-18 22:31:14 +00:00
parent 405e611279
commit d078fe0930

View File

@ -676,12 +676,22 @@ ClutterEvent *
clutter_event_copy (const ClutterEvent *event)
{
ClutterEvent *new_event;
ClutterEventPrivate *new_real_event;
g_return_val_if_fail (event != NULL, NULL);
new_event = clutter_event_new (CLUTTER_NOTHING);
new_real_event = (ClutterEventPrivate *) new_event;
*new_event = *event;
if (is_event_allocated (event))
{
ClutterEventPrivate *real_event = (ClutterEventPrivate *) event;
new_real_event->source_device = real_event->source_device;
}
switch (event->type)
{
case CLUTTER_BUTTON_PRESS:
@ -696,6 +706,17 @@ clutter_event_copy (const ClutterEvent *event)
}
break;
case CLUTTER_SCROLL:
if (event->scroll.device != NULL && event->scroll.axes != NULL)
{
gint n_axes;
n_axes = clutter_input_device_get_n_axes (event->scroll.device);
new_event->scroll.axes = g_memdup (event->scroll.axes,
sizeof (gdouble) * n_axes);
}
break;
case CLUTTER_MOTION:
if (event->motion.device != NULL && event->motion.axes != NULL)
{
@ -743,6 +764,10 @@ clutter_event_free (ClutterEvent *event)
g_free (event->motion.axes);
break;
case CLUTTER_SCROLL:
g_free (event->scroll.axes);
break;
default:
break;
}