Received: from eggs.gnu.org ([2001:4830:134:3::10]:35773) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XRCCj-000162-CL for qemu-devel@nongnu.org; Mon, 08 Sep 2014 23:34:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XRCCe-0001gl-Jq for qemu-devel@nongnu.org; Mon, 08 Sep 2014 23:34:53 -0400 Received: from soto.provo.novell.com ([137.65.250.214]:42550) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XRCCe-0001gF-Cu for qemu-devel@nongnu.org; Mon, 08 Sep 2014 23:34:48 -0400 Message-Id: <540EE5CD020000660005EE1D@soto.provo.novell.com> Date: Mon, 08 Sep 2014 21:34:37 -0600 From: "Chun Yan Liu" References: <1409886863-6124-1-git-send-email-cyliu@suse.com> In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Subject: Re: [Qemu-devel] [PATCH] vnc: add additional key up event before repeated key down List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: stefano.stabellini@eu.citrix.com Cc: qemu-devel@nongnu.org, xen-devel@lists.xen.org >>> On 9/6/2014 at 05:23 AM, in message , Stefano Stabellini wrote:=20 > On Fri, 5 Sep 2014, Chunyan Liu wrote:=20 > > Using xen tools 'xl vncviewer' with tigervnc (default on SLE-12),=20 > > found that: the display of the guest is unexpected while keep=20 > > pressing a key. We expect the same character multiple times, but=20 > > it prints only one time. This happens on a PV guest in text mode.=20 > > =20 > > After debugging, found that tigervnc sends repeated key down events=20 > > in this case, to differentiate from user pressing the same key many=20 > > times. Vnc server only prints the character when it finally receives=20= > > key up event.=20 > =20 > Is this actually how a vnc client should behave?=20 > How do the vnc client and server from realvnc behave in this regard=20 > (they are the reference implementation)?=20 VNC protocol doesn't specify how to handle key repetition. Tightvnc sends key-down&key-up repeatedly, but some example like RealVNC for Windows does the same thing - it sends only repeated key-down. Generally the VNC keyboard handling gives lot of space for interpretation and so the implementations differ. > =20 > =20 > > To solve this issue, this patch tries to add additional key up = event=20 > > before the next repeated key down event (if the key is not a control=20= > > key).=20 > > =20 > > Signed-off-by: Chunyan Liu =20 > > ---=20 > > ui/vnc.c | 19 +++++++++++++++++++=20 > > 1 file changed, 19 insertions(+)=20 > > =20 > > diff --git a/ui/vnc.c b/ui/vnc.c=20 > > index f8d9b7d..a265378 100644=20 > > --- a/ui/vnc.c=20 > > +++ b/ui/vnc.c=20 > > @@ -1659,6 +1659,25 @@ static void do_key_event(VncState *vs, int = down, int =20 > keycode, int sym)=20 > > if (down)=20 > > vs->modifiers_state[keycode] ^=3D 1;=20 > > break;=20 > > + default:=20 > > + if (qemu_console_is_graphic(NULL)) {=20 > > + /* record key 'down' info. Some client like tigervnc=20 > > + * will send key down repeatedly if user pressing a=20 > > + * a key for long time. In this case, we should add=20 > > + * additional key up event before repeated key down,=20 > > + * so that it can display the key multiple times.=20 > > + */=20 > > + if (down) {=20 > > + if (vs->modifiers_state[keycode]) {=20 > > + /* add a key up event */=20 > > + do_key_event(vs, 0, keycode, sym);=20 > > + }=20 > > + vs->modifiers_state[keycode] =3D 1;=20 > > + } else {=20 > > + vs->modifiers_state[keycode] =3D 0;=20 > > + }=20 > =20 > I am not 100% convinced that we have to fix this in QEMU, but if we = do=20 > then this doesn't look like the right fix: the switch statement that = you=20 > are modifying is for QEMU console switches. > Also if I am not mistaken=20 > modifiers_state is meant for control keys, not regular keys.=20 Yes, you are right. Currently modifiers_state is used for control keys, = and key-down info is not recorded. I just want to reuse modifiers_state to record the key-down info. Since control key and regular key have different keycodes, that won't affect control key handling. > =20 > At the very least you could move the change below, near the call to=20 > qemu_input_event_send_key_number.=20 Could change there too, but need to check the keycode again: only regular = key needs the change, control key should not be changed. So I just move the = change ahead in the switch. > =20 > =20 > > + }=20 > > + break;=20 > > }=20 > > =20 > > /* Turn off the lock state sync logic if the client support the = led=20 > > -- =20 > > 1.8.4.5=20 > > =20 > =20 > =20