[gtk+] [broadway] Emulate hardware keycodes in keyboard events



commit 01da867dac948205f10c4ccfd924a2958ad3c749
Author: Alexander Larsson <alexl redhat com>
Date:   Thu Apr 14 21:13:28 2011 +0200

    [broadway] Emulate hardware keycodes in keyboard events
    
    We can't really know the client side keymaps, so we use the keysym
    as the hardware keycode (essentially claiming to have a keyboard with
    one key for all possible keysyms). This is not ideal, but its hard to
    do better with no knowledge of the client side keyboard mappings.
    (And html keyboard events suck badly...)

 gdk/broadway/gdkeventsource.c   |    1 +
 gdk/broadway/gdkkeys-broadway.c |   38 +++++++++++++++++++++++++++++++-------
 2 files changed, 32 insertions(+), 7 deletions(-)
---
diff --git a/gdk/broadway/gdkeventsource.c b/gdk/broadway/gdkeventsource.c
index a2864da..e7f8574 100644
--- a/gdk/broadway/gdkeventsource.c
+++ b/gdk/broadway/gdkeventsource.c
@@ -259,6 +259,7 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
 	event->key.window = g_object_ref (window);
 	event->key.time = message->base.time;
 	event->key.keyval = message->key.key;
+	event->key.hardware_keycode = message->key.key;
 	event->key.length = 0;
 	gdk_event_set_device (event, display->core_pointer);
 
diff --git a/gdk/broadway/gdkkeys-broadway.c b/gdk/broadway/gdkkeys-broadway.c
index 1d5f41a..48d5158 100644
--- a/gdk/broadway/gdkkeys-broadway.c
+++ b/gdk/broadway/gdkkeys-broadway.c
@@ -119,8 +119,15 @@ gdk_broadway_keymap_get_entries_for_keyval (GdkKeymap     *keymap,
 					    GdkKeymapKey **keys,
 					    gint          *n_keys)
 {
-  *n_keys = 0;
-  return FALSE;
+  if (n_keys)
+    *n_keys = 1;
+  if (keys)
+    {
+      *keys = g_new0 (GdkKeymapKey, 1);
+      (*keys)->keycode = keyval;
+    }
+
+  return TRUE;
 }
 
 static gboolean
@@ -130,15 +137,26 @@ gdk_broadway_keymap_get_entries_for_keycode (GdkKeymap     *keymap,
 					     guint        **keyvals,
 					     gint          *n_entries)
 {
-  *n_entries = 0;
-  return FALSE;
+  if (n_entries)
+    *n_entries = 1;
+  if (keys)
+    {
+      *keys = g_new0 (GdkKeymapKey, 1);
+      (*keys)->keycode = hardware_keycode;
+    }
+  if (keyvals)
+    {
+      *keyvals = g_new0 (guint, 1);
+      (*keyvals)[0] = hardware_keycode;
+    }
+  return TRUE;
 }
 
 static guint
 gdk_broadway_keymap_lookup_key (GdkKeymap          *keymap,
 				const GdkKeymapKey *key)
 {
-  return 0;
+  return key->keycode;
 }
 
 
@@ -152,7 +170,13 @@ gdk_broadway_keymap_translate_keyboard_state (GdkKeymap       *keymap,
 					      gint            *level,
 					      GdkModifierType *consumed_modifiers)
 {
-  return FALSE;
+  if (keyval)
+    *keyval = hardware_keycode;
+  if (effective_group)
+    *effective_group = 0;
+  if (level)
+    *level = 0;
+  return TRUE;
 }
 
 static void
@@ -165,7 +189,7 @@ static gboolean
 gdk_broadway_keymap_map_virtual_modifiers (GdkKeymap       *keymap,
 					   GdkModifierType *state)
 {
-  return FALSE;
+  return TRUE;
 }
 
 static void



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