From: Zack Marvel Date: Sun, 21 Feb 2021 17:06:13 +0000 (-0700) Subject: ui/gtk: vte: fix sending multiple characeters X-Git-Tag: qemu-xen-4.16.0-rc4~314^2~6 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=8eb13bbbac08aa077efcf9877c9646c4497d766c;p=qemu-xen.git ui/gtk: vte: fix sending multiple characeters When using the GTK UI with libvte, multicharacter keystrokes are not sent correctly (such as arrow keys). gd_vc_in should check the CharBackend's can_receive instead of assuming multiple characters can be received. This is not an issue for e.g. the SDL UI because qemu_chr_be_write is called with len=1 for each character (SDL sends more than once keystroke). Modify gd_vc_in to call qemu_chr_be_write multiple times if necessary. Buglink: https://bugs.launchpad.net/qemu/+bug/1407808 Signed-off-by: Zack Marvel Message-Id: <20210221170613.13183-2-zpmarvel@gmail.com> Signed-off-by: Gerd Hoffmann --- diff --git a/ui/gtk.c b/ui/gtk.c index 79dc240120..bad716f136 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1786,7 +1786,16 @@ static gboolean gd_vc_in(VteTerminal *terminal, gchar *text, guint size, } } - qemu_chr_be_write(vc->vte.chr, (uint8_t *)text, (unsigned int)size); + int remaining = size; + uint8_t* p = (uint8_t *)text; + while (remaining > 0) { + int can_write = qemu_chr_be_can_write(vc->vte.chr); + int written = MIN(remaining, can_write); + qemu_chr_be_write(vc->vte.chr, p, written); + + remaining -= written; + p += written; + } return TRUE; }