Merge branch 'ebassi/for-master' into 'master'

Ebassi/for master

Closes #2783

See merge request GNOME/gtk!1962
This commit is contained in:
Matthias Clasen 2020-05-26 01:35:11 +00:00
commit ddf6138d07
4 changed files with 34 additions and 5 deletions

View File

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

View File

@ -612,6 +612,9 @@ GdkEvent * gdk_grab_broken_event_new (GdkSurface *surface,
GdkSurface *grab_surface,
gboolean implicit);
GdkTranslatedKey * gdk_key_event_get_translated_key (GdkEvent *event,
gboolean no_lock);
G_END_DECLS
#endif /* __GDK_EVENTS_PRIVATE_H__ */

View File

@ -939,6 +939,7 @@ gtk_accelerator_print_label (GString *gstring,
if (accelerator_key >= GDK_KEY_KP_Space &&
accelerator_key <= GDK_KEY_KP_Equal)
{
/* Translators: "KP" means "numeric key pad" */
g_string_append (gstring, C_("keyboard label", "KP"));
g_string_append (gstring, "");
}

View File

@ -1244,8 +1244,8 @@ static GdkEvent *
rewrite_event_for_toplevel (GdkEvent *event)
{
GdkSurface *surface;
GdkKeyEvent *key_event;
GdkEventType event_type;
GdkTranslatedKey *key, *key_no_lock;
surface = gdk_event_get_surface (event);
if (!surface->parent)
@ -1259,9 +1259,9 @@ rewrite_event_for_toplevel (GdkEvent *event)
while (surface->parent)
surface = surface->parent;
key_event = (GdkKeyEvent *) event;
key = gdk_key_event_get_translated_key (event, FALSE);
key_no_lock = gdk_key_event_get_translated_key (event, TRUE);
/* FIXME: Avoid direct access to the translated[] field */
return gdk_key_event_new (gdk_event_get_event_type (event),
surface,
gdk_event_get_device (event),
@ -1270,8 +1270,7 @@ rewrite_event_for_toplevel (GdkEvent *event)
gdk_key_event_get_keycode (event),
gdk_event_get_modifier_state (event),
gdk_key_event_is_modifier (event),
&key_event->translated[0],
&key_event->translated[1]);
key, key_no_lock);
}
static gboolean