mirror of https://github.com/xemu-project/xemu.git
ui: Simplify control flow in qemu_mouse_set()
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230109190321.1056914-18-armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
ec843b97f2
commit
a0506b7c8f
24
ui/input.c
24
ui/input.c
|
@ -595,28 +595,26 @@ MouseInfoList *qmp_query_mice(Error **errp)
|
||||||
bool qemu_mouse_set(int index, Error **errp)
|
bool qemu_mouse_set(int index, Error **errp)
|
||||||
{
|
{
|
||||||
QemuInputHandlerState *s;
|
QemuInputHandlerState *s;
|
||||||
int found = 0;
|
|
||||||
|
|
||||||
QTAILQ_FOREACH(s, &handlers, node) {
|
QTAILQ_FOREACH(s, &handlers, node) {
|
||||||
if (s->id != index) {
|
if (s->id == index) {
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
if (!(s->handler->mask & (INPUT_EVENT_MASK_REL |
|
|
||||||
INPUT_EVENT_MASK_ABS))) {
|
|
||||||
error_setg(errp, "Input device '%s' is not a mouse",
|
|
||||||
s->handler->name);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
found = 1;
|
|
||||||
qemu_input_handler_activate(s);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found) {
|
if (!s) {
|
||||||
error_setg(errp, "Mouse at index '%d' not found", index);
|
error_setg(errp, "Mouse at index '%d' not found", index);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(s->handler->mask & (INPUT_EVENT_MASK_REL |
|
||||||
|
INPUT_EVENT_MASK_ABS))) {
|
||||||
|
error_setg(errp, "Input device '%s' is not a mouse",
|
||||||
|
s->handler->name);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
qemu_input_handler_activate(s);
|
||||||
qemu_input_check_mode_change();
|
qemu_input_check_mode_change();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue