diff --git a/clutter/clutter-event.h b/clutter/clutter-event.h index 947536461..f0dc8a357 100644 --- a/clutter/clutter-event.h +++ b/clutter/clutter-event.h @@ -192,8 +192,6 @@ typedef enum CLUTTER_STAGE_STATE_ACTIVATED = (1<<3) } ClutterStageState; -typedef union _ClutterEvent ClutterEvent; - typedef struct _ClutterAnyEvent ClutterAnyEvent; typedef struct _ClutterButtonEvent ClutterButtonEvent; typedef struct _ClutterKeyEvent ClutterKeyEvent; diff --git a/clutter/clutter-input-device.c b/clutter/clutter-input-device.c index 1567a41b5..0f93e9329 100644 --- a/clutter/clutter-input-device.c +++ b/clutter/clutter-input-device.c @@ -526,6 +526,25 @@ clutter_input_device_get_pointer_actor (ClutterInputDevice *device) return device->cursor_actor; } +/** + * clutter_input_device_get_pointer_stage: + * @device: a #ClutterInputDevice of type %CLUTTER_POINTER_DEVICE + * + * Retrieves the #ClutterStage underneath the pointer of @device + * + * Return value: (transfer none): a pointer to the #ClutterStage or %NULL + * + * Since: 1.2 + */ +ClutterStage * +clutter_input_device_get_pointer_stage (ClutterInputDevice *device) +{ + g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), NULL); + g_return_val_if_fail (device->device_type == CLUTTER_POINTER_DEVICE, NULL); + + return device->stage; +} + /** * clutter_input_device_get_device_name: * @device: a #ClutterInputDevice @@ -545,3 +564,43 @@ clutter_input_device_get_device_name (ClutterInputDevice *device) return device->device_name; } + +/** + * clutter_input_device_update_from_event: + * @device: a #ClutterInputDevice + * @event: a #ClutterEvent + * @update_stage: whether to update the #ClutterStage of the @device + * using the stage of the event + * + * Forcibly updates the state of the @device using a #ClutterEvent + * + * This function should never be used by applications: it is meant + * for integration with embedding toolkits, like clutter-gtk + * + * Since: 1.2 + */ +void +clutter_input_device_update_from_event (ClutterInputDevice *device, + ClutterEvent *event, + gboolean update_stage) +{ + ClutterModifierType event_state; + ClutterStage *event_stage; + gfloat event_x, event_y; + guint32 event_time; + + g_return_if_fail (CLUTTER_IS_INPUT_DEVICE (device)); + g_return_if_fail (event != NULL); + + event_state = clutter_event_get_state (event); + event_time = clutter_event_get_time (event); + event_stage = clutter_event_get_stage (event); + clutter_event_get_coords (event, &event_x, &event_y); + + _clutter_input_device_set_coords (device, event_x, event_y); + _clutter_input_device_set_state (device, event_state); + _clutter_input_device_set_time (device, event_time); + + if (update_stage) + _clutter_input_device_set_stage (device, event_stage); +} diff --git a/clutter/clutter-input-device.h b/clutter/clutter-input-device.h index 4b8cc9470..85ee592f5 100644 --- a/clutter/clutter-input-device.h +++ b/clutter/clutter-input-device.h @@ -92,8 +92,13 @@ void clutter_input_device_get_device_coords (ClutterInputDevic gint *x, gint *y); ClutterActor * clutter_input_device_get_pointer_actor (ClutterInputDevice *device); +ClutterStage * clutter_input_device_get_pointer_stage (ClutterInputDevice *device); G_CONST_RETURN gchar * clutter_input_device_get_device_name (ClutterInputDevice *device); +void clutter_input_device_update_from_event (ClutterInputDevice *device, + ClutterEvent *event, + gboolean update_stage); + G_END_DECLS #endif /* __CLUTTER_INPUT_DEVICE_H__ */ diff --git a/clutter/clutter-types.h b/clutter/clutter-types.h index 84f364462..119ff1d8a 100644 --- a/clutter/clutter-types.h +++ b/clutter/clutter-types.h @@ -46,6 +46,8 @@ typedef struct _ClutterChildMeta ClutterChildMeta; typedef struct _ClutterLayoutMeta ClutterLayoutMeta; typedef struct _ClutterAnimator ClutterAnimator; +typedef union _ClutterEvent ClutterEvent; + /** * ClutterGravity: * @CLUTTER_GRAVITY_NONE: Do not apply any gravity diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt index 8e3891640..59d61fac2 100644 --- a/doc/reference/clutter/clutter-sections.txt +++ b/doc/reference/clutter/clutter-sections.txt @@ -1005,6 +1005,8 @@ clutter_input_device_get_device_type clutter_input_device_get_device_name clutter_input_device_get_device_coords clutter_input_device_get_pointer_actor +clutter_input_device_get_pointer_stage +clutter_input_device_update_from_event CLUTTER_TYPE_INPUT_DEVICE