diff --git a/clutter/clutter/clutter-event-private.h b/clutter/clutter/clutter-event-private.h index dd4d3420a..4edeb5be4 100644 --- a/clutter/clutter/clutter-event-private.h +++ b/clutter/clutter/clutter-event-private.h @@ -4,6 +4,15 @@ G_BEGIN_DECLS +typedef struct _ClutterModifierSet ClutterModifierSet; + +struct _ClutterModifierSet +{ + ClutterModifierType pressed; + ClutterModifierType latched; + ClutterModifierType locked; +}; + CLUTTER_EXPORT ClutterEvent * clutter_event_key_new (ClutterEventType type, ClutterEventFlags flags, diff --git a/clutter/clutter/clutter-event.c b/clutter/clutter/clutter-event.c index 8e258f7ea..2e66fe560 100644 --- a/clutter/clutter/clutter-event.c +++ b/clutter/clutter/clutter-event.c @@ -51,6 +51,7 @@ struct _ClutterKeyEvent ClutterInputDevice *device; ClutterInputDevice *source_device; + ClutterModifierSet raw_modifiers; ClutterModifierType modifier_state; uint32_t keyval; uint16_t hardware_keycode; @@ -695,6 +696,36 @@ clutter_event_get_key_unicode (const ClutterEvent *event) return clutter_keysym_to_unicode (event->key.keyval); } +/** + * clutter_event_get_key_state: + * @event: a #ClutterEvent of type %CLUTTER_KEY_PRESS + * or %CLUTTER_KEY_RELEASE + * @pressed: (out): Return location for pressed modifiers + * @latched: (out): Return location for latched modifiers + * @locked: (out): Return location for locked modifiers + * + * Returns the modifier state decomposed into independent + * pressed/latched/locked states. The effective state is a + * composition of these 3 states, see clutter_event_get_state(). + **/ +void +clutter_event_get_key_state (const ClutterEvent *event, + ClutterModifierType *pressed, + ClutterModifierType *latched, + ClutterModifierType *locked) +{ + g_return_if_fail (event != NULL); + g_return_if_fail (event->type == CLUTTER_KEY_PRESS || + event->type == CLUTTER_KEY_RELEASE); + + if (pressed) + *pressed = event->key.raw_modifiers.pressed; + if (latched) + *latched = event->key.raw_modifiers.latched; + if (locked) + *locked = event->key.raw_modifiers.locked; +} + /** * clutter_event_get_event_sequence: * @event: a #ClutterEvent of type %CLUTTER_TOUCH_BEGIN, diff --git a/clutter/clutter/clutter-event.h b/clutter/clutter/clutter-event.h index 92a07b205..81f489b19 100644 --- a/clutter/clutter/clutter-event.h +++ b/clutter/clutter/clutter-event.h @@ -205,6 +205,11 @@ guint16 clutter_event_get_key_code (const ClutterEv CLUTTER_EXPORT gunichar clutter_event_get_key_unicode (const ClutterEvent *event); CLUTTER_EXPORT +void clutter_event_get_key_state (const ClutterEvent *event, + ClutterModifierType *pressed, + ClutterModifierType *latched, + ClutterModifierType *locked); +CLUTTER_EXPORT guint32 clutter_event_get_button (const ClutterEvent *event); CLUTTER_EXPORT ClutterActor * clutter_event_get_related (const ClutterEvent *event);