From: Anthony Liguori <aliguori@us.ibm.com>
To: qemu-devel@nongnu.org
Cc: Anthony Liguori <aliguori@us.ibm.com>,
Gerd Hoffman <kraxel@redhat.com>,
Luiz Capitulino <lcapitulino@redhat.com>
Subject: [Qemu-devel] [PATCH 4/7] Add notifier for mouse mode changes
Date: Wed, 10 Mar 2010 10:51:06 -0600 [thread overview]
Message-ID: <1268239869-16058-4-git-send-email-aliguori@us.ibm.com> (raw)
In-Reply-To: <1268239869-16058-1-git-send-email-aliguori@us.ibm.com>
Right now, DisplayState clients rely on polling the mouse mode to determine
when the device is changed to an absolute device. Use a notification list to
add an explicit notification.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
console.h | 3 +++
input.c | 37 ++++++++++++++++++++++++++++++++++++-
2 files changed, 39 insertions(+), 1 deletions(-)
diff --git a/console.h b/console.h
index f3c619f..cb928cf 100644
--- a/console.h
+++ b/console.h
@@ -3,6 +3,7 @@
#include "qemu-char.h"
#include "qdict.h"
+#include "notify.h"
/* keyboard/mouse support */
@@ -56,6 +57,8 @@ void kbd_mouse_event(int dx, int dy, int dz, int buttons_state);
/* Does the current mouse generate absolute events */
int kbd_mouse_is_absolute(void);
+void qemu_add_mouse_mode_change_notifier(QEMUNotifier *notify);
+void qemu_remove_mouse_mode_change_notifier(QEMUNotifier *notify);
/* Of all the mice, is there one that generates absolute events */
int kbd_mouse_has_absolute(void);
diff --git a/input.c b/input.c
index 8d5a14d..cbf55b7 100644
--- a/input.c
+++ b/input.c
@@ -28,12 +28,13 @@
#include "console.h"
#include "qjson.h"
-
static QEMUPutKBDEvent *qemu_put_kbd_event;
static void *qemu_put_kbd_event_opaque;
static QTAILQ_HEAD(, QEMUPutLEDEntry) led_handlers = QTAILQ_HEAD_INITIALIZER(led_handlers);
static QTAILQ_HEAD(, QEMUPutMouseEntry) mouse_handlers =
QTAILQ_HEAD_INITIALIZER(mouse_handlers);
+static QEMUNotifierList mouse_mode_notifiers =
+ QEMU_NOTIFIER_LIST_INITIALIZER(mouse_mode_notifiers);
void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque)
{
@@ -41,6 +42,24 @@ void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque)
qemu_put_kbd_event = func;
}
+static void check_mode_change(void)
+{
+ static int current_is_absolute, current_has_absolute;
+ int is_absolute;
+ int has_absolute;
+
+ is_absolute = kbd_mouse_is_absolute();
+ has_absolute = kbd_mouse_has_absolute();
+
+ if (is_absolute != current_is_absolute ||
+ has_absolute != current_has_absolute) {
+ qemu_notifier_list_notify(&mouse_mode_notifiers);
+ }
+
+ current_is_absolute = is_absolute;
+ current_has_absolute = has_absolute;
+}
+
QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func,
void *opaque, int absolute,
const char *name)
@@ -58,6 +77,8 @@ QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func,
QTAILQ_INSERT_TAIL(&mouse_handlers, s, node);
+ check_mode_change();
+
return s;
}
@@ -75,6 +96,8 @@ void qemu_remove_mouse_event_handler(QEMUPutMouseEntry *entry)
qemu_free(entry->qemu_put_mouse_event_name);
qemu_free(entry);
+
+ check_mode_change();
}
QEMUPutLEDEntry *qemu_add_led_event_handler(QEMUPutLEDEvent *func,
@@ -256,4 +279,16 @@ void do_mouse_set(Monitor *mon, const QDict *qdict)
if (!found) {
monitor_printf(mon, "Mouse at given index not found\n");
}
+
+ check_mode_change();
+}
+
+void qemu_add_mouse_mode_change_notifier(QEMUNotifier *notify)
+{
+ qemu_notifier_list_add(&mouse_mode_notifiers, notify);
+}
+
+void qemu_remove_mouse_mode_change_notifier(QEMUNotifier *notify)
+{
+ qemu_notifier_list_remove(&mouse_mode_notifiers, notify);
}
--
1.6.5.2
next prev parent reply other threads:[~2010-03-10 16:51 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-10 16:51 [Qemu-devel] [PATCH 1/7] Add support for generic notifier lists Anthony Liguori
2010-03-10 16:51 ` [Qemu-devel] [PATCH 2/7] Rewrite mouse handlers to use QTAILQ and to have an activation function Anthony Liguori
2010-03-10 16:51 ` [Qemu-devel] [PATCH 3/7] Add kbd_mouse_has_absolute() Anthony Liguori
2010-03-10 16:51 ` Anthony Liguori [this message]
2010-03-10 16:51 ` [Qemu-devel] [PATCH 5/7] Expose whether a mouse is an absolute device via QMP and the human monitor Anthony Liguori
2010-03-11 14:15 ` [Qemu-devel] " Luiz Capitulino
2010-03-10 16:51 ` [Qemu-devel] [PATCH 6/7] input: make vnc use mouse mode notifiers Anthony Liguori
2010-03-10 22:37 ` [Qemu-devel] " Gerd Hoffmann
2010-03-10 16:51 ` [Qemu-devel] [PATCH 7/7] sdl: use mouse mode notifier Anthony Liguori
2010-03-11 12:57 ` [Qemu-devel] [PATCH 1/7] Add support for generic notifier lists Paul Brook
2010-03-11 13:25 ` [Qemu-devel] " Paolo Bonzini
2010-03-11 13:42 ` Avi Kivity
2010-03-11 14:36 ` Paolo Bonzini
2010-03-11 14:42 ` Avi Kivity
2010-03-11 15:08 ` Anthony Liguori
2010-03-11 13:58 ` Paul Brook
2010-03-11 14:39 ` Paolo Bonzini
2010-03-11 14:11 ` Anthony Liguori
2010-03-11 14:09 ` [Qemu-devel] " Anthony Liguori
2010-03-11 14:19 ` Paul Brook
2010-03-11 14:54 ` Anthony Liguori
2010-03-11 15:19 ` Avi Kivity
2010-03-15 20:31 ` Anthony Liguori
2010-03-15 23:37 ` Anthony Liguori
2010-03-11 13:36 ` Avi Kivity
2010-03-11 14:12 ` Anthony Liguori
2010-03-11 14:48 ` [Qemu-devel] [PATCH] CODING_STYLE: Reserve qemu_ prefix for library wrappers Avi Kivity
2010-03-11 14:55 ` [Qemu-devel] " Anthony Liguori
2010-03-11 23:08 ` Jamie Lokier
2010-03-12 18:47 ` Blue Swirl
2010-03-11 16:19 ` [Qemu-devel] " Markus Armbruster
2010-03-11 23:21 ` [Qemu-devel] " Juan Quintela
2010-03-12 7:58 ` [Qemu-devel] " Aurelien Jarno
2010-03-12 11:28 ` Paul Brook
2010-03-13 2:55 ` Edgar E. Iglesias
2010-03-13 8:17 ` Avi Kivity
2010-03-13 11:11 ` Edgar E. Iglesias
2010-03-22 19:39 ` Anthony Liguori
-- strict thread matches above, loose matches on Subject: below --
2010-03-15 20:34 [Qemu-devel] [PATCH 1/7] Add support for generic notifier lists (v2) Anthony Liguori
2010-03-15 20:34 ` [Qemu-devel] [PATCH 4/7] Add notifier for mouse mode changes Anthony Liguori
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=1268239869-16058-4-git-send-email-aliguori@us.ibm.com \
--to=aliguori@us.ibm.com \
--cc=kraxel@redhat.com \
--cc=lcapitulino@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).