[gtk/export-key-translation] Export keymap translation again



commit 266a3a5267e5ba043912291879731f14b54a3e6b
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu May 28 15:15:53 2020 -0400

    Export keymap translation again
    
    This is needed in WebKit webdriver test environment.

 docs/reference/gdk/gdk4-sections.txt |  1 +
 gdk/gdkdisplay.c                     | 51 ++++++++++++++++++++++++++++++++++++
 gdk/gdkdisplay.h                     | 10 +++++++
 3 files changed, 62 insertions(+)
---
diff --git a/docs/reference/gdk/gdk4-sections.txt b/docs/reference/gdk/gdk4-sections.txt
index 30b09adea8..763cc45c8f 100644
--- a/docs/reference/gdk/gdk4-sections.txt
+++ b/docs/reference/gdk/gdk4-sections.txt
@@ -102,6 +102,7 @@ gdk_display_setup_window_visual
 <SUBSECTION>
 gdk_display_map_keyval
 gdk_display_map_keycode
+gdk_display_translate_key
 
 <SUBSECTION Standard>
 GDK_DISPLAY
diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c
index 4ba000719d..2994416805 100644
--- a/gdk/gdkdisplay.c
+++ b/gdk/gdkdisplay.c
@@ -1725,3 +1725,54 @@ gdk_display_map_keycode (GdkDisplay    *display,
                                              keyvals,
                                              n_entries);
 }
+
+/**
+ * gdk_display_translate_key:
+ * @display: a #GdkDisplay
+ * @keycode: a keycode
+ * @state: a modifier state
+ * @group: active keyboard group
+ * @keyval: (out) (allow-none): return location for keyval, or %NULL
+ * @effective_group: (out) (allow-none): return location for effective
+ *     group, or %NULL
+ * @level: (out) (allow-none): return location for level, or %NULL
+ * @consumed_modifiers: (out) (allow-none): return location for modifiers
+ *     that were used to determine the group or level, or %NULL
+ *
+ * Translates the contents of a #GdkEventKey (ie @keycode, @state, and @group)
+ * into a keyval, effective group, and level. Modifiers that affected the
+ * translation and are thus unavailable for application use are returned in
+ * @consumed_modifiers.
+ *
+ * The @effective_group is the group that was actually used for the translation;
+ * some keys such as Enter are not affected by the active keyboard group.
+ * The @level is derived from @state.
+ *
+ * @consumed_modifiers gives modifiers that should be masked outfrom @state
+ * when comparing this key press to a keyboard shortcut. For instance, on a US
+ * keyboard, the `plus` symbol is shifted, so when comparing a key press to a
+ * `<Control>plus` accelerator `<Shift>` should be masked out.
+ *
+ * This function should rarely be needed, since #GdkEventKey already contains
+ * the translated keyval. It is exported for the benefit of virtualized test
+ * environments.
+ *
+ * Returns: %TRUE if there was a keyval bound to keycode/state/group.
+ */
+gboolean
+gdk_display_translate_key (GdkDisplay      *display,
+                           guint            keycode,
+                           GdkModifierType  state,
+                           int              group,
+                           guint           *keyval,
+                           int             *effective_group,
+                           int             *level,
+                           GdkModifierType *consumed)
+{
+  return gdk_keymap_translate_keyboard_state (gdk_display_get_keymap (display),
+                                              keycode, state, group,
+                                              keyval,
+                                              effective_group,
+                                              level,
+                                              consumed);
+}
diff --git a/gdk/gdkdisplay.h b/gdk/gdkdisplay.h
index 0a6f6ef2c0..a9b8ed8436 100644
--- a/gdk/gdkdisplay.h
+++ b/gdk/gdkdisplay.h
@@ -123,6 +123,16 @@ gboolean       gdk_display_map_keycode (GdkDisplay    *display,
                                         guint        **keyvals,
                                         int           *n_entries);
 
+GDK_AVAILABLE_IN_ALL
+gboolean       gdk_display_translate_key (GdkDisplay      *display,
+                                          guint            keycode,
+                                          GdkModifierType  state,
+                                          int              group,
+                                          guint           *keyval,
+                                          int             *effective_group,
+                                          int             *level,
+                                          GdkModifierType *consumed);
+
 GDK_AVAILABLE_IN_ALL
 gboolean     gdk_display_get_setting (GdkDisplay *display,
                                       const char *name,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]