All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ui/gtk: vte: fix sending multiple characeters
@ 2021-02-21 16:52 Zack Marvel
  2021-02-21 16:57 ` no-reply
  0 siblings, 1 reply; 5+ messages in thread
From: Zack Marvel @ 2021-02-21 16:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Zack Marvel, Gerd Hoffmann

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).

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..0311d7d64b 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



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] ui/gtk: vte: fix sending multiple characeters
  2021-02-21 16:52 [PATCH] ui/gtk: vte: fix sending multiple characeters Zack Marvel
@ 2021-02-21 16:57 ` no-reply
  2021-02-21 17:06   ` Zack Marvel
  0 siblings, 1 reply; 5+ messages in thread
From: no-reply @ 2021-02-21 16:57 UTC (permalink / raw)
  To: zpmarvel; +Cc: qemu-trivial, zpmarvel, qemu-devel, kraxel

Patchew URL: https://patchew.org/QEMU/20210221165219.12744-1-zpmarvel@gmail.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 20210221165219.12744-1-zpmarvel@gmail.com
Subject: [PATCH] ui/gtk: vte: fix sending multiple characeters

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag]         patchew/20210221165219.12744-1-zpmarvel@gmail.com -> patchew/20210221165219.12744-1-zpmarvel@gmail.com
Switched to a new branch 'test'
033e3de ui/gtk: vte: fix sending multiple characeters

=== OUTPUT BEGIN ===
ERROR: "(foo*)" should be "(foo *)"
#32: FILE: ui/gtk.c:1790:
+    uint8_t* p = (uint8_t*)text;

total: 1 errors, 0 warnings, 17 lines checked

Commit 033e3de379a7 (ui/gtk: vte: fix sending multiple characeters) has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/20210221165219.12744-1-zpmarvel@gmail.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ui/gtk: vte: fix sending multiple characeters
  2021-02-21 16:57 ` no-reply
@ 2021-02-21 17:06   ` Zack Marvel
  2021-02-21 17:06     ` Zack Marvel
  0 siblings, 1 reply; 5+ messages in thread
From: Zack Marvel @ 2021-02-21 17:06 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Gerd Hoffmann

Sorry for the noise. Fixed coding style issue.




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] ui/gtk: vte: fix sending multiple characeters
  2021-02-21 17:06   ` Zack Marvel
@ 2021-02-21 17:06     ` Zack Marvel
  2021-02-22 11:39       ` Gerd Hoffmann
  0 siblings, 1 reply; 5+ messages in thread
From: Zack Marvel @ 2021-02-21 17:06 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Zack Marvel, Gerd Hoffmann

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



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] ui/gtk: vte: fix sending multiple characeters
  2021-02-21 17:06     ` Zack Marvel
@ 2021-02-22 11:39       ` Gerd Hoffmann
  0 siblings, 0 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2021-02-22 11:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Zack Marvel

On Sun, Feb 21, 2021 at 10:06:13AM -0700, Zack Marvel wrote:
> 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>

Added to ui patch queue.

thanks,
  Gerd



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-02-22 11:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-21 16:52 [PATCH] ui/gtk: vte: fix sending multiple characeters Zack Marvel
2021-02-21 16:57 ` no-reply
2021-02-21 17:06   ` Zack Marvel
2021-02-21 17:06     ` Zack Marvel
2021-02-22 11:39       ` Gerd Hoffmann

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.