[gtk-vnc] Remove uneccessarily generic handling of shifted tab key



commit 579940d95dd7b9bb8e834ffbb10da444cf26d5c0
Author: Daniel P. Berrange <berrange redhat com>
Date:   Tue Aug 8 16:35:50 2017 +0100

    Remove uneccessarily generic handling of shifted tab key
    
    Signed-off-by: Daniel P. Berrange <berrange redhat com>

 src/vncdisplay.c       |   20 ++++++++++++----
 src/vncdisplaykeymap.c |   56 ------------------------------------------------
 src/vncdisplaykeymap.h |    3 --
 3 files changed, 15 insertions(+), 64 deletions(-)
---
diff --git a/src/vncdisplay.c b/src/vncdisplay.c
index a7008ca..2fdc13c 100644
--- a/src/vncdisplay.c
+++ b/src/vncdisplay.c
@@ -968,6 +968,14 @@ static gboolean check_for_grab_key(GtkWidget *widget, int type, int keyval)
 }
 
 
+/* Compatability code to allow build on Gtk2 and Gtk3 */
+#ifndef GDK_Tab
+#define GDK_Tab GDK_KEY_Tab
+#endif
+#ifndef GDK_ISO_Left_Tab
+#define GDK_ISO_Left_Tab GDK_KEY_ISO_Left_Tab
+#endif
+
 static gboolean key_event(GtkWidget *widget, GdkEventKey *key)
 {
     VncDisplayPrivate *priv = VNC_DISPLAY(widget)->priv;
@@ -997,7 +1005,13 @@ static gboolean key_event(GtkWidget *widget, GdkEventKey *key)
     }
 #endif
 
-    keyval = vnc_display_keyval_from_keycode(key->hardware_keycode, keyval);
+    /* VNC servers don't want to get an ISO_Left_Tab.
+     * They need the Tab key and will apply the
+     * Shift modifier themselves
+     */
+    if (keyval == GDK_ISO_Left_Tab) {
+        keyval = GDK_Tab;
+    }
 
     /*
      * Some VNC suckiness with key state & modifiers in particular
@@ -2136,8 +2150,6 @@ static void vnc_display_finalize (GObject *obj)
     g_slist_free (priv->preferable_auths);
     g_slist_free (priv->preferable_vencrypt_subauths);
 
-    vnc_display_keyval_free_entries();
-
     G_OBJECT_CLASS (vnc_display_parent_class)->finalize (obj);
 }
 
@@ -2507,8 +2519,6 @@ static void vnc_display_init(VncDisplay *display)
 
     gtk_widget_set_can_focus (widget, TRUE);
 
-    vnc_display_keyval_set_entries();
-
     gtk_widget_add_events(widget,
                           GDK_POINTER_MOTION_MASK |
                           GDK_BUTTON_PRESS_MASK |
diff --git a/src/vncdisplaykeymap.c b/src/vncdisplaykeymap.c
index 58e3f11..04a8329 100644
--- a/src/vncdisplaykeymap.c
+++ b/src/vncdisplaykeymap.c
@@ -18,22 +18,6 @@
 #include "vncutil.h"
 
 
-/* Compatability code to allow build on Gtk2 and Gtk3 */
-#ifndef GDK_Tab
-#define GDK_Tab GDK_KEY_Tab
-#endif
-
-/* keycode translation for sending ISO_Left_Send
- * to vncserver
- */
-static struct {
-    GdkKeymapKey *keys;
-    gint n_keys;
-    guint keyval;
-} untranslated_keys[] = {{NULL, 0, GDK_Tab}};
-
-static unsigned int ref_count_for_untranslated_keys = 0;
-
 #ifdef GDK_WINDOWING_WAYLAND
 #include <gdk/gdkwayland.h>
 #endif
@@ -257,46 +241,6 @@ guint16 vnc_display_keymap_gdk2rfb(const guint16 *keycode_map,
     return keycode_map[keycode];
 }
 
-/* Set the keymap entries */
-void vnc_display_keyval_set_entries(void)
-{
-    size_t i;
-    if (ref_count_for_untranslated_keys == 0)
-        for (i = 0; i < G_N_ELEMENTS(untranslated_keys); i++)
-            gdk_keymap_get_entries_for_keyval(gdk_keymap_get_default(),
-                                              untranslated_keys[i].keyval,
-                                              &untranslated_keys[i].keys,
-                                              &untranslated_keys[i].n_keys);
-    ref_count_for_untranslated_keys++;
-}
-
-/* Free the keymap entries */
-void vnc_display_keyval_free_entries(void)
-{
-    size_t i;
-
-    if (ref_count_for_untranslated_keys == 0)
-        return;
-
-    ref_count_for_untranslated_keys--;
-    if (ref_count_for_untranslated_keys == 0)
-        for (i = 0; i < G_N_ELEMENTS(untranslated_keys); i++)
-            g_free(untranslated_keys[i].keys);
-
-}
-
-/* Get the keyval from the keycode without the level. */
-guint vnc_display_keyval_from_keycode(guint keycode, guint keyval)
-{
-    size_t i;
-    for (i = 0; i < G_N_ELEMENTS(untranslated_keys); i++) {
-        if (keycode == untranslated_keys[i].keys[0].keycode) {
-            return untranslated_keys[i].keyval;
-        }
-    }
-
-    return keyval;
-}
 /*
  * Local variables:
  *  c-indent-level: 4
diff --git a/src/vncdisplaykeymap.h b/src/vncdisplaykeymap.h
index 57fdad0..007e756 100644
--- a/src/vncdisplaykeymap.h
+++ b/src/vncdisplaykeymap.h
@@ -28,9 +28,6 @@ const guint16 *vnc_display_keymap_gdk2rfb_table(size_t *maplen);
 guint16 vnc_display_keymap_gdk2rfb(const guint16 *keycode_map,
                                    size_t keycode_maplen,
                                    guint16 keycode);
-void vnc_display_keyval_set_entries(void);
-void vnc_display_keyval_free_entries(void);
-guint vnc_display_keyval_from_keycode(guint keycode, guint keyval);
 
 #endif /* VNC_DISPLAY_KEYMAP_H */
 /*


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