summaryrefslogtreecommitdiff
path: root/ui/input.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2013-12-05 11:23:42 +0100
committerGerd Hoffmann <kraxel@redhat.com>2014-03-05 09:52:04 +0100
commit4a33f45e2e4c773b47963baf5a8251963bd01e38 (patch)
tree98984b91045c0d9d1da238e8b095275645248b94 /ui/input.c
parent4798648e32112ce92be904bb9d53f8ad0f519c76 (diff)
downloadqemu-4a33f45e2e4c773b47963baf5a8251963bd01e38.tar.gz
input: move mouse mode notifier to new core
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'ui/input.c')
-rw-r--r--ui/input.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/ui/input.c b/ui/input.c
index 60302b1d3c..b8fc6818d2 100644
--- a/ui/input.c
+++ b/ui/input.c
@@ -13,6 +13,8 @@ struct QemuInputHandlerState {
};
static QTAILQ_HEAD(, QemuInputHandlerState) handlers =
QTAILQ_HEAD_INITIALIZER(handlers);
+static NotifierList mouse_mode_notifiers =
+ NOTIFIER_LIST_INITIALIZER(mouse_mode_notifiers);
QemuInputHandlerState *qemu_input_handler_register(DeviceState *dev,
QemuInputHandler *handler)
@@ -24,6 +26,8 @@ QemuInputHandlerState *qemu_input_handler_register(DeviceState *dev,
s->handler = handler;
s->id = id++;
QTAILQ_INSERT_TAIL(&handlers, s, node);
+
+ qemu_input_check_mode_change();
return s;
}
@@ -31,12 +35,14 @@ void qemu_input_handler_activate(QemuInputHandlerState *s)
{
QTAILQ_REMOVE(&handlers, s, node);
QTAILQ_INSERT_HEAD(&handlers, s, node);
+ qemu_input_check_mode_change();
}
void qemu_input_handler_unregister(QemuInputHandlerState *s)
{
QTAILQ_REMOVE(&handlers, s, node);
g_free(s);
+ qemu_input_check_mode_change();
}
static QemuInputHandlerState*
@@ -274,3 +280,27 @@ void qemu_input_queue_abs(QemuConsole *src, InputAxis axis, int value, int size)
qemu_input_event_send(src, evt);
qapi_free_InputEvent(evt);
}
+
+void qemu_input_check_mode_change(void)
+{
+ static int current_is_absolute;
+ int is_absolute;
+
+ is_absolute = qemu_input_is_absolute();
+
+ if (is_absolute != current_is_absolute) {
+ notifier_list_notify(&mouse_mode_notifiers, NULL);
+ }
+
+ current_is_absolute = is_absolute;
+}
+
+void qemu_add_mouse_mode_change_notifier(Notifier *notify)
+{
+ notifier_list_add(&mouse_mode_notifiers, notify);
+}
+
+void qemu_remove_mouse_mode_change_notifier(Notifier *notify)
+{
+ notifier_remove(notify);
+}