aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2023-01-09 20:03:20 +0100
committerMarkus Armbruster <armbru@redhat.com>2023-01-19 13:30:01 +0100
commitec843b97f2c02b85115c7c5c8799ea4d02ddfba7 (patch)
tree66ebfa1f30e15fa02deaefaefee66c54c27e9c29 /ui
parent006e79cdf4273b52a854f36b119ebd2ea954ea92 (diff)
downloadqemu-ec843b97f2c02b85115c7c5c8799ea4d02ddfba7.zip
qemu-ec843b97f2c02b85115c7c5c8799ea4d02ddfba7.tar.gz
qemu-ec843b97f2c02b85115c7c5c8799ea4d02ddfba7.tar.bz2
ui: Split hmp_mouse_set() and move the HMP part to ui/
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230109190321.1056914-17-armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/input.c15
-rw-r--r--ui/ui-hmp-cmds.c8
2 files changed, 15 insertions, 8 deletions
diff --git a/ui/input.c b/ui/input.c
index d1c7605..7048810 100644
--- a/ui/input.c
+++ b/ui/input.c
@@ -2,8 +2,6 @@
#include "sysemu/sysemu.h"
#include "qapi/error.h"
#include "qapi/qapi-commands-ui.h"
-#include "qapi/qmp/qdict.h"
-#include "qemu/error-report.h"
#include "trace.h"
#include "ui/input.h"
#include "ui/console.h"
@@ -594,10 +592,9 @@ MouseInfoList *qmp_query_mice(Error **errp)
return mice_list;
}
-void hmp_mouse_set(Monitor *mon, const QDict *qdict)
+bool qemu_mouse_set(int index, Error **errp)
{
QemuInputHandlerState *s;
- int index = qdict_get_int(qdict, "index");
int found = 0;
QTAILQ_FOREACH(s, &handlers, node) {
@@ -606,8 +603,9 @@ void hmp_mouse_set(Monitor *mon, const QDict *qdict)
}
if (!(s->handler->mask & (INPUT_EVENT_MASK_REL |
INPUT_EVENT_MASK_ABS))) {
- error_report("Input device '%s' is not a mouse", s->handler->name);
- return;
+ error_setg(errp, "Input device '%s' is not a mouse",
+ s->handler->name);
+ return false;
}
found = 1;
qemu_input_handler_activate(s);
@@ -615,9 +613,10 @@ void hmp_mouse_set(Monitor *mon, const QDict *qdict)
}
if (!found) {
- error_report("Mouse at index '%d' not found", index);
- return;
+ error_setg(errp, "Mouse at index '%d' not found", index);
+ return false;
}
qemu_input_check_mode_change();
+ return true;
}
diff --git a/ui/ui-hmp-cmds.c b/ui/ui-hmp-cmds.c
index 7ca80c8..5c456ec 100644
--- a/ui/ui-hmp-cmds.c
+++ b/ui/ui-hmp-cmds.c
@@ -69,6 +69,14 @@ void hmp_mouse_button(Monitor *mon, const QDict *qdict)
mouse_button_state = button_state;
}
+void hmp_mouse_set(Monitor *mon, const QDict *qdict)
+{
+ Error *err = NULL;
+
+ qemu_mouse_set(qdict_get_int(qdict, "index"), &err);
+ hmp_handle_error(mon, err);
+}
+
void hmp_info_mice(Monitor *mon, const QDict *qdict)
{
MouseInfoList *mice_list, *mouse;