qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] ui/input: strictly check console in finding input handler
@ 2014-11-04 16:49 Amos Kong
  2014-11-05  8:47 ` Gerd Hoffmann
  0 siblings, 1 reply; 6+ messages in thread
From: Amos Kong @ 2014-11-04 16:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: mtosatti, armbru, kraxel

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 <akong@redhat.com>
---
 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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-11-07  4:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-04 16:49 [Qemu-devel] [PATCH] ui/input: strictly check console in finding input handler Amos Kong
2014-11-05  8:47 ` Gerd Hoffmann
2014-11-06  6:37   ` Amos Kong
2014-11-06 15:01     ` Amos Kong
2014-11-07  4:16       ` Amos Kong
2014-11-06  9:00   ` Markus Armbruster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).