clutter: Add clutter_event_get_key_state() getter

This function may be used on key events to obtain the fully
detailed pressed/latched/locked modifiers that apply when the
event is received. No events have this detailed information
yet.

This API call may be compared to the clutter_event_get_state_full()
that existed in the past, although this getter has a stronger
predilection to it applying exclusively to key events.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3369>
This commit is contained in:
Carlos Garnacho 2023-11-06 11:38:34 +01:00 committed by Marge Bot
parent 61de313198
commit 2e897fccd5
3 changed files with 45 additions and 0 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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);