diff options
Diffstat (limited to 'ui')
-rw-r--r-- | ui/cocoa.m | 4 | ||||
-rw-r--r-- | ui/console.c | 23 | ||||
-rw-r--r-- | ui/gtk.c | 4 | ||||
-rw-r--r-- | ui/input-legacy.c | 4 | ||||
-rw-r--r-- | ui/input.c | 32 | ||||
-rw-r--r-- | ui/sdl.c | 4 | ||||
-rw-r--r-- | ui/sdl2.c | 4 | ||||
-rw-r--r-- | ui/spice-input.c | 4 | ||||
-rw-r--r-- | ui/vnc.c | 19 |
9 files changed, 56 insertions, 42 deletions
diff --git a/ui/cocoa.m b/ui/cocoa.m index 3ee554908a..7063a025c0 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -739,8 +739,8 @@ QemuCocoaView *cocoaView; [INPUT_BUTTON_LEFT] = MOUSE_EVENT_LBUTTON, [INPUT_BUTTON_MIDDLE] = MOUSE_EVENT_MBUTTON, [INPUT_BUTTON_RIGHT] = MOUSE_EVENT_RBUTTON, - [INPUT_BUTTON_WHEELUP] = MOUSE_EVENT_WHEELUP, - [INPUT_BUTTON_WHEELDOWN] = MOUSE_EVENT_WHEELDN, + [INPUT_BUTTON_WHEEL_UP] = MOUSE_EVENT_WHEELUP, + [INPUT_BUTTON_WHEEL_DOWN] = MOUSE_EVENT_WHEELDN, }; qemu_input_update_buttons(dcl->con, bmap, last_buttons, buttons); last_buttons = buttons; diff --git a/ui/console.c b/ui/console.c index 7db0fd27c9..ae61382d6e 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1790,6 +1790,29 @@ QemuConsole *qemu_console_lookup_by_device(DeviceState *dev, uint32_t head) return NULL; } +QemuConsole *qemu_console_lookup_by_device_name(const char *device_id, + uint32_t head, Error **errp) +{ + DeviceState *dev; + QemuConsole *con; + + dev = qdev_find_recursive(sysbus_get_default(), device_id); + if (dev == NULL) { + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + "Device '%s' not found", device_id); + return NULL; + } + + con = qemu_console_lookup_by_device(dev, head); + if (con == NULL) { + error_setg(errp, "Device %s (head %d) is not bound to a QemuConsole", + device_id, head); + return NULL; + } + + return con; +} + bool qemu_console_is_visible(QemuConsole *con) { return (con == active_console) || (con->dcls > 0); @@ -966,9 +966,9 @@ static gboolean gd_scroll_event(GtkWidget *widget, GdkEventScroll *scroll, InputButton btn; if (scroll->direction == GDK_SCROLL_UP) { - btn = INPUT_BUTTON_WHEELUP; + btn = INPUT_BUTTON_WHEEL_UP; } else if (scroll->direction == GDK_SCROLL_DOWN) { - btn = INPUT_BUTTON_WHEELDOWN; + btn = INPUT_BUTTON_WHEEL_DOWN; } else { return TRUE; } diff --git a/ui/input-legacy.c b/ui/input-legacy.c index c97eac1778..703f0a6ed1 100644 --- a/ui/input-legacy.c +++ b/ui/input-legacy.c @@ -158,7 +158,7 @@ static void legacy_mouse_event(DeviceState *dev, QemuConsole *src, } else { s->buttons &= ~bmap[evt->u.btn->button]; } - if (evt->u.btn->down && evt->u.btn->button == INPUT_BUTTON_WHEELUP) { + if (evt->u.btn->down && evt->u.btn->button == INPUT_BUTTON_WHEEL_UP) { s->qemu_put_mouse_event(s->qemu_put_mouse_event_opaque, s->axis[INPUT_AXIS_X], s->axis[INPUT_AXIS_Y], @@ -166,7 +166,7 @@ static void legacy_mouse_event(DeviceState *dev, QemuConsole *src, s->buttons); } if (evt->u.btn->down && - evt->u.btn->button == INPUT_BUTTON_WHEELDOWN) { + evt->u.btn->button == INPUT_BUTTON_WHEEL_DOWN) { s->qemu_put_mouse_event(s->qemu_put_mouse_event_opaque, s->axis[INPUT_AXIS_X], s->axis[INPUT_AXIS_Y], diff --git a/ui/input.c b/ui/input.c index bdcb974a89..6fd48efb57 100644 --- a/ui/input.c +++ b/ui/input.c @@ -82,19 +82,12 @@ void qemu_input_handler_bind(QemuInputHandlerState *s, const char *device_id, int head, Error **errp) { - DeviceState *dev; QemuConsole *con; + Error *err = NULL; - dev = qdev_find_recursive(sysbus_get_default(), device_id); - if (dev == NULL) { - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, - "Device '%s' not found", device_id); - return; - } - - con = qemu_console_lookup_by_device(dev, head); - if (con == NULL) { - error_setg(errp, "Device %s is not bound to a QemuConsole", device_id); + con = qemu_console_lookup_by_device_name(device_id, head, &err); + if (err) { + error_propagate(errp, err); return; } @@ -126,17 +119,22 @@ qemu_input_find_handler(uint32_t mask, QemuConsole *con) return NULL; } -void qmp_x_input_send_event(bool has_console, int64_t console, - InputEventList *events, Error **errp) +void qmp_input_send_event(bool has_device, const char *device, + bool has_head, int64_t head, + InputEventList *events, Error **errp) { InputEventList *e; QemuConsole *con; + Error *err = NULL; con = NULL; - if (has_console) { - con = qemu_console_lookup_by_index(console); - if (!con) { - error_setg(errp, "console %" PRId64 " not found", console); + if (has_device) { + if (!has_head) { + head = 0; + } + con = qemu_console_lookup_by_device_name(device, head, &err); + if (err) { + error_propagate(errp, err); return; } } @@ -475,8 +475,8 @@ static void sdl_send_mouse_event(int dx, int dy, int x, int y, int state) [INPUT_BUTTON_LEFT] = SDL_BUTTON(SDL_BUTTON_LEFT), [INPUT_BUTTON_MIDDLE] = SDL_BUTTON(SDL_BUTTON_MIDDLE), [INPUT_BUTTON_RIGHT] = SDL_BUTTON(SDL_BUTTON_RIGHT), - [INPUT_BUTTON_WHEELUP] = SDL_BUTTON(SDL_BUTTON_WHEELUP), - [INPUT_BUTTON_WHEELDOWN] = SDL_BUTTON(SDL_BUTTON_WHEELDOWN), + [INPUT_BUTTON_WHEEL_UP] = SDL_BUTTON(SDL_BUTTON_WHEELUP), + [INPUT_BUTTON_WHEEL_DOWN] = SDL_BUTTON(SDL_BUTTON_WHEELDOWN), }; static uint32_t prev_state; @@ -509,9 +509,9 @@ static void handle_mousewheel(SDL_Event *ev) InputButton btn; if (wev->y > 0) { - btn = INPUT_BUTTON_WHEELUP; + btn = INPUT_BUTTON_WHEEL_UP; } else if (wev->y < 0) { - btn = INPUT_BUTTON_WHEELDOWN; + btn = INPUT_BUTTON_WHEEL_DOWN; } else { return; } diff --git a/ui/spice-input.c b/ui/spice-input.c index 72e406382f..8eeebdbb2e 100644 --- a/ui/spice-input.c +++ b/ui/spice-input.c @@ -108,8 +108,8 @@ static void spice_update_buttons(QemuSpicePointer *pointer, [INPUT_BUTTON_LEFT] = 0x01, [INPUT_BUTTON_MIDDLE] = 0x04, [INPUT_BUTTON_RIGHT] = 0x02, - [INPUT_BUTTON_WHEELUP] = 0x10, - [INPUT_BUTTON_WHEELDOWN] = 0x20, + [INPUT_BUTTON_WHEEL_UP] = 0x10, + [INPUT_BUTTON_WHEEL_DOWN] = 0x20, }; if (wheel < 0) { @@ -1593,8 +1593,8 @@ static void pointer_event(VncState *vs, int button_mask, int x, int y) [INPUT_BUTTON_LEFT] = 0x01, [INPUT_BUTTON_MIDDLE] = 0x02, [INPUT_BUTTON_RIGHT] = 0x04, - [INPUT_BUTTON_WHEELUP] = 0x08, - [INPUT_BUTTON_WHEELDOWN] = 0x10, + [INPUT_BUTTON_WHEEL_UP] = 0x08, + [INPUT_BUTTON_WHEEL_DOWN] = 0x10, }; QemuConsole *con = vs->vd->dcl.con; int width = pixman_image_get_width(vs->vd->server); @@ -3732,19 +3732,12 @@ void vnc_display_open(const char *id, Error **errp) device_id = qemu_opt_get(opts, "display"); if (device_id) { - DeviceState *dev; int head = qemu_opt_get_number(opts, "head", 0); + Error *err = NULL; - dev = qdev_find_recursive(sysbus_get_default(), device_id); - if (dev == NULL) { - error_setg(errp, "Device '%s' not found", device_id); - goto fail; - } - - con = qemu_console_lookup_by_device(dev, head); - if (con == NULL) { - error_setg(errp, "Device %s is not bound to a QemuConsole", - device_id); + con = qemu_console_lookup_by_device_name(device_id, head, &err); + if (err) { + error_propagate(errp, err); goto fail; } } else { |