qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] ui/input: strictly check console in finding input h


From: Amos Kong
Subject: [Qemu-devel] [PATCH] ui/input: strictly check console in finding input handler
Date: Wed, 5 Nov 2014 00:49:26 +0800

qemu_input_find_handler() prefers a handler associated with con.
But if none exists, it takes any. This patch added a parameter
to strictly check console, in case we want to input event to
special console.

'input-send-event' has a parameter to assign special console,
so we should enable strict checking in finding handler.

Signed-off-by: Amos Kong <address@hidden>
---
 ui/input.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/ui/input.c b/ui/input.c
index 002831e..61b26a0 100644
--- a/ui/input.c
+++ b/ui/input.c
@@ -98,7 +98,7 @@ void qemu_input_handler_bind(QemuInputHandlerState *s,
 }
 
 static QemuInputHandlerState*
-qemu_input_find_handler(uint32_t mask, QemuConsole *con)
+qemu_input_find_handler(uint32_t mask, QemuConsole *con, bool strict_con)
 {
     QemuInputHandlerState *s;
 
@@ -111,6 +111,10 @@ qemu_input_find_handler(uint32_t mask, QemuConsole *con)
         }
     }
 
+    if (strict_con) {
+        return NULL;
+    }
+
     QTAILQ_FOREACH(s, &handlers, node) {
         if (s->con != NULL) {
             continue;
@@ -142,7 +146,7 @@ void qmp_input_send_event(int64_t console, InputEventList 
*events,
     for (e = events; e != NULL; e = e->next) {
         InputEvent *event = e->value;
 
-        if (!qemu_input_find_handler(1 << event->kind, con)) {
+        if (!qemu_input_find_handler(1 << event->kind, con, true)) {
             error_setg(errp, "Input handler not found for "
                              "event type %s",
                             InputEventKind_lookup[event->kind]);
@@ -311,7 +315,7 @@ void qemu_input_event_send(QemuConsole *src, InputEvent 
*evt)
     }
 
     /* send event */
-    s = qemu_input_find_handler(1 << evt->kind, src);
+    s = qemu_input_find_handler(1 << evt->kind, src, NULL);
     if (!s) {
         return;
     }
@@ -428,7 +432,7 @@ bool qemu_input_is_absolute(void)
     QemuInputHandlerState *s;
 
     s = qemu_input_find_handler(INPUT_EVENT_MASK_REL | INPUT_EVENT_MASK_ABS,
-                                NULL);
+                                NULL, NULL);
     return (s != NULL) && (s->handler->mask & INPUT_EVENT_MASK_ABS);
 }
 
-- 
1.9.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]