Patchwork Move the xenfb pointer handler to the connected method

login
register
mail settings
Submitter Stefano Stabellini
Date July 21, 2010, 1:46 p.m.
Message ID <alpine.DEB.2.00.1007211442420.22235@kaball-desktop>
Download mbox | patch
Permalink /patch/59441/
State New
Headers show

Comments

Stefano Stabellini - July 21, 2010, 1:46 p.m.
From: John Haxby <john.haxby@oracle.com>

Move the xenfb pointer handler to the connected method

Ensure that we read "request-abs-pointer" after the frontend has written
it.  This means that we will correctly set up an ansolute or relative
pointer handler correctly.

Signed-off-by: John Haxby <john.haxby@oracle.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Stefano Stabellini - July 27, 2010, 2:55 p.m.
Any comments?

On Wed, 21 Jul 2010, Stefano Stabellini wrote:
> From: John Haxby <john.haxby@oracle.com>
> 
> Move the xenfb pointer handler to the connected method
> 
> Ensure that we read "request-abs-pointer" after the frontend has written
> it.  This means that we will correctly set up an ansolute or relative
> pointer handler correctly.
> 
> Signed-off-by: John Haxby <john.haxby@oracle.com>
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> 
> 
> diff --git a/hw/xenfb.c b/hw/xenfb.c
> index b535d8c..72e5277 100644
> --- a/hw/xenfb.c
> +++ b/hw/xenfb.c
> @@ -364,19 +364,27 @@ static int input_initialise(struct XenDevice *xendev)
>      struct XenInput *in = container_of(xendev, struct XenInput, c.xendev);
>      int rc;
>  
> -    if (xenstore_read_fe_int(xendev, "request-abs-pointer",
> -                             &in->abs_pointer_wanted) == -1)
> -	in->abs_pointer_wanted = 0;
> -
>      rc = common_bind(&in->c);
>      if (rc != 0)
>  	return rc;
>  
>      qemu_add_kbd_event_handler(xenfb_key_event, in);
> +    return 0;
> +}
> +
> +static void input_connected(struct XenDevice *xendev)
> +{
> +    struct XenInput *in = container_of(xendev, struct XenInput, c.xendev);
> +
> +    if (xenstore_read_fe_int(xendev, "request-abs-pointer",
> +                             &in->abs_pointer_wanted) == -1)
> +	in->abs_pointer_wanted = 0;
> +
> +    if (in->qmouse)
> +	qemu_remove_mouse_event_handler(in->qmouse);
>      in->qmouse = qemu_add_mouse_event_handler(xenfb_mouse_event, in,
>  					      in->abs_pointer_wanted,
>  					      "Xen PVFB Mouse");
> -    return 0;
>  }
>  
>  static void input_disconnect(struct XenDevice *xendev)
> @@ -956,6 +964,7 @@ struct XenDevOps xen_kbdmouse_ops = {
>      .size       = sizeof(struct XenInput),
>      .init       = input_init,
>      .initialise = input_initialise,
> +    .connected  = input_connected,
>      .disconnect = input_disconnect,
>      .event      = input_event,
>  };
>

Patch

diff --git a/hw/xenfb.c b/hw/xenfb.c
index b535d8c..72e5277 100644
--- a/hw/xenfb.c
+++ b/hw/xenfb.c
@@ -364,19 +364,27 @@  static int input_initialise(struct XenDevice *xendev)
     struct XenInput *in = container_of(xendev, struct XenInput, c.xendev);
     int rc;
 
-    if (xenstore_read_fe_int(xendev, "request-abs-pointer",
-                             &in->abs_pointer_wanted) == -1)
-	in->abs_pointer_wanted = 0;
-
     rc = common_bind(&in->c);
     if (rc != 0)
 	return rc;
 
     qemu_add_kbd_event_handler(xenfb_key_event, in);
+    return 0;
+}
+
+static void input_connected(struct XenDevice *xendev)
+{
+    struct XenInput *in = container_of(xendev, struct XenInput, c.xendev);
+
+    if (xenstore_read_fe_int(xendev, "request-abs-pointer",
+                             &in->abs_pointer_wanted) == -1)
+	in->abs_pointer_wanted = 0;
+
+    if (in->qmouse)
+	qemu_remove_mouse_event_handler(in->qmouse);
     in->qmouse = qemu_add_mouse_event_handler(xenfb_mouse_event, in,
 					      in->abs_pointer_wanted,
 					      "Xen PVFB Mouse");
-    return 0;
 }
 
 static void input_disconnect(struct XenDevice *xendev)
@@ -956,6 +964,7 @@  struct XenDevOps xen_kbdmouse_ops = {
     .size       = sizeof(struct XenInput),
     .init       = input_init,
     .initialise = input_initialise,
+    .connected  = input_connected,
     .disconnect = input_disconnect,
     .event      = input_event,
 };