> It seems the Windows gVim build (7.2.267) is not affected of this
> issue. All the examples above works well with this langmap:

Yes, I think the issue is in gtk+ behavior. (I even think it's not bug but a 
feature since, in general, it allows using sequences like ^<russian letter>).

I've looked through geany sources and have found nothing concerning keymaps.

Geany works because its keybindings are set via gtk accelerators and the
layouts are processed inside gtk.

But in gtk the task is somewhat different from what we need. In gtk the
bindings are known and when a key is pressed we just have to compare the new
key with all registered accelerators to find the actual one.

In gvim we have to translate the pressed key without knowing whether the key is
registered in gvim (and gvim knows how to process it) or not, so we have to go
another way.

The patch below fixes the issue for me.

In the patch we use gdk_keymap_translate_keyboard_state() just to know the
current level, and then use gdk_keymap_get_entries_for_keycode() to get the
list of keys and keyvals with the same keycode as the pressed key. Then we just
use the first key with the same level as the pressed one, from range 0x20 to
0x7f.

Can it be commited to vim repository?

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
diff -Napur vim72.orig/src/gui_gtk_x11.c vim72/src/gui_gtk_x11.c
--- vim72.orig/src/gui_gtk_x11.c	2010-06-18 00:22:25.000000000 +0400
+++ vim72/src/gui_gtk_x11.c	2010-06-18 00:21:34.000000000 +0400
@@ -993,8 +993,36 @@ key_press_event(GtkWidget *widget UNUSED
     guint	state;
     char_u	*s, *d;
 
+#ifdef HAVE_GTK2
+    gint n_entries;
+    GdkModifierType consumed;
+    guint *keyvals;
+    gint level;
+    GdkKeymapKey *keys;
+#endif
+
     key_sym = event->keyval;
     state = event->state;
+
+#ifdef HAVE_GTK2
+    if (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_MOD4_MASK)
+        && gdk_keymap_translate_keyboard_state (NULL, event->hardware_keycode,
+                                                event->state, event->group,
+                                                NULL, NULL, &level, &consumed)
+        && gdk_keymap_get_entries_for_keycode (NULL, event->hardware_keycode,
+                                               &keys, &keyvals, &n_entries))
+    {
+        for (i = 0; i < n_entries; i++)
+            if (level == keys[i].level
+                && keyvals[i] >= 0x20 && keyvals[i] < 0x80)
+            {
+                key_sym = keyvals[i];
+                state = event->state & ~consumed;
+                break;
+            }
+    }
+#endif
+
 #ifndef HAVE_GTK2 /* deprecated */
     len = event->length;
     g_assert(len <= sizeof(string));

Raspunde prin e-mail lui