qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Amos Kong <akong@redhat.com>
To: qemu-devel@nongnu.org
Cc: mtosatti@redhat.com, armbru@redhat.com, kraxel@redhat.com
Subject: [Qemu-devel] [PATCH] ui/input: strictly check console in finding input handler
Date: Wed,  5 Nov 2014 00:49:26 +0800	[thread overview]
Message-ID: <1415119766-9745-1-git-send-email-akong@redhat.com> (raw)

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

             reply	other threads:[~2014-11-04 16:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-04 16:49 Amos Kong [this message]
2014-11-05  8:47 ` [Qemu-devel] [PATCH] ui/input: strictly check console in finding input handler 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1415119766-9745-1-git-send-email-akong@redhat.com \
    --to=akong@redhat.com \
    --cc=armbru@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).