diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2020-05-22 12:35:58 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2020-05-24 15:19:01 +0100 |
commit | 0cf5b66e7b0fda0857f18be602184e2891d9b6ae (patch) | |
tree | 4ce954af524e29bd46881f517cc2f2b0040cb16a /gdk/gdkevents.c | |
parent | be8fc8f26b974c0972a4e24d741c78ea3012fb93 (diff) | |
download | gtk+-0cf5b66e7b0fda0857f18be602184e2891d9b6ae.tar.gz |
Add private accessor for GdkKeyEvent.translated
Avoid accessing the event structure directly, even from within GTK.
Diffstat (limited to 'gdk/gdkevents.c')
-rw-r--r-- | gdk/gdkevents.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c index 5495d5e6ca..cc26f2f085 100644 --- a/gdk/gdkevents.c +++ b/gdk/gdkevents.c @@ -1466,6 +1466,32 @@ gdk_key_event_new (GdkEventType type, return event; } +/*< private > + * gdk_key_event_get_translated_key: + * @event: (type GdkKeyEvent): a key event + * @no_lock: whether the translated key should take the event + * state into account + * + * Extracts the translated key from a key event. + * + * Returns: (transfer none): the translated key + */ +GdkTranslatedKey * +gdk_key_event_get_translated_key (GdkEvent *event, + gboolean no_lock) +{ + GdkKeyEvent *self = (GdkKeyEvent *) event; + + g_return_val_if_fail (GDK_IS_EVENT (event), NULL); + g_return_val_if_fail (GDK_IS_EVENT_TYPE (event, GDK_KEY_PRESS) || + GDK_IS_EVENT_TYPE (event, GDK_KEY_RELEASE), NULL); + + if (no_lock) + return &(self->translated[1]); + + return &(self->translated[0]); +} + /** * gdk_key_event_get_keyval: * @event: (type GdkKeyEvent): a key event |