From f5360a0d287923dcf8f1f25acdd8b772970175cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Wed, 30 Aug 2023 13:38:19 +0400 Subject: [PATCH] ui/vc: remove kbd_put_keysym() and update function calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The function calls to `kbd_put_keysym` have been updated to now call `kbd_put_keysym_console` with a NULL console parameter. Like most console functions, NULL argument is now for the active console. This will allow to rename the text console functions in a consistent manner. Signed-off-by: Marc-André Lureau Reviewed-by: Akihiko Odaki --- include/ui/console.h | 1 - ui/cocoa.m | 2 +- ui/console.c | 14 ++++++------ ui/curses.c | 2 +- ui/vnc.c | 54 ++++++++++++++++++++++---------------------- 5 files changed, 36 insertions(+), 37 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index 1ccd432b4d..9c362f0e87 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -115,7 +115,6 @@ bool qemu_mouse_set(int index, Error **errp); void kbd_put_keysym_console(QemuTextConsole *s, int keysym); bool kbd_put_qcode_console(QemuTextConsole *s, int qcode, bool ctrl); void kbd_put_string_console(QemuTextConsole *s, const char *str, int len); -void kbd_put_keysym(int keysym); /* Touch devices */ typedef struct touch_slot { diff --git a/ui/cocoa.m b/ui/cocoa.m index 4d8989c4eb..90a89c5c8e 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -784,7 +784,7 @@ static CGEventRef handleTapEvent(CGEventTapProxy proxy, CGEventType type, CGEven } if (keysym) { - kbd_put_keysym(keysym); + kbd_put_keysym_console(NULL, keysym); } } diff --git a/ui/console.c b/ui/console.c index e4d61794bb..4c07791ac7 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1141,6 +1141,13 @@ void kbd_put_keysym_console(QemuTextConsole *s, int keysym) int c; uint32_t num_free; + if (!s) { + if (!QEMU_IS_TEXT_CONSOLE(active_console)) { + return; + } + s = QEMU_TEXT_CONSOLE(active_console); + } + switch(keysym) { case QEMU_KEY_CTRL_UP: console_scroll(s, -1); @@ -1231,13 +1238,6 @@ void kbd_put_string_console(QemuTextConsole *s, const char *str, int len) } } -void kbd_put_keysym(int keysym) -{ - if (QEMU_IS_TEXT_CONSOLE(active_console)) { - kbd_put_keysym_console(QEMU_TEXT_CONSOLE(active_console), keysym); - } -} - static void text_console_invalidate(void *opaque) { QemuTextConsole *s = QEMU_TEXT_CONSOLE(opaque); diff --git a/ui/curses.c b/ui/curses.c index de962faa7c..4ddbbae7cd 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -400,7 +400,7 @@ static void curses_refresh(DisplayChangeListener *dcl) if (keysym == -1) keysym = chr; - kbd_put_keysym(keysym); + kbd_put_keysym_console(NULL, keysym); } } } diff --git a/ui/vnc.c b/ui/vnc.c index 92964dcc0c..1fa4456744 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -1945,88 +1945,88 @@ static void do_key_event(VncState *vs, int down, int keycode, int sym) case 0xb8: /* Right ALT */ break; case 0xc8: - kbd_put_keysym(QEMU_KEY_UP); + kbd_put_keysym_console(NULL, QEMU_KEY_UP); break; case 0xd0: - kbd_put_keysym(QEMU_KEY_DOWN); + kbd_put_keysym_console(NULL, QEMU_KEY_DOWN); break; case 0xcb: - kbd_put_keysym(QEMU_KEY_LEFT); + kbd_put_keysym_console(NULL, QEMU_KEY_LEFT); break; case 0xcd: - kbd_put_keysym(QEMU_KEY_RIGHT); + kbd_put_keysym_console(NULL, QEMU_KEY_RIGHT); break; case 0xd3: - kbd_put_keysym(QEMU_KEY_DELETE); + kbd_put_keysym_console(NULL, QEMU_KEY_DELETE); break; case 0xc7: - kbd_put_keysym(QEMU_KEY_HOME); + kbd_put_keysym_console(NULL, QEMU_KEY_HOME); break; case 0xcf: - kbd_put_keysym(QEMU_KEY_END); + kbd_put_keysym_console(NULL, QEMU_KEY_END); break; case 0xc9: - kbd_put_keysym(QEMU_KEY_PAGEUP); + kbd_put_keysym_console(NULL, QEMU_KEY_PAGEUP); break; case 0xd1: - kbd_put_keysym(QEMU_KEY_PAGEDOWN); + kbd_put_keysym_console(NULL, QEMU_KEY_PAGEDOWN); break; case 0x47: - kbd_put_keysym(numlock ? '7' : QEMU_KEY_HOME); + kbd_put_keysym_console(NULL, numlock ? '7' : QEMU_KEY_HOME); break; case 0x48: - kbd_put_keysym(numlock ? '8' : QEMU_KEY_UP); + kbd_put_keysym_console(NULL, numlock ? '8' : QEMU_KEY_UP); break; case 0x49: - kbd_put_keysym(numlock ? '9' : QEMU_KEY_PAGEUP); + kbd_put_keysym_console(NULL, numlock ? '9' : QEMU_KEY_PAGEUP); break; case 0x4b: - kbd_put_keysym(numlock ? '4' : QEMU_KEY_LEFT); + kbd_put_keysym_console(NULL, numlock ? '4' : QEMU_KEY_LEFT); break; case 0x4c: - kbd_put_keysym('5'); + kbd_put_keysym_console(NULL, '5'); break; case 0x4d: - kbd_put_keysym(numlock ? '6' : QEMU_KEY_RIGHT); + kbd_put_keysym_console(NULL, numlock ? '6' : QEMU_KEY_RIGHT); break; case 0x4f: - kbd_put_keysym(numlock ? '1' : QEMU_KEY_END); + kbd_put_keysym_console(NULL, numlock ? '1' : QEMU_KEY_END); break; case 0x50: - kbd_put_keysym(numlock ? '2' : QEMU_KEY_DOWN); + kbd_put_keysym_console(NULL, numlock ? '2' : QEMU_KEY_DOWN); break; case 0x51: - kbd_put_keysym(numlock ? '3' : QEMU_KEY_PAGEDOWN); + kbd_put_keysym_console(NULL, numlock ? '3' : QEMU_KEY_PAGEDOWN); break; case 0x52: - kbd_put_keysym('0'); + kbd_put_keysym_console(NULL, '0'); break; case 0x53: - kbd_put_keysym(numlock ? '.' : QEMU_KEY_DELETE); + kbd_put_keysym_console(NULL, numlock ? '.' : QEMU_KEY_DELETE); break; case 0xb5: - kbd_put_keysym('/'); + kbd_put_keysym_console(NULL, '/'); break; case 0x37: - kbd_put_keysym('*'); + kbd_put_keysym_console(NULL, '*'); break; case 0x4a: - kbd_put_keysym('-'); + kbd_put_keysym_console(NULL, '-'); break; case 0x4e: - kbd_put_keysym('+'); + kbd_put_keysym_console(NULL, '+'); break; case 0x9c: - kbd_put_keysym('\n'); + kbd_put_keysym_console(NULL, '\n'); break; default: if (control) { - kbd_put_keysym(sym & 0x1f); + kbd_put_keysym_console(NULL, sym & 0x1f); } else { - kbd_put_keysym(sym); + kbd_put_keysym_console(NULL, sym); } break; }