GDK keymap on Haiku

While debugging Remmina, I found that mapping of CTRL and ALT keys (gtk keyvals 65507 and 65513) doesn’t work in GTK apps.

gdk_keymap_get_entries_for_keyval fails to find any mapping for those two keys.

Is the lack of support for CTRL and ALT a known issue on X11/Wayland haiku? Is there a way to fix it?

1 Like

Alt GR is a known issue at least:

Seems similar, because I was under the impression that Remmina did run under Xlibe, but instead I see it depends on Wayland, so I guess it runs on Wayland too like Web/Epiphany

I’m also slightly confused about where GDK gets the keymap from.
For example letter “H” is translated as such

(remmina_protocol_widget_send_keys_signals) - Sending keyval: 104, hardware_keycode: 43

but the keycode 43, is not letter H nor in wayland-server/HaikuSeat.cpp at master · X547/wayland-server · GitHub nor in wayland-server/WaylandKeycodes.h at master · X547/wayland-server · GitHub so I’m not sure what that keycode refers to.

You need to substract 8 from GTK hardware_keycode value.

43 - 8 = 35 (KEY_H). This is some weird libxkbcommon behavior and don’t ask me why, I don’t know.

3 Likes

Ok, I was able to make “Send CTRL+ALT+CANC” work in remmina with following patch.
Previously it did segfault.
I’ll now have to work on a more general purpose solution.

diff --git a/src/remmina_public.c b/src/remmina_public.c
index cdb40a7ae..af793e42d 100644
--- a/src/remmina_public.c
+++ b/src/remmina_public.c
@@ -60,6 +60,7 @@
 #endif
 #include "remmina_public.h"
 #include "remmina/remmina_trace_calls.h"
+#include "remmina_log.h"
 
 GtkWidget*
 remmina_public_create_combo_entry(const gchar *text, const gchar *def, gboolean descending)
@@ -533,9 +534,21 @@ guint16 remmina_public_get_keycode_for_keyval(GdkKeymap *keymap, guint keyval)
        guint16 keycode = 0;
 
        if (gdk_keymap_get_entries_for_keyval(keymap, keyval, &keys, &length)) {
-               keycode = keys[0].keycode;
-               g_free(keys);
+               if(length > 0) {
+                       keycode = keys[0].keycode;
+                       g_free(keys);
+               }
+       }
+
+       if (keycode == 0) {
+               REMMINA_WARNING("Unable to find keycode for %u in %p, trying default", keyval, keymap);
+               if (keyval == 65507)
+                       keycode = 37;
+               else if (keyval == 65513)
+                       keycode = 64;
+               REMMINA_DEBUG("Fallback keymap %u -> %u", keyval, keycode);
        }
+
        return keycode;
 }
1 Like

There’s a similar issue in qemu gtk ui. Ctrl/Alt/Shift doesn’t work.