Re: [gtk-vnc-devel] May I add the function that gtk-vnc send 'ISO_Left_Tab' keysym to vncserver



On 2008/02/22 23:08, Anthony Liguori wrote:
Hiroyuki Kaguchi wrote:
I could not switch the task with 'Shift+Alt+Tab' when used gvncviewer.
The cause is that gtk-vnc sent a "ISO_Left_Tab" keysym to vncserver .
In the RFB protocol, gtk-vnc should send a shifted Tab rather than "ISO_Left_Tab".
If I make the patch that fix it, could you commit the patch?

Sounds reasonable to me.

Regards,

Anthony Liguori

Thanks
Hiroyuki Kaguchi


This patch changes the key translation.

Signed-off-by: Hiroyuki Kaguchi <fj7025cf aa jp fujitsu com>
diff -r a8cd8a224a10 src/vncdisplay.c
--- a/src/vncdisplay.c	Mon Feb 25 22:03:00 2008 -0500
+++ b/src/vncdisplay.c	Tue Feb 26 16:33:55 2008 +0900
@@ -24,6 +24,7 @@
 #include <sys/stat.h>
 #include <unistd.h>
 #include <pwd.h>
+#include <X11/keysym.h>
 
 #if WITH_GTKGLEXT
 #include <gtk/gtkgl.h>
@@ -135,6 +136,15 @@ static guint signals[LAST_SIGNAL] = { 0,
 				      0, 0, 0, 0,
 				      0, 0, 0, 0, 0,};
 static GParamSpec *signalCredParam;
+
+/* keycode translation for sending ISO_Left_Send 
+ * to vncserver
+ */
+static struct {
+	guint *keycodes;
+	gint n_keycodes;
+	guint keyval;
+} untranslated_keys[] = {{NULL, 0, XK_Tab}};
 
 GtkWidget *vnc_display_new(void)
 {
@@ -535,6 +545,7 @@ static gboolean key_event(GtkWidget *wid
 	guint keyval;
 	gint group, level;
 	GdkModifierType consumed;
+	int k;
 
 	if (priv->gvnc == NULL || !gvnc_is_initialized(priv->gvnc))
 		return TRUE;
@@ -566,6 +577,16 @@ static gboolean key_event(GtkWidget *wid
 					    &group,
 					    &level,
 					    &consumed);
+
+	for (k = 0; k < sizeof(untranslated_keys) / sizeof(untranslated_keys[0]); k++) {
+		if (keyval == untranslated_keys[k].keyval)
+			break;
+
+		if (key->hardware_keycode == untranslated_keys[k].keycodes[0]) {
+			keyval = untranslated_keys[k].keyval;
+			break;
+		}
+	}
 
 	/*
 	 * More VNC suckiness with key state & modifiers in particular
@@ -1586,6 +1607,7 @@ static void vnc_display_finalize (GObjec
 {
 	VncDisplay *display = VNC_DISPLAY (obj);
 	VncDisplayPrivate *priv = display->priv;
+	int i;
 
 	GVNC_DEBUG("Releasing VNC widget\n");
 	if (gvnc_is_open(priv->gvnc)) {
@@ -1616,6 +1638,9 @@ static void vnc_display_finalize (GObjec
 	}
 
 	G_OBJECT_CLASS (vnc_display_parent_class)->finalize (obj);
+
+	for (i = 0; i < sizeof(untranslated_keys) / sizeof(untranslated_keys[0]); i++)
+		g_free(untranslated_keys[i].keycodes);
 }
 
 static void vnc_display_class_init(VncDisplayClass *klass)
@@ -1787,6 +1812,7 @@ static void vnc_display_init(VncDisplay 
 	GtkObject *obj = GTK_OBJECT(display);
 	GtkWidget *widget = GTK_WIDGET(display);
 	VncDisplayPrivate *priv;
+	int i;
 #if WITH_GTKGLEXT
 	static const int attrib[] = { GDK_GL_RGBA,
 				      GDK_GL_RED_SIZE, 1,
@@ -1856,6 +1882,12 @@ static void vnc_display_init(VncDisplay 
 #endif
 
 	priv->gvnc = gvnc_new(&vnc_display_ops, obj);
+
+	for (i = 0; i < sizeof(untranslated_keys) / sizeof(untranslated_keys[0]); i++)
+		gdk_keymap_get_entries_for_keyval(gdk_keymap_get_default(),
+						  untranslated_keys[i].keyval,
+						  &untranslated_keys[i].keycodes,
+						  &untranslated_keys[i].n_keycodes);
 }
 
 static int vnc_display_best_path(char *buf,


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