[libhandy] preferences-window: Translate keyval properly



commit d853ab999a800002d22f60ffa0737bb4e28faa35
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Fri Aug 14 17:27:42 2020 +0500

    preferences-window: Translate keyval properly
    
    See 
https://developer.gnome.org/gdk3/stable/gdk3-Keyboard-Handling.html#gdk-keymap-translate-keyboard-state
    
    Fixes https://gitlab.gnome.org/GNOME/libhandy/-/issues/332
    
    Signed-off-by: Alexander Mikhaylenko <alexm gnome org>

 src/hdy-preferences-window.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/src/hdy-preferences-window.c b/src/hdy-preferences-window.c
index 3618d580..d89fb822 100644
--- a/src/hdy-preferences-window.c
+++ b/src/hdy-preferences-window.c
@@ -209,13 +209,22 @@ key_press_event_cb (GtkWidget            *sender,
   GdkModifierType default_modifiers = gtk_accelerator_get_default_mod_mask ();
   guint keyval;
   GdkModifierType state;
+  GdkKeymap *keymap;
+  GdkEventKey *key_event = (GdkEventKey *) event;
 
   if (priv->subpage)
     return GDK_EVENT_PROPAGATE;
 
-  gdk_event_get_keyval (event, &keyval);
   gdk_event_get_state (event, &state);
 
+  keymap = gdk_keymap_get_for_display (gtk_widget_get_display (sender));
+
+  gdk_keymap_translate_keyboard_state (keymap,
+                                       key_event->hardware_keycode,
+                                       state,
+                                       key_event->group,
+                                       &keyval, NULL, NULL, NULL);
+
   if (priv->search_enabled &&
       (keyval == GDK_KEY_f || keyval == GDK_KEY_F) &&
       (state & default_modifiers) == GDK_CONTROL_MASK) {


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