From: Zack Marvel <zpmarvel@gmail.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>,
qemu-trivial@nongnu.org, Zack Marvel <zpmarvel@gmail.com>
Subject: [PATCH] ui/gtk: vte: fix sending multiple characeters
Date: Sun, 21 Feb 2021 10:06:13 -0700 [thread overview]
Message-ID: <20210221170613.13183-2-zpmarvel@gmail.com> (raw)
In-Reply-To: <20210221170613.13183-1-zpmarvel@gmail.com>
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 <zpmarvel@gmail.com>
---
ui/gtk.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
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;
}
--
2.20.1
WARNING: multiple messages have this Message-ID (diff)
From: Zack Marvel <zpmarvel@gmail.com>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, Zack Marvel <zpmarvel@gmail.com>,
Gerd Hoffmann <kraxel@redhat.com>
Subject: [PATCH] ui/gtk: vte: fix sending multiple characeters
Date: Sun, 21 Feb 2021 10:06:13 -0700 [thread overview]
Message-ID: <20210221170613.13183-2-zpmarvel@gmail.com> (raw)
In-Reply-To: <20210221170613.13183-1-zpmarvel@gmail.com>
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 <zpmarvel@gmail.com>
---
ui/gtk.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
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;
}
--
2.20.1
next prev parent reply other threads:[~2021-02-21 17:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-21 16:52 [PATCH] ui/gtk: vte: fix sending multiple characeters Zack Marvel
2021-02-21 16:52 ` Zack Marvel
2021-02-21 16:57 ` no-reply
2021-02-21 16:57 ` no-reply
2021-02-21 17:06 ` Zack Marvel
2021-02-21 17:06 ` Zack Marvel
2021-02-21 17:06 ` Zack Marvel [this message]
2021-02-21 17:06 ` Zack Marvel
2021-02-22 11:39 ` Gerd Hoffmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210221170613.13183-2-zpmarvel@gmail.com \
--to=zpmarvel@gmail.com \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.