[Spice-devel] [PATCH spice-protocol] inputs: add an INPUTS_KEY_SCANCODE message

Alon Levy alevy at redhat.com
Wed Aug 15 15:16:15 PDT 2012


On Wed, Aug 15, 2012 at 10:57:57PM +0300, Marc-André Lureau wrote:
> Add a new arbitrary keyboard scancodes message.
> 
> For now, it will be used to avoid unwanted key repeatition when there
> is jitter in the network and too much time between DOWN and UP
> messages, instead the client will send the press & release scancode in
> a sequence from a single message.
> 
> If the server doesn't support INPUTS_CAP_KEY_SCANCODE, the client is
> responsible to handle a fallback mode with the exisiting KEY_DOWN and
> KEY_UP messages.

ACK all, just one note we discussed offline (and this is a huge
improvement btw regardless of what I'm about to say): When two keys are
pressed, A followed by B, and B is released, the current behavior is to
send A press. Then when A is eventually released we still have the old
behavior of a separate messages, and so we are susceptible to network
jitter. Even worse, there is no solution for it that also enforces the
order of events (i.e. if A was pressed before B in the client, it must
be the same order in the guest). We could still do a little better then
the current code, by waiting for B release instead of B press to send
the A press (since maybe A release will happen meanwhile, and then we
have the regular case that this patchset solves).

Example:

t=0    A press
t=0.05 B press
t=0.1  B release <- send ScanCode{A_press,B_press,B_release}

Case 1: after 9.9 seconds A release happens - then we are optimal:
t=10  A release <- send ScanCode{A_release}

Case 2: after 0.05 seconds A release happens - then we are susceptible
to jitter in these 0.05 seconds:

t=0.15  A release <- send ScanCode{A_release}

> 
> See also: https://bugzilla.redhat.com/show_bug.cgi?id=812347
> ---
>  spice/enums.h    |    1 +
>  spice/protocol.h |    4 ++++
>  2 files changed, 5 insertions(+)
> 
> diff --git a/spice/enums.h b/spice/enums.h
> index c4e38aa..129f9b7 100644
> --- a/spice/enums.h
> +++ b/spice/enums.h
> @@ -453,6 +453,7 @@ enum {
>      SPICE_MSGC_INPUTS_KEY_DOWN = 101,
>      SPICE_MSGC_INPUTS_KEY_UP,
>      SPICE_MSGC_INPUTS_KEY_MODIFIERS,
> +    SPICE_MSGC_INPUTS_KEY_SCANCODE,
>      SPICE_MSGC_INPUTS_MOUSE_MOTION = 111,
>      SPICE_MSGC_INPUTS_MOUSE_POSITION,
>      SPICE_MSGC_INPUTS_MOUSE_PRESS,
> diff --git a/spice/protocol.h b/spice/protocol.h
> index c0d33e6..fafd015 100644
> --- a/spice/protocol.h
> +++ b/spice/protocol.h
> @@ -127,6 +127,10 @@ enum {
>      SPICE_DISPLAY_CAP_MONITORS_CONFIG,
>  };
>  
> +enum {
> +    SPICE_INPUTS_CAP_KEY_SCANCODE,
> +};
> +
>  #include <spice/end-packed.h>
>  
>  #endif /* _H_SPICE_PROTOCOL */
> -- 
> 1.7.10.4
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel


More information about the Spice-devel mailing list