Skip to contentSkip to conversation

ui/gtk: Fix non-working DELETE key

PATCH In review Thomas Huth 2 participants 2 messages Oct 27, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ui/gtk: Fix non-working DELETE key

GTK generates key events for the delete key with key->string[0] = 0x7f ... but this does not work right with the readline_handle_byte() function in util/readline.c, since this treats the keycode 127 as backspace. So let's add a special case for the GTK delete key to make this key behave right in the monitor interface of the GTK ui.

---
 ui/gtk.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
ui/gtk.c +3 -1
index 25e6d99..ab280e4 100644
@@ -1051,7 +1051,9 @@ static gboolean gd_text_key_down(GtkWidget *widget,
     VirtualConsole *vc = opaque;
     QemuConsole *con = vc->gfx.dcl.con;
 
-    if (key->length) {
+    if (key->keyval == GDK_KEY_Delete) {
+        kbd_put_qcode_console(con, Q_KEY_CODE_DELETE);
+    } else if (key->length) {
         kbd_put_string_console(con, key->string, key->length);
     } else {
         int num = gd_map_keycode(vc->s, gtk_widget_get_display(widget),
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 5 lines · Thomas Huth

GTK generates key events for the delete key with key->string[0] = 0x7f ... but this does not work right with the readline_handle_byte() function in util/readline.c, since this treats the keycode 127 as backspace. So let's add a special case for the GTK delete key to make this key behave right in the monitor interface of the GTK ui.

added to ui queue.

thanks,
Gerd