From d4c853375508086132a72f2570e8877608ad6fe7 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Thu, 28 Nov 2013 09:58:18 +0100 Subject: console: export QemuConsole index,width,height Add functions to query QemuConsole properties. Signed-off-by: Gerd Hoffmann --- include/ui/console.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/ui/console.h b/include/ui/console.h index 4156a876e1..8543d18319 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -289,6 +289,9 @@ QemuConsole *qemu_console_lookup_by_device(DeviceState *dev); bool qemu_console_is_visible(QemuConsole *con); bool qemu_console_is_graphic(QemuConsole *con); bool qemu_console_is_fixedsize(QemuConsole *con); +int qemu_console_get_index(QemuConsole *con); +int qemu_console_get_width(QemuConsole *con, int fallback); +int qemu_console_get_height(QemuConsole *con, int fallback); void text_consoles_set_display(DisplayState *ds); void console_select(unsigned int index); -- cgit v1.2.3-55-g7522 From c8b405b6798e3731eb9a71fcd753745f224ce698 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Wed, 27 Nov 2013 10:35:26 +0100 Subject: input: add core bits of the new input layer Register and unregister handlers. Event dispatcher code. Signed-off-by: Gerd Hoffmann --- include/ui/input.h | 32 +++++++++++++++++++++ ui/Makefile.objs | 2 +- ui/input.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 include/ui/input.h create mode 100644 ui/input.c (limited to 'include') diff --git a/include/ui/input.h b/include/ui/input.h new file mode 100644 index 0000000000..3cf3641243 --- /dev/null +++ b/include/ui/input.h @@ -0,0 +1,32 @@ +#ifndef INPUT_H +#define INPUT_H + +#include "qapi-types.h" + +#define INPUT_EVENT_MASK_KEY (1<dev = dev; + s->handler = handler; + s->id = id++; + QTAILQ_INSERT_TAIL(&handlers, s, node); + return s; +} + +void qemu_input_handler_activate(QemuInputHandlerState *s) +{ + QTAILQ_REMOVE(&handlers, s, node); + QTAILQ_INSERT_HEAD(&handlers, s, node); +} + +void qemu_input_handler_unregister(QemuInputHandlerState *s) +{ + QTAILQ_REMOVE(&handlers, s, node); + g_free(s); +} + +static QemuInputHandlerState* +qemu_input_find_handler(uint32_t mask) +{ + QemuInputHandlerState *s; + + QTAILQ_FOREACH(s, &handlers, node) { + if (mask & s->handler->mask) { + return s; + } + } + return NULL; +} + +void qemu_input_event_send(QemuConsole *src, InputEvent *evt) +{ + QemuInputHandlerState *s; + + if (!runstate_is_running() && !runstate_check(RUN_STATE_SUSPENDED)) { + return; + } + + s = qemu_input_find_handler(1 << evt->kind); + s->handler->event(s->dev, src, evt); + s->events++; +} + +void qemu_input_event_sync(void) +{ + QemuInputHandlerState *s; + + if (!runstate_is_running() && !runstate_check(RUN_STATE_SUSPENDED)) { + return; + } + + QTAILQ_FOREACH(s, &handlers, node) { + if (!s->events) { + continue; + } + if (s->handler->sync) { + s->handler->sync(s->dev); + } + s->events = 0; + } +} -- cgit v1.2.3-55-g7522 From 6567147588fabd87c1b633cc35760d45b71b8d41 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Wed, 27 Nov 2013 11:38:47 +0100 Subject: input: keyboard: add helper functions to core A bunch of helper functions to manage keyboard events, to make life simpler for the ui code when submitting keyboard events. Signed-off-by: Gerd Hoffmann --- include/ui/input.h | 5 +++++ ui/input.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) (limited to 'include') diff --git a/include/ui/input.h b/include/ui/input.h index 3cf3641243..189f131b3b 100644 --- a/include/ui/input.h +++ b/include/ui/input.h @@ -29,4 +29,9 @@ void qemu_input_handler_unregister(QemuInputHandlerState *s); void qemu_input_event_send(QemuConsole *src, InputEvent *evt); void qemu_input_event_sync(void); +InputEvent *qemu_input_event_new_key(KeyValue *key, bool down); +void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down); +void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down); +void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool down); + #endif /* INPUT_H */ diff --git a/ui/input.c b/ui/input.c index 23c84f7254..61c8089749 100644 --- a/ui/input.c +++ b/ui/input.c @@ -81,3 +81,38 @@ void qemu_input_event_sync(void) s->events = 0; } } + +InputEvent *qemu_input_event_new_key(KeyValue *key, bool down) +{ + InputEvent *evt = g_new0(InputEvent, 1); + evt->key = g_new0(InputKeyEvent, 1); + evt->kind = INPUT_EVENT_KIND_KEY; + evt->key->key = key; + evt->key->down = down; + return evt; +} + +void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down) +{ + InputEvent *evt; + evt = qemu_input_event_new_key(key, down); + qemu_input_event_send(src, evt); + qemu_input_event_sync(); + qapi_free_InputEvent(evt); +} + +void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down) +{ + KeyValue *key = g_new0(KeyValue, 1); + key->kind = KEY_VALUE_KIND_NUMBER; + key->number = num; + qemu_input_event_send_key(src, key, down); +} + +void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool down) +{ + KeyValue *key = g_new0(KeyValue, 1); + key->kind = KEY_VALUE_KIND_QCODE; + key->qcode = q; + qemu_input_event_send_key(src, key, down); +} -- cgit v1.2.3-55-g7522 From 43579403a3d67d6aab5ceb682dedae8fde85703c Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Wed, 27 Nov 2013 18:24:29 +0100 Subject: input: mouse: add helpers functions to core Likewise a bunch of helper functions to manage mouse button and movement events, again to make life easier for the ui code. Signed-off-by: Gerd Hoffmann --- include/ui/input.h | 14 +++++++++++ ui/input.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) (limited to 'include') diff --git a/include/ui/input.h b/include/ui/input.h index 189f131b3b..c6f50c2440 100644 --- a/include/ui/input.h +++ b/include/ui/input.h @@ -8,6 +8,8 @@ #define INPUT_EVENT_MASK_REL (1<qcode = q; qemu_input_event_send_key(src, key, down); } + +InputEvent *qemu_input_event_new_btn(InputButton btn, bool down) +{ + InputEvent *evt = g_new0(InputEvent, 1); + evt->btn = g_new0(InputBtnEvent, 1); + evt->kind = INPUT_EVENT_KIND_BTN; + evt->btn->button = btn; + evt->btn->down = down; + return evt; +} + +void qemu_input_queue_btn(QemuConsole *src, InputButton btn, bool down) +{ + InputEvent *evt; + evt = qemu_input_event_new_btn(btn, down); + qemu_input_event_send(src, evt); + qapi_free_InputEvent(evt); +} + +void qemu_input_update_buttons(QemuConsole *src, uint32_t *button_map, + uint32_t button_old, uint32_t button_new) +{ + InputButton btn; + uint32_t mask; + + for (btn = 0; btn < INPUT_BUTTON_MAX; btn++) { + mask = button_map[btn]; + if ((button_old & mask) == (button_new & mask)) { + continue; + } + qemu_input_queue_btn(src, btn, button_new & mask); + } +} + +int qemu_input_scale_axis(int value, int size_in, int size_out) +{ + if (size_in < 2) { + return size_out / 2; + } + return (int64_t)value * (size_out - 1) / (size_in - 1); +} + +InputEvent *qemu_input_event_new_move(InputEventKind kind, + InputAxis axis, int value) +{ + InputEvent *evt = g_new0(InputEvent, 1); + InputMoveEvent *move = g_new0(InputMoveEvent, 1); + + evt->kind = kind; + evt->data = move; + move->axis = axis; + move->value = value; + return evt; +} + +void qemu_input_queue_rel(QemuConsole *src, InputAxis axis, int value) +{ + InputEvent *evt; + evt = qemu_input_event_new_move(INPUT_EVENT_KIND_REL, axis, value); + qemu_input_event_send(src, evt); + qapi_free_InputEvent(evt); +} + +void qemu_input_queue_abs(QemuConsole *src, InputAxis axis, int value, int size) +{ + InputEvent *evt; + int scaled = qemu_input_scale_axis(value, size, INPUT_EVENT_ABS_SIZE); + evt = qemu_input_event_new_move(INPUT_EVENT_KIND_ABS, axis, scaled); + qemu_input_event_send(src, evt); + qapi_free_InputEvent(evt); +} -- cgit v1.2.3-55-g7522 From 502c8db5b41bb3206ad136fa4baa753c186c9ebd Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Thu, 28 Nov 2013 11:31:09 +0100 Subject: input: mouse: add qemu_input_is_absolute() Same as kbd_mouse_is_absolute(), but using new input core. Signed-off-by: Gerd Hoffmann --- include/ui/input.h | 1 + ui/input.c | 8 ++++++++ 2 files changed, 9 insertions(+) (limited to 'include') diff --git a/include/ui/input.h b/include/ui/input.h index c6f50c2440..28afc45c04 100644 --- a/include/ui/input.h +++ b/include/ui/input.h @@ -41,6 +41,7 @@ void qemu_input_queue_btn(QemuConsole *src, InputButton btn, bool down); void qemu_input_update_buttons(QemuConsole *src, uint32_t *button_map, uint32_t button_old, uint32_t button_new); +bool qemu_input_is_absolute(void); int qemu_input_scale_axis(int value, int size_in, int size_out); InputEvent *qemu_input_event_new_move(InputEventKind kind, InputAxis axis, int value); diff --git a/ui/input.c b/ui/input.c index fd2293b399..01991cb2c0 100644 --- a/ui/input.c +++ b/ui/input.c @@ -181,6 +181,14 @@ void qemu_input_update_buttons(QemuConsole *src, uint32_t *button_map, } } +bool qemu_input_is_absolute(void) +{ + QemuInputHandlerState *s; + + s = qemu_input_find_handler(INPUT_EVENT_MASK_REL | INPUT_EVENT_MASK_ABS); + return (s != NULL) && (s->handler->mask & INPUT_EVENT_MASK_ABS); +} + int qemu_input_scale_axis(int value, int size_in, int size_out) { if (size_in < 2) { -- cgit v1.2.3-55-g7522 From 21bae11a39570bea2d7c839d01363dafdab608ce Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Wed, 4 Dec 2013 14:08:04 +0100 Subject: input: mouse: switch cocoa ui to new core Build fixes by Peter Maydell. Signed-off-by: Gerd Hoffmann --- include/ui/console.h | 2 ++ ui/cocoa.m | 63 ++++++++++++++++++++++++++++++++++------------------ 2 files changed, 44 insertions(+), 21 deletions(-) (limited to 'include') diff --git a/include/ui/console.h b/include/ui/console.h index 8543d18319..a3062d092c 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -14,6 +14,8 @@ #define MOUSE_EVENT_LBUTTON 0x01 #define MOUSE_EVENT_RBUTTON 0x02 #define MOUSE_EVENT_MBUTTON 0x04 +#define MOUSE_EVENT_WHEELUP 0x08 +#define MOUSE_EVENT_WHEELDN 0x10 /* identical to the ps/2 keyboard bits */ #define QEMU_SCROLL_LOCK_LED (1 << 0) diff --git a/ui/cocoa.m b/ui/cocoa.m index d4af3e5710..f20fd1ffa2 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -27,6 +27,7 @@ #include "qemu-common.h" #include "ui/console.h" +#include "ui/input.h" #include "sysemu/sysemu.h" #ifndef MAC_OS_X_VERSION_10_4 @@ -49,14 +50,6 @@ #endif #define cgrect(nsrect) (*(CGRect *)&(nsrect)) -#define COCOA_MOUSE_EVENT \ - if (isTabletEnabled) { \ - kbd_mouse_event((int)(p.x * 0x7FFF / (screen.width - 1)), (int)((screen.height - p.y) * 0x7FFF / (screen.height - 1)), 0, buttons); \ - } else if (isMouseGrabbed) { \ - kbd_mouse_event((int)[event deltaX], (int)[event deltaY], 0, buttons); \ - } else { \ - [NSApp sendEvent:event]; \ - } typedef struct { int width; @@ -67,6 +60,7 @@ typedef struct { NSWindow *normalWindow; static DisplayChangeListener *dcl; +static int last_buttons; int gArgc; char **gArgv; @@ -501,6 +495,7 @@ QemuCocoaView *cocoaView; int buttons = 0; int keycode; + bool mouse_event = false; NSPoint p = [event locationInWindow]; switch ([event type]) { @@ -620,7 +615,7 @@ QemuCocoaView *cocoaView; } } } - COCOA_MOUSE_EVENT + mouse_event = true; break; case NSLeftMouseDown: if ([event modifierFlags] & NSCommandKeyMask) { @@ -628,15 +623,15 @@ QemuCocoaView *cocoaView; } else { buttons |= MOUSE_EVENT_LBUTTON; } - COCOA_MOUSE_EVENT + mouse_event = true; break; case NSRightMouseDown: buttons |= MOUSE_EVENT_RBUTTON; - COCOA_MOUSE_EVENT + mouse_event = true; break; case NSOtherMouseDown: buttons |= MOUSE_EVENT_MBUTTON; - COCOA_MOUSE_EVENT + mouse_event = true; break; case NSLeftMouseDragged: if ([event modifierFlags] & NSCommandKeyMask) { @@ -644,19 +639,19 @@ QemuCocoaView *cocoaView; } else { buttons |= MOUSE_EVENT_LBUTTON; } - COCOA_MOUSE_EVENT + mouse_event = true; break; case NSRightMouseDragged: buttons |= MOUSE_EVENT_RBUTTON; - COCOA_MOUSE_EVENT + mouse_event = true; break; case NSOtherMouseDragged: buttons |= MOUSE_EVENT_MBUTTON; - COCOA_MOUSE_EVENT + mouse_event = true; break; case NSLeftMouseUp: if (isTabletEnabled) { - COCOA_MOUSE_EVENT + mouse_event = true; } else if (!isMouseGrabbed) { if (p.x > -1 && p.x < screen.width && p.y > -1 && p.y < screen.height) { [self grabMouse]; @@ -664,18 +659,20 @@ QemuCocoaView *cocoaView; [NSApp sendEvent:event]; } } else { - COCOA_MOUSE_EVENT + mouse_event = true; } break; case NSRightMouseUp: - COCOA_MOUSE_EVENT + mouse_event = true; break; case NSOtherMouseUp: - COCOA_MOUSE_EVENT + mouse_event = true; break; case NSScrollWheel: if (isTabletEnabled || isMouseGrabbed) { - kbd_mouse_event(0, 0, -[event deltaY], 0); + buttons |= ([event deltaY] < 0) ? + MOUSE_EVENT_WHEELUP : MOUSE_EVENT_WHEELDN; + mouse_event = true; } else { [NSApp sendEvent:event]; } @@ -683,6 +680,30 @@ QemuCocoaView *cocoaView; default: [NSApp sendEvent:event]; } + + if (mouse_event) { + if (last_buttons != buttons) { + static uint32_t bmap[INPUT_BUTTON_MAX] = { + [INPUT_BUTTON_LEFT] = MOUSE_EVENT_LBUTTON, + [INPUT_BUTTON_MIDDLE] = MOUSE_EVENT_MBUTTON, + [INPUT_BUTTON_RIGHT] = MOUSE_EVENT_RBUTTON, + [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; + } + if (isTabletEnabled) { + qemu_input_queue_abs(dcl->con, INPUT_AXIS_X, p.x, screen.width); + qemu_input_queue_abs(dcl->con, INPUT_AXIS_Y, p.y, screen.height); + } else if (isMouseGrabbed) { + qemu_input_queue_rel(dcl->con, INPUT_AXIS_X, (int)[event deltaX]); + qemu_input_queue_rel(dcl->con, INPUT_AXIS_Y, (int)[event deltaY]); + } else { + [NSApp sendEvent:event]; + } + qemu_input_event_sync(); + } } - (void) grabMouse @@ -1017,7 +1038,7 @@ static void cocoa_refresh(DisplayChangeListener *dcl) COCOA_DEBUG("qemu_cocoa: cocoa_refresh\n"); - if (kbd_mouse_is_absolute()) { + if (qemu_input_is_absolute()) { if (![cocoaView isAbsoluteEnabled]) { if ([cocoaView isMouseGrabbed]) { [cocoaView ungrabMouse]; -- cgit v1.2.3-55-g7522 From faecd955ce3100992a8930a4e96c9bc5e27349ce Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Thu, 5 Dec 2013 08:12:19 +0100 Subject: input-legacy: remove kbd_put_keycode Signed-off-by: Gerd Hoffmann --- include/ui/console.h | 1 - ui/input-legacy.c | 23 ----------------------- 2 files changed, 24 deletions(-) (limited to 'include') diff --git a/include/ui/console.h b/include/ui/console.h index a3062d092c..c7f4e4fb32 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -46,7 +46,6 @@ void qemu_activate_mouse_event_handler(QEMUPutMouseEntry *entry); QEMUPutLEDEntry *qemu_add_led_event_handler(QEMUPutLEDEvent *func, void *opaque); void qemu_remove_led_event_handler(QEMUPutLEDEntry *entry); -void kbd_put_keycode(int keycode); void kbd_put_ledstate(int ledstate); void kbd_mouse_event(int dx, int dy, int dz, int buttons_state); diff --git a/ui/input-legacy.c b/ui/input-legacy.c index dd2dec37dd..3ac30e228f 100644 --- a/ui/input-legacy.c +++ b/ui/input-legacy.c @@ -500,29 +500,6 @@ void qemu_remove_led_event_handler(QEMUPutLEDEntry *entry) g_free(entry); } -void kbd_put_keycode(int keycode) -{ - static bool emul0; - bool up; - - if (keycode == SCANCODE_EMUL0) { - emul0 = true; - return; - } - if (keycode & SCANCODE_UP) { - keycode &= ~SCANCODE_UP; - up = true; - } else { - up = false; - } - if (emul0) { - keycode |= SCANCODE_GREY; - emul0 = false; - } - - qemu_input_event_send_key_number(NULL, keycode, !up); -} - void kbd_put_ledstate(int ledstate) { QEMUPutLEDEntry *cursor; -- cgit v1.2.3-55-g7522 From 16b0ecd16837c5987ebc675ef4a0e1926491dc72 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Thu, 5 Dec 2013 08:19:02 +0100 Subject: input-legacy: remove kbd_mouse_has_absolute Signed-off-by: Gerd Hoffmann --- include/ui/console.h | 3 --- ui/input-legacy.c | 21 ++------------------- 2 files changed, 2 insertions(+), 22 deletions(-) (limited to 'include') diff --git a/include/ui/console.h b/include/ui/console.h index c7f4e4fb32..53e956d474 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -54,9 +54,6 @@ int kbd_mouse_is_absolute(void); void qemu_add_mouse_mode_change_notifier(Notifier *notify); void qemu_remove_mouse_mode_change_notifier(Notifier *notify); -/* Of all the mice, is there one that generates absolute events */ -int kbd_mouse_has_absolute(void); - struct MouseTransformInfo { /* Touchscreen resolution */ int x; diff --git a/ui/input-legacy.c b/ui/input-legacy.c index 3ac30e228f..22796faa4f 100644 --- a/ui/input-legacy.c +++ b/ui/input-legacy.c @@ -366,20 +366,16 @@ void qemu_remove_kbd_event_handler(QEMUPutKbdEntry *entry) static void check_mode_change(void) { - static int current_is_absolute, current_has_absolute; + static int current_is_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) { + if (is_absolute != current_is_absolute) { notifier_list_notify(&mouse_mode_notifiers, NULL); } current_is_absolute = is_absolute; - current_has_absolute = has_absolute; } static void legacy_mouse_event(DeviceState *dev, QemuConsole *src, @@ -567,19 +563,6 @@ int kbd_mouse_is_absolute(void) return QTAILQ_FIRST(&mouse_handlers)->qemu_put_mouse_event_absolute; } -int kbd_mouse_has_absolute(void) -{ - QEMUPutMouseEntry *entry; - - QTAILQ_FOREACH(entry, &mouse_handlers, node) { - if (entry->qemu_put_mouse_event_absolute) { - return 1; - } - } - - return 0; -} - MouseInfoList *qmp_query_mice(Error **errp) { MouseInfoList *mice_list = NULL; -- cgit v1.2.3-55-g7522 From 2d0755d21cdc4bd47a44ccbd5e3ee70ba67b20ec Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Thu, 5 Dec 2013 11:20:39 +0100 Subject: input-legacy: remove kbd_mouse_is_absolute Signed-off-by: Gerd Hoffmann --- include/ui/console.h | 1 - ui/input-legacy.c | 11 +---------- 2 files changed, 1 insertion(+), 11 deletions(-) (limited to 'include') diff --git a/include/ui/console.h b/include/ui/console.h index 53e956d474..21b32e46d7 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -50,7 +50,6 @@ void kbd_put_ledstate(int ledstate); 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(Notifier *notify); void qemu_remove_mouse_mode_change_notifier(Notifier *notify); diff --git a/ui/input-legacy.c b/ui/input-legacy.c index 22796faa4f..412d4011dc 100644 --- a/ui/input-legacy.c +++ b/ui/input-legacy.c @@ -369,7 +369,7 @@ static void check_mode_change(void) static int current_is_absolute; int is_absolute; - is_absolute = kbd_mouse_is_absolute(); + is_absolute = qemu_input_is_absolute(); if (is_absolute != current_is_absolute) { notifier_list_notify(&mouse_mode_notifiers, NULL); @@ -554,15 +554,6 @@ void kbd_mouse_event(int dx, int dy, int dz, int buttons_state) } } -int kbd_mouse_is_absolute(void) -{ - if (QTAILQ_EMPTY(&mouse_handlers)) { - return 0; - } - - return QTAILQ_FIRST(&mouse_handlers)->qemu_put_mouse_event_absolute; -} - MouseInfoList *qmp_query_mice(Error **errp) { MouseInfoList *mice_list = NULL; -- cgit v1.2.3-55-g7522 From 4798648e32112ce92be904bb9d53f8ad0f519c76 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Thu, 5 Dec 2013 11:21:21 +0100 Subject: input-legacy: remove kbd_mouse_event Signed-off-by: Gerd Hoffmann --- include/ui/console.h | 1 - ui/input-legacy.c | 49 ------------------------------------------------- 2 files changed, 50 deletions(-) (limited to 'include') diff --git a/include/ui/console.h b/include/ui/console.h index 21b32e46d7..71a0da3fbf 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -47,7 +47,6 @@ QEMUPutLEDEntry *qemu_add_led_event_handler(QEMUPutLEDEvent *func, void *opaque) void qemu_remove_led_event_handler(QEMUPutLEDEntry *entry); void kbd_put_ledstate(int ledstate); -void kbd_mouse_event(int dx, int dy, int dz, int buttons_state); /* Does the current mouse generate absolute events */ void qemu_add_mouse_mode_change_notifier(Notifier *notify); diff --git a/ui/input-legacy.c b/ui/input-legacy.c index 412d4011dc..26ff06fd8c 100644 --- a/ui/input-legacy.c +++ b/ui/input-legacy.c @@ -505,55 +505,6 @@ void kbd_put_ledstate(int ledstate) } } -void kbd_mouse_event(int dx, int dy, int dz, int buttons_state) -{ - QEMUPutMouseEntry *entry; - QEMUPutMouseEvent *mouse_event; - void *mouse_event_opaque; - int width, height; - - if (!runstate_is_running() && !runstate_check(RUN_STATE_SUSPENDED)) { - return; - } - if (QTAILQ_EMPTY(&mouse_handlers)) { - return; - } - - entry = QTAILQ_FIRST(&mouse_handlers); - - mouse_event = entry->qemu_put_mouse_event; - mouse_event_opaque = entry->qemu_put_mouse_event_opaque; - - if (mouse_event) { - if (entry->qemu_put_mouse_event_absolute) { - width = 0x7fff; - height = 0x7fff; - } else { - width = graphic_width - 1; - height = graphic_height - 1; - } - - switch (graphic_rotate) { - case 0: - mouse_event(mouse_event_opaque, - dx, dy, dz, buttons_state); - break; - case 90: - mouse_event(mouse_event_opaque, - width - dy, dx, dz, buttons_state); - break; - case 180: - mouse_event(mouse_event_opaque, - width - dx, height - dy, dz, buttons_state); - break; - case 270: - mouse_event(mouse_event_opaque, - dy, height - dx, dz, buttons_state); - break; - } - } -} - MouseInfoList *qmp_query_mice(Error **errp) { MouseInfoList *mice_list = NULL; -- cgit v1.2.3-55-g7522 From 4a33f45e2e4c773b47963baf5a8251963bd01e38 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Thu, 5 Dec 2013 11:23:42 +0100 Subject: input: move mouse mode notifier to new core Signed-off-by: Gerd Hoffmann --- include/ui/console.h | 4 ---- include/ui/input.h | 4 ++++ ui/input-legacy.c | 34 +--------------------------------- ui/input.c | 30 ++++++++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 37 deletions(-) (limited to 'include') diff --git a/include/ui/console.h b/include/ui/console.h index 71a0da3fbf..9a282cb077 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -48,10 +48,6 @@ void qemu_remove_led_event_handler(QEMUPutLEDEntry *entry); void kbd_put_ledstate(int ledstate); -/* Does the current mouse generate absolute events */ -void qemu_add_mouse_mode_change_notifier(Notifier *notify); -void qemu_remove_mouse_mode_change_notifier(Notifier *notify); - struct MouseTransformInfo { /* Touchscreen resolution */ int x; diff --git a/include/ui/input.h b/include/ui/input.h index 28afc45c04..4976f3da2c 100644 --- a/include/ui/input.h +++ b/include/ui/input.h @@ -49,4 +49,8 @@ void qemu_input_queue_rel(QemuConsole *src, InputAxis axis, int value); void qemu_input_queue_abs(QemuConsole *src, InputAxis axis, int value, int size); +void qemu_input_check_mode_change(void); +void qemu_add_mouse_mode_change_notifier(Notifier *notify); +void qemu_remove_mouse_mode_change_notifier(Notifier *notify); + #endif /* INPUT_H */ diff --git a/ui/input-legacy.c b/ui/input-legacy.c index 26ff06fd8c..7f8e72b55e 100644 --- a/ui/input-legacy.c +++ b/ui/input-legacy.c @@ -65,8 +65,6 @@ static QTAILQ_HEAD(, QEMUPutLEDEntry) led_handlers = QTAILQ_HEAD_INITIALIZER(led_handlers); static QTAILQ_HEAD(, QEMUPutMouseEntry) mouse_handlers = QTAILQ_HEAD_INITIALIZER(mouse_handlers); -static NotifierList mouse_mode_notifiers = - NOTIFIER_LIST_INITIALIZER(mouse_mode_notifiers); static const int key_defs[] = { [Q_KEY_CODE_SHIFT] = 0x2a, @@ -364,20 +362,6 @@ void qemu_remove_kbd_event_handler(QEMUPutKbdEntry *entry) g_free(entry); } -static void 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; -} - static void legacy_mouse_event(DeviceState *dev, QemuConsole *src, InputEvent *evt) { @@ -448,8 +432,6 @@ QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, s->s = qemu_input_handler_register((DeviceState *)s, &s->h); - check_mode_change(); - return s; } @@ -459,8 +441,6 @@ void qemu_activate_mouse_event_handler(QEMUPutMouseEntry *entry) QTAILQ_INSERT_HEAD(&mouse_handlers, entry, node); qemu_input_handler_activate(entry->s); - - check_mode_change(); } void qemu_remove_mouse_event_handler(QEMUPutMouseEntry *entry) @@ -471,8 +451,6 @@ void qemu_remove_mouse_event_handler(QEMUPutMouseEntry *entry) g_free(entry->qemu_put_mouse_event_name); g_free(entry); - - check_mode_change(); } QEMUPutLEDEntry *qemu_add_led_event_handler(QEMUPutLEDEvent *func, @@ -551,15 +529,5 @@ void do_mouse_set(Monitor *mon, const QDict *qdict) monitor_printf(mon, "Mouse at given index not found\n"); } - check_mode_change(); -} - -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); + qemu_input_check_mode_change(); } 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); +} -- cgit v1.2.3-55-g7522 From 5c07d00f1b33729b23326c57b55e71a9cd9b9310 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Tue, 10 Dec 2013 17:30:15 +0100 Subject: input: remove index_from_keycode (no users) Signed-off-by: Gerd Hoffmann --- include/ui/console.h | 1 - ui/input-legacy.c | 14 -------------- 2 files changed, 15 deletions(-) (limited to 'include') diff --git a/include/ui/console.h b/include/ui/console.h index 9a282cb077..3bf69ee2c2 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -329,7 +329,6 @@ void curses_display_init(DisplayState *ds, int full_screen); /* input.c */ int index_from_key(const char *key); -int index_from_keycode(int code); /* gtk.c */ void early_gtk_display_init(void); diff --git a/ui/input-legacy.c b/ui/input-legacy.c index b51e6ad5df..f38984b192 100644 --- a/ui/input-legacy.c +++ b/ui/input-legacy.c @@ -220,20 +220,6 @@ int index_from_key(const char *key) return i; } -int index_from_keycode(int code) -{ - int i; - - for (i = 0; i < Q_KEY_CODE_MAX; i++) { - if (key_defs[i] == code) { - break; - } - } - - /* Return Q_KEY_CODE_MAX if the code is invalid */ - return i; -} - static int *keycodes; static int keycodes_size; static QEMUTimer *key_timer; -- cgit v1.2.3-55-g7522 From 5643706a095044d75df1c0588aac553a595b972b Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 24 Jan 2014 15:35:21 +0100 Subject: console: add head to index to qemu consoles. Signed-off-by: Gerd Hoffmann --- hw/arm/musicpal.c | 2 +- hw/display/blizzard.c | 2 +- hw/display/cg3.c | 2 +- hw/display/cirrus_vga.c | 4 ++-- hw/display/exynos4210_fimd.c | 2 +- hw/display/g364fb.c | 2 +- hw/display/jazz_led.c | 2 +- hw/display/milkymist-vgafb.c | 2 +- hw/display/omap_lcdc.c | 2 +- hw/display/pl110.c | 2 +- hw/display/pxa2xx_lcd.c | 2 +- hw/display/qxl.c | 4 ++-- hw/display/sm501.c | 2 +- hw/display/ssd0303.c | 2 +- hw/display/ssd0323.c | 2 +- hw/display/tc6393xb.c | 2 +- hw/display/tcx.c | 4 ++-- hw/display/vga-isa-mm.c | 2 +- hw/display/vga-isa.c | 2 +- hw/display/vga-pci.c | 2 +- hw/display/vmware_vga.c | 2 +- hw/unicore32/puv3.c | 2 +- include/ui/console.h | 5 +++-- ui/console.c | 28 ++++++++++++++++++++++++---- 24 files changed, 52 insertions(+), 31 deletions(-) (limited to 'include') diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c index cce7127598..d10b5dbb49 100644 --- a/hw/arm/musicpal.c +++ b/hw/arm/musicpal.c @@ -630,7 +630,7 @@ static int musicpal_lcd_init(SysBusDevice *sbd) "musicpal-lcd", MP_LCD_SIZE); sysbus_init_mmio(sbd, &s->iomem); - s->con = graphic_console_init(dev, &musicpal_gfx_ops, s); + s->con = graphic_console_init(dev, 0, &musicpal_gfx_ops, s); qemu_console_resize(s->con, 128*3, 64*3); qdev_init_gpio_in(dev, musicpal_lcd_gpio_brightness_in, 3); diff --git a/hw/display/blizzard.c b/hw/display/blizzard.c index 4a466c8323..55c0ddf00b 100644 --- a/hw/display/blizzard.c +++ b/hw/display/blizzard.c @@ -956,7 +956,7 @@ void *s1d13745_init(qemu_irq gpio_int) s->fb = g_malloc(0x180000); - s->con = graphic_console_init(NULL, &blizzard_ops, s); + s->con = graphic_console_init(NULL, 0, &blizzard_ops, s); surface = qemu_console_surface(s->con); switch (surface_bits_per_pixel(surface)) { diff --git a/hw/display/cg3.c b/hw/display/cg3.c index 6db8ca362a..a042b9ecbe 100644 --- a/hw/display/cg3.c +++ b/hw/display/cg3.c @@ -306,7 +306,7 @@ static void cg3_realizefn(DeviceState *dev, Error **errp) sysbus_init_irq(sbd, &s->irq); - s->con = graphic_console_init(DEVICE(dev), &cg3_ops, s); + s->con = graphic_console_init(DEVICE(dev), 0, &cg3_ops, s); qemu_console_resize(s->con, s->width, s->height); } diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c index 3a8fc0bf8e..0d3127da21 100644 --- a/hw/display/cirrus_vga.c +++ b/hw/display/cirrus_vga.c @@ -2917,7 +2917,7 @@ static void isa_cirrus_vga_realizefn(DeviceState *dev, Error **errp) cirrus_init_common(&d->cirrus_vga, OBJECT(dev), CIRRUS_ID_CLGD5430, 0, isa_address_space(isadev), isa_address_space_io(isadev)); - s->con = graphic_console_init(dev, s->hw_ops, s); + s->con = graphic_console_init(dev, 0, s->hw_ops, s); rom_add_vga(VGABIOS_CIRRUS_FILENAME); /* XXX ISA-LFB support */ /* FIXME not qdev yet */ @@ -2963,7 +2963,7 @@ static int pci_cirrus_vga_initfn(PCIDevice *dev) vga_common_init(&s->vga, OBJECT(dev)); cirrus_init_common(s, OBJECT(dev), device_id, 1, pci_address_space(dev), pci_address_space_io(dev)); - s->vga.con = graphic_console_init(DEVICE(dev), s->vga.hw_ops, &s->vga); + s->vga.con = graphic_console_init(DEVICE(dev), 0, s->vga.hw_ops, &s->vga); /* setup PCI */ diff --git a/hw/display/exynos4210_fimd.c b/hw/display/exynos4210_fimd.c index 65cca1d707..9750330c25 100644 --- a/hw/display/exynos4210_fimd.c +++ b/hw/display/exynos4210_fimd.c @@ -1917,7 +1917,7 @@ static int exynos4210_fimd_init(SysBusDevice *dev) memory_region_init_io(&s->iomem, OBJECT(s), &exynos4210_fimd_mmio_ops, s, "exynos4210.fimd", FIMD_REGS_SIZE); sysbus_init_mmio(dev, &s->iomem); - s->console = graphic_console_init(DEVICE(dev), &exynos4210_fimd_ops, s); + s->console = graphic_console_init(DEVICE(dev), 0, &exynos4210_fimd_ops, s); return 0; } diff --git a/hw/display/g364fb.c b/hw/display/g364fb.c index bc909bb3de..5c6a2d3605 100644 --- a/hw/display/g364fb.c +++ b/hw/display/g364fb.c @@ -484,7 +484,7 @@ static void g364fb_init(DeviceState *dev, G364State *s) { s->vram = g_malloc0(s->vram_size); - s->con = graphic_console_init(dev, &g364fb_ops, s); + s->con = graphic_console_init(dev, 0, &g364fb_ops, s); memory_region_init_io(&s->mem_ctrl, NULL, &g364fb_ctrl_ops, s, "ctrl", 0x180000); memory_region_init_ram_ptr(&s->mem_vram, NULL, "vram", diff --git a/hw/display/jazz_led.c b/hw/display/jazz_led.c index 8407e6c2ef..f9e7d7c981 100644 --- a/hw/display/jazz_led.c +++ b/hw/display/jazz_led.c @@ -271,7 +271,7 @@ static int jazz_led_init(SysBusDevice *dev) memory_region_init_io(&s->iomem, OBJECT(s), &led_ops, s, "led", 1); sysbus_init_mmio(dev, &s->iomem); - s->con = graphic_console_init(DEVICE(dev), &jazz_led_ops, s); + s->con = graphic_console_init(DEVICE(dev), 0, &jazz_led_ops, s); return 0; } diff --git a/hw/display/milkymist-vgafb.c b/hw/display/milkymist-vgafb.c index 5150cb48b7..603537aabb 100644 --- a/hw/display/milkymist-vgafb.c +++ b/hw/display/milkymist-vgafb.c @@ -290,7 +290,7 @@ static int milkymist_vgafb_init(SysBusDevice *dev) "milkymist-vgafb", R_MAX * 4); sysbus_init_mmio(dev, &s->regs_region); - s->con = graphic_console_init(DEVICE(dev), &vgafb_ops, s); + s->con = graphic_console_init(DEVICE(dev), 0, &vgafb_ops, s); return 0; } diff --git a/hw/display/omap_lcdc.c b/hw/display/omap_lcdc.c index c3b9b68971..fda81baff0 100644 --- a/hw/display/omap_lcdc.c +++ b/hw/display/omap_lcdc.c @@ -406,7 +406,7 @@ struct omap_lcd_panel_s *omap_lcdc_init(MemoryRegion *sysmem, memory_region_init_io(&s->iomem, NULL, &omap_lcdc_ops, s, "omap.lcdc", 0x100); memory_region_add_subregion(sysmem, base, &s->iomem); - s->con = graphic_console_init(NULL, &omap_ops, s); + s->con = graphic_console_init(NULL, 0, &omap_ops, s); return s; } diff --git a/hw/display/pl110.c b/hw/display/pl110.c index ab689e9aae..c574cf1a81 100644 --- a/hw/display/pl110.c +++ b/hw/display/pl110.c @@ -464,7 +464,7 @@ static int pl110_initfn(SysBusDevice *sbd) sysbus_init_mmio(sbd, &s->iomem); sysbus_init_irq(sbd, &s->irq); qdev_init_gpio_in(dev, pl110_mux_ctrl_set, 1); - s->con = graphic_console_init(dev, &pl110_gfx_ops, s); + s->con = graphic_console_init(dev, 0, &pl110_gfx_ops, s); return 0; } diff --git a/hw/display/pxa2xx_lcd.c b/hw/display/pxa2xx_lcd.c index 990931ae45..09cdf17ab9 100644 --- a/hw/display/pxa2xx_lcd.c +++ b/hw/display/pxa2xx_lcd.c @@ -1013,7 +1013,7 @@ PXA2xxLCDState *pxa2xx_lcdc_init(MemoryRegion *sysmem, "pxa2xx-lcd-controller", 0x00100000); memory_region_add_subregion(sysmem, base, &s->iomem); - s->con = graphic_console_init(NULL, &pxa2xx_ops, s); + s->con = graphic_console_init(NULL, 0, &pxa2xx_ops, s); surface = qemu_console_surface(s->con); switch (surface_bits_per_pixel(surface)) { diff --git a/hw/display/qxl.c b/hw/display/qxl.c index 2a559ebcc9..47bbf1f1fe 100644 --- a/hw/display/qxl.c +++ b/hw/display/qxl.c @@ -2069,7 +2069,7 @@ static int qxl_init_primary(PCIDevice *dev) portio_list_set_flush_coalesced(qxl_vga_port_list); portio_list_add(qxl_vga_port_list, pci_address_space_io(dev), 0x3b0); - vga->con = graphic_console_init(DEVICE(dev), &qxl_ops, qxl); + vga->con = graphic_console_init(DEVICE(dev), 0, &qxl_ops, qxl); qemu_spice_display_init_common(&qxl->ssd); rc = qxl_init_common(qxl); @@ -2094,7 +2094,7 @@ static int qxl_init_secondary(PCIDevice *dev) qxl->vga.vram_size); vmstate_register_ram(&qxl->vga.vram, &qxl->pci.qdev); qxl->vga.vram_ptr = memory_region_get_ram_ptr(&qxl->vga.vram); - qxl->vga.con = graphic_console_init(DEVICE(dev), &qxl_ops, qxl); + qxl->vga.con = graphic_console_init(DEVICE(dev), 0, &qxl_ops, qxl); return qxl_init_common(qxl); } diff --git a/hw/display/sm501.c b/hw/display/sm501.c index 0b5f993594..eedf2d48e0 100644 --- a/hw/display/sm501.c +++ b/hw/display/sm501.c @@ -1449,5 +1449,5 @@ void sm501_init(MemoryRegion *address_space_mem, uint32_t base, } /* create qemu graphic console */ - s->con = graphic_console_init(DEVICE(dev), &sm501_ops, s); + s->con = graphic_console_init(DEVICE(dev), 0, &sm501_ops, s); } diff --git a/hw/display/ssd0303.c b/hw/display/ssd0303.c index 89804e108b..c2eea04934 100644 --- a/hw/display/ssd0303.c +++ b/hw/display/ssd0303.c @@ -299,7 +299,7 @@ static int ssd0303_init(I2CSlave *i2c) { ssd0303_state *s = SSD0303(i2c); - s->con = graphic_console_init(DEVICE(i2c), &ssd0303_ops, s); + s->con = graphic_console_init(DEVICE(i2c), 0, &ssd0303_ops, s); qemu_console_resize(s->con, 96 * MAGNIFY, 16 * MAGNIFY); return 0; } diff --git a/hw/display/ssd0323.c b/hw/display/ssd0323.c index c3231c6116..46c3b40c79 100644 --- a/hw/display/ssd0323.c +++ b/hw/display/ssd0323.c @@ -342,7 +342,7 @@ static int ssd0323_init(SSISlave *dev) s->col_end = 63; s->row_end = 79; - s->con = graphic_console_init(DEVICE(dev), &ssd0323_ops, s); + s->con = graphic_console_init(DEVICE(dev), 0, &ssd0323_ops, s); qemu_console_resize(s->con, 128 * MAGNIFY, 64 * MAGNIFY); qdev_init_gpio_in(&dev->qdev, ssd0323_cd, 1); diff --git a/hw/display/tc6393xb.c b/hw/display/tc6393xb.c index 3dd9b98eca..f4011d2db0 100644 --- a/hw/display/tc6393xb.c +++ b/hw/display/tc6393xb.c @@ -587,7 +587,7 @@ TC6393xbState *tc6393xb_init(MemoryRegion *sysmem, uint32_t base, qemu_irq irq) memory_region_add_subregion(sysmem, base + 0x100000, &s->vram); s->scr_width = 480; s->scr_height = 640; - s->con = graphic_console_init(NULL, &tc6393xb_gfx_ops, s); + s->con = graphic_console_init(NULL, 0, &tc6393xb_gfx_ops, s); return s; } diff --git a/hw/display/tcx.c b/hw/display/tcx.c index e60769c2c9..2b37ffac4c 100644 --- a/hw/display/tcx.c +++ b/hw/display/tcx.c @@ -602,14 +602,14 @@ static int tcx_init1(SysBusDevice *dev) &s->vram_mem, vram_offset, size); sysbus_init_mmio(dev, &s->vram_cplane); - s->con = graphic_console_init(DEVICE(dev), &tcx24_ops, s); + s->con = graphic_console_init(DEVICE(dev), 0, &tcx24_ops, s); } else { /* THC 8 bit (dummy) */ memory_region_init_io(&s->thc8, OBJECT(s), &dummy_ops, s, "tcx.thc8", TCX_THC_NREGS_8); sysbus_init_mmio(dev, &s->thc8); - s->con = graphic_console_init(DEVICE(dev), &tcx_ops, s); + s->con = graphic_console_init(DEVICE(dev), 0, &tcx_ops, s); } qemu_console_resize(s->con, s->width, s->height); diff --git a/hw/display/vga-isa-mm.c b/hw/display/vga-isa-mm.c index 8b514cc39d..afc46b8c9d 100644 --- a/hw/display/vga-isa-mm.c +++ b/hw/display/vga-isa-mm.c @@ -135,7 +135,7 @@ int isa_vga_mm_init(hwaddr vram_base, vga_common_init(&s->vga, NULL); vga_mm_init(s, vram_base, ctrl_base, it_shift, address_space); - s->vga.con = graphic_console_init(NULL, s->vga.hw_ops, s); + s->vga.con = graphic_console_init(NULL, 0, s->vga.hw_ops, s); vga_init_vbe(&s->vga, NULL, address_space); return 0; diff --git a/hw/display/vga-isa.c b/hw/display/vga-isa.c index c2a19ad6ba..1d9ea6b51d 100644 --- a/hw/display/vga-isa.c +++ b/hw/display/vga-isa.c @@ -67,7 +67,7 @@ static void vga_isa_realizefn(DeviceState *dev, Error **errp) isa_mem_base + 0x000a0000, vga_io_memory, 1); memory_region_set_coalescing(vga_io_memory); - s->con = graphic_console_init(DEVICE(dev), s->hw_ops, s); + s->con = graphic_console_init(DEVICE(dev), 0, s->hw_ops, s); vga_init_vbe(s, OBJECT(dev), isa_address_space(isadev)); /* ROM BIOS */ diff --git a/hw/display/vga-pci.c b/hw/display/vga-pci.c index f74fc43aa6..574ea0e7f9 100644 --- a/hw/display/vga-pci.c +++ b/hw/display/vga-pci.c @@ -151,7 +151,7 @@ static int pci_std_vga_initfn(PCIDevice *dev) vga_init(s, OBJECT(dev), pci_address_space(dev), pci_address_space_io(dev), true); - s->con = graphic_console_init(DEVICE(dev), s->hw_ops, s); + s->con = graphic_console_init(DEVICE(dev), 0, s->hw_ops, s); /* XXX: VGA_RAM_SIZE must be a power of two */ pci_register_bar(&d->dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->vram); diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c index 334e71856e..bd2c108c42 100644 --- a/hw/display/vmware_vga.c +++ b/hw/display/vmware_vga.c @@ -1199,7 +1199,7 @@ static void vmsvga_init(DeviceState *dev, struct vmsvga_state_s *s, s->scratch_size = SVGA_SCRATCH_SIZE; s->scratch = g_malloc(s->scratch_size * 4); - s->vga.con = graphic_console_init(dev, &vmsvga_ops, s); + s->vga.con = graphic_console_init(dev, 0, &vmsvga_ops, s); s->fifo_size = SVGA_FIFO_SIZE; memory_region_init_ram(&s->fifo_ram, NULL, "vmsvga.fifo", s->fifo_size); diff --git a/hw/unicore32/puv3.c b/hw/unicore32/puv3.c index e05cbc131e..42913b6a5a 100644 --- a/hw/unicore32/puv3.c +++ b/hw/unicore32/puv3.c @@ -98,7 +98,7 @@ static void puv3_load_kernel(const char *kernel_filename) } /* cheat curses that we have a graphic console, only under ocd console */ - graphic_console_init(NULL, &no_ops, NULL); + graphic_console_init(NULL, 0, &no_ops, NULL); } static void puv3_init(QEMUMachineInitArgs *args) diff --git a/include/ui/console.h b/include/ui/console.h index 3bf69ee2c2..b2af53e5e6 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -268,7 +268,7 @@ typedef struct GraphicHwOps { void (*update_interval)(void *opaque, uint64_t interval); } GraphicHwOps; -QemuConsole *graphic_console_init(DeviceState *dev, +QemuConsole *graphic_console_init(DeviceState *dev, uint32_t head, const GraphicHwOps *ops, void *opaque); @@ -277,11 +277,12 @@ void graphic_hw_invalidate(QemuConsole *con); void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata); QemuConsole *qemu_console_lookup_by_index(unsigned int index); -QemuConsole *qemu_console_lookup_by_device(DeviceState *dev); +QemuConsole *qemu_console_lookup_by_device(DeviceState *dev, uint32_t head); bool qemu_console_is_visible(QemuConsole *con); bool qemu_console_is_graphic(QemuConsole *con); bool qemu_console_is_fixedsize(QemuConsole *con); int qemu_console_get_index(QemuConsole *con); +uint32_t qemu_console_get_head(QemuConsole *con); int qemu_console_get_width(QemuConsole *con, int fallback); int qemu_console_get_height(QemuConsole *con, int fallback); diff --git a/ui/console.c b/ui/console.c index 0bbefe545f..0a4f9128a5 100644 --- a/ui/console.c +++ b/ui/console.c @@ -124,6 +124,7 @@ struct QemuConsole { /* Graphic console state. */ Object *device; + uint32_t head; const GraphicHwOps *hw_ops; void *hw; @@ -1179,6 +1180,8 @@ static QemuConsole *new_console(DisplayState *ds, console_type_t console_type) s = QEMU_CONSOLE(obj); object_property_add_link(obj, "device", TYPE_DEVICE, (Object **)&s->device, &local_err); + object_property_add_uint32_ptr(obj, "head", + &s->head, &local_err); if (!active_console || ((active_console->console_type != GRAPHIC_CONSOLE) && (console_type == GRAPHIC_CONSOLE))) { @@ -1569,7 +1572,7 @@ DisplayState *init_displaystate(void) return display_state; } -QemuConsole *graphic_console_init(DeviceState *dev, +QemuConsole *graphic_console_init(DeviceState *dev, uint32_t head, const GraphicHwOps *hw_ops, void *opaque) { @@ -1587,6 +1590,8 @@ QemuConsole *graphic_console_init(DeviceState *dev, if (dev) { object_property_set_link(OBJECT(s), OBJECT(dev), "device", &local_err); + object_property_set_int(OBJECT(s), head, + "head", &local_err); } s->surface = qemu_create_displaysurface(width, height); @@ -1601,10 +1606,11 @@ QemuConsole *qemu_console_lookup_by_index(unsigned int index) return consoles[index]; } -QemuConsole *qemu_console_lookup_by_device(DeviceState *dev) +QemuConsole *qemu_console_lookup_by_device(DeviceState *dev, uint32_t head) { Error *local_err = NULL; Object *obj; + uint32_t h; int i; for (i = 0; i < nb_consoles; i++) { @@ -1613,9 +1619,15 @@ QemuConsole *qemu_console_lookup_by_device(DeviceState *dev) } obj = object_property_get_link(OBJECT(consoles[i]), "device", &local_err); - if (DEVICE(obj) == dev) { - return consoles[i]; + if (DEVICE(obj) != dev) { + continue; + } + h = object_property_get_int(OBJECT(consoles[i]), + "head", &local_err); + if (h != head) { + continue; } + return consoles[i]; } return NULL; } @@ -1649,6 +1661,14 @@ int qemu_console_get_index(QemuConsole *con) return con ? con->index : -1; } +uint32_t qemu_console_get_head(QemuConsole *con) +{ + if (con == NULL) { + con = active_console; + } + return con ? con->head : -1; +} + int qemu_console_get_width(QemuConsole *con, int fallback) { if (con == NULL) { -- cgit v1.2.3-55-g7522 From 6f90f3d786ec1ddae31535bb4be4a1120fd5dfe0 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 24 Jan 2014 17:38:20 +0100 Subject: console: add QemuUIInfo Signed-off-by: Gerd Hoffmann --- include/ui/console.h | 12 ++++++++++++ ui/console.c | 17 +++++++++++++++++ 2 files changed, 29 insertions(+) (limited to 'include') diff --git a/include/ui/console.h b/include/ui/console.h index b2af53e5e6..08a38eab13 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -120,6 +120,14 @@ struct DisplaySurface { struct PixelFormat pf; }; +typedef struct QemuUIInfo { + /* geometry */ + int xoff; + int yoff; + uint32_t width; + uint32_t height; +} QemuUIInfo; + /* cursor data format is 32bit RGBA */ typedef struct QEMUCursor { int width, height; @@ -204,6 +212,8 @@ void update_displaychangelistener(DisplayChangeListener *dcl, uint64_t interval); void unregister_displaychangelistener(DisplayChangeListener *dcl); +int dpy_set_ui_info(QemuConsole *con, QemuUIInfo *info); + void dpy_gfx_update(QemuConsole *con, int x, int y, int w, int h); void dpy_gfx_replace_surface(QemuConsole *con, DisplaySurface *surface); @@ -266,6 +276,7 @@ typedef struct GraphicHwOps { void (*gfx_update)(void *opaque); void (*text_update)(void *opaque, console_ch_t *text); void (*update_interval)(void *opaque, uint64_t interval); + int (*ui_info)(void *opaque, uint32_t head, QemuUIInfo *info); } GraphicHwOps; QemuConsole *graphic_console_init(DeviceState *dev, uint32_t head, @@ -283,6 +294,7 @@ bool qemu_console_is_graphic(QemuConsole *con); bool qemu_console_is_fixedsize(QemuConsole *con); int qemu_console_get_index(QemuConsole *con); uint32_t qemu_console_get_head(QemuConsole *con); +QemuUIInfo *qemu_console_get_ui_info(QemuConsole *con); int qemu_console_get_width(QemuConsole *con, int fallback); int qemu_console_get_height(QemuConsole *con, int fallback); diff --git a/ui/console.c b/ui/console.c index 0a4f9128a5..4df251d579 100644 --- a/ui/console.c +++ b/ui/console.c @@ -125,6 +125,7 @@ struct QemuConsole { /* Graphic console state. */ Object *device; uint32_t head; + QemuUIInfo ui_info; const GraphicHwOps *hw_ops; void *hw; @@ -1347,6 +1348,16 @@ void unregister_displaychangelistener(DisplayChangeListener *dcl) gui_setup_refresh(ds); } +int dpy_set_ui_info(QemuConsole *con, QemuUIInfo *info) +{ + assert(con != NULL); + con->ui_info = *info; + if (con->hw_ops->ui_info) { + return con->hw_ops->ui_info(con->hw, con->head, info); + } + return -1; +} + void dpy_gfx_update(QemuConsole *con, int x, int y, int w, int h) { DisplayState *s = con->ds; @@ -1669,6 +1680,12 @@ uint32_t qemu_console_get_head(QemuConsole *con) return con ? con->head : -1; } +QemuUIInfo *qemu_console_get_ui_info(QemuConsole *con) +{ + assert(con != NULL); + return &con->ui_info; +} + int qemu_console_get_width(QemuConsole *con, int fallback) { if (con == NULL) { -- cgit v1.2.3-55-g7522