summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorTingPing <tingping@tingping.se>2015-02-01 16:37:27 -0500
committerTingPing <tingping@tingping.se>2015-02-02 02:56:08 -0500
commitafee9fd42b95274d71c76351349b9bf2090632c5 (patch)
treec5d292f2d9bae061f75196716be924ebbcbc054d
parent60fa7efbc861cc6b6d6ff0f619a16ed79025cb12 (diff)
Only send utf8 string in Key Press event
Fixes #869
-rw-r--r--src/common/plugin.c13
-rw-r--r--src/common/plugin.h2
-rw-r--r--src/fe-gtk/fkeys.c2
3 files changed, 11 insertions, 6 deletions
diff --git a/src/common/plugin.c b/src/common/plugin.c
index 9a1efbec..d2782e01 100644
--- a/src/common/plugin.c
+++ b/src/common/plugin.c
@@ -659,26 +659,31 @@ plugin_emit_dummy_print (session *sess, char *name)
 }
 
 int
-plugin_emit_keypress (session *sess, unsigned int state, unsigned int keyval,
-							 int len, char *string)
+plugin_emit_keypress (session *sess, unsigned int state, unsigned int keyval, gunichar key)
 {
 	char *word[PDIWORDS];
 	char keyval_str[16];
 	char state_str[16];
 	char len_str[16];
-	int i;
+	char key_str[7];
+	int i, len;
 
 	if (!hook_list)
 		return 0;
 
 	sprintf (keyval_str, "%u", keyval);
 	sprintf (state_str, "%u", state);
+	if (!key)
+		len = 0;
+	else
+		len = g_unichar_to_utf8 (key, key_str);
+	key_str[len] = '\0';
 	sprintf (len_str, "%d", len);
 
 	word[0] = "Key Press";
 	word[1] = keyval_str;
 	word[2] = state_str;
-	word[3] = string;
+	word[3] = key_str;
 	word[4] = len_str;
 	for (i = 5; i < PDIWORDS; i++)
 		word[i] = "\000";
diff --git a/src/common/plugin.h b/src/common/plugin.h
index cd3f70a8..db0054cb 100644
--- a/src/common/plugin.h
+++ b/src/common/plugin.h
@@ -174,7 +174,7 @@ int plugin_emit_server (session *sess, char *name, char *word[], char *word_eol[
 						time_t server_time);
 int plugin_emit_print (session *sess, char *word[], time_t server_time);
 int plugin_emit_dummy_print (session *sess, char *name);
-int plugin_emit_keypress (session *sess, unsigned int state, unsigned int keyval, int len, char *string);
+int plugin_emit_keypress (session *sess, unsigned int state, unsigned int keyval, gunichar key);
 GList* plugin_command_list(GList *tmp_list);
 int plugin_show_help (session *sess, char *cmd);
 void plugin_command_foreach (session *sess, void *userdata, void (*cb) (session *sess, void *userdata, char *name, char *usage));
diff --git a/src/fe-gtk/fkeys.c b/src/fe-gtk/fkeys.c
index 38e991cb..553c7447 100644
--- a/src/fe-gtk/fkeys.c
+++ b/src/fe-gtk/fkeys.c
@@ -322,7 +322,7 @@ key_handle_key_press (GtkWidget *wid, GdkEventKey *evt, session *sess)
 		return FALSE;
 	current_sess = sess;
 
-	if (plugin_emit_keypress (sess, evt->state, evt->keyval, evt->length, evt->string))
+	if (plugin_emit_keypress (sess, evt->state, evt->keyval, gdk_keyval_to_unicode (evt->keyval)))
 		return 1;
 
 	/* maybe the plugin closed this tab? */