Keyboard event handler was replaced with a new handler on disconnect.
Use the unregister function to remove keyboard handler.

Signed-off-by: Owen smith <owen.sm...@citrix.com>
---
 hw/display/xenfb.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c
index 07ddc9d..2c39753 100644
--- a/hw/display/xenfb.c
+++ b/hw/display/xenfb.c
@@ -62,6 +62,7 @@ struct XenInput {
     int abs_pointer_wanted; /* Whether guest supports absolute pointer */
     int button_state;       /* Last seen pointer button state */
     int extended;
+    QEMUPutKbdEntry *qkbd;
     QEMUPutMouseEntry *qmouse;
 };
 
@@ -364,7 +365,6 @@ static int input_initialise(struct XenDevice *xendev)
     if (rc != 0)
        return rc;
 
-    qemu_add_kbd_event_handler(xenfb_key_event, in);
     return 0;
 }
 
@@ -383,17 +383,26 @@ static void input_connected(struct XenDevice *xendev)
     in->qmouse = qemu_add_mouse_event_handler(xenfb_mouse_event, in,
                                              in->abs_pointer_wanted,
                                              "Xen PVFB Mouse");
+    qemu_activate_mouse_event_handler(in->qmouse);
+
+    if (in->qkbd) {
+        qemu_remove_kbd_event_handler(in->qkbd);
+    }
+    in->qkbd = qemu_add_kbd_event_handler(xenfb_key_event, in);
 }
 
 static void input_disconnect(struct XenDevice *xendev)
 {
     struct XenInput *in = container_of(xendev, struct XenInput, c.xendev);
 
+    if (in->qkbd) {
+        qemu_remove_kbd_event_handler(in->qkbd);
+        in->qkbd = NULL;
+    }
     if (in->qmouse) {
        qemu_remove_mouse_event_handler(in->qmouse);
        in->qmouse = NULL;
     }
-    qemu_add_kbd_event_handler(NULL, NULL);
     common_unbind(&in->c);
 }
 
-- 
2.1.0


Reply via email to