[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 48/67] ui/vc: preliminary QemuTextConsole changes before split
From: |
marcandre . lureau |
Subject: |
[PATCH 48/67] ui/vc: preliminary QemuTextConsole changes before split |
Date: |
Wed, 30 Aug 2023 13:38:22 +0400 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Those changes will help to split console.c unit in the following commit.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/console.c | 52 +++++++++++++++++++++++++++++++++++-----------------
1 file changed, 35 insertions(+), 17 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index f7bc27f596..c2c1f22979 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -174,7 +174,7 @@ static QEMUTimer *cursor_timer;
static void dpy_refresh(DisplayState *s);
static DisplayState *get_alloc_displaystate(void);
-static void text_console_update_cursor(void *opaque);
+static void qemu_text_console_update_cursor(void *opaque);
static bool displaychangelistener_has_dmabuf(DisplayChangeListener *dcl);
static bool console_compatible_with(QemuConsole *con,
DisplayChangeListener *dcl, Error **errp);
@@ -1065,6 +1065,13 @@ static void
displaychangelistener_display_console(DisplayChangeListener *dcl,
}
}
+static void
+qemu_text_console_select(QemuTextConsole *c)
+{
+ dpy_text_resize(QEMU_CONSOLE(c), c->width, c->height);
+ qemu_text_console_update_cursor(NULL);
+}
+
void console_select(unsigned int index)
{
DisplayChangeListener *dcl;
@@ -1084,8 +1091,7 @@ void console_select(unsigned int index)
}
if (QEMU_IS_TEXT_CONSOLE(s)) {
- dpy_text_resize(s, QEMU_TEXT_CONSOLE(s)->width,
QEMU_TEXT_CONSOLE(s)->height);
- text_console_update_cursor(NULL);
+ qemu_text_console_select(QEMU_TEXT_CONSOLE(s));
}
}
}
@@ -1135,19 +1141,12 @@ static void kbd_send_chars(QemuTextConsole *s)
}
/* called when an ascii key is pressed */
-void qemu_text_console_put_keysym(QemuTextConsole *s, int keysym)
+static void qemu_text_console_handle_keysym(QemuTextConsole *s, int keysym)
{
uint8_t buf[16], *q;
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);
@@ -1192,6 +1191,18 @@ void qemu_text_console_put_keysym(QemuTextConsole *s,
int keysym)
}
}
+void qemu_text_console_put_keysym(QemuTextConsole *s, int keysym)
+{
+ if (!s) {
+ if (!QEMU_IS_TEXT_CONSOLE(active_console)) {
+ return;
+ }
+ s = QEMU_TEXT_CONSOLE(active_console);
+ }
+
+ qemu_text_console_handle_keysym(s, keysym);
+}
+
static const int qcode_to_keysym[Q_KEY_CODE__MAX] = {
[Q_KEY_CODE_UP] = QEMU_KEY_UP,
[Q_KEY_CODE_DOWN] = QEMU_KEY_DOWN,
@@ -1395,7 +1406,7 @@ qemu_text_console_class_init(ObjectClass *oc, void *data)
{
if (!cursor_timer) {
cursor_timer = timer_new_ms(QEMU_CLOCK_REALTIME,
- text_console_update_cursor, NULL);
+ qemu_text_console_update_cursor, NULL);
}
}
@@ -1701,7 +1712,7 @@ void register_displaychangelistener(DisplayChangeListener
*dcl)
if (QEMU_IS_GRAPHIC_CONSOLE(con)) {
dcl_set_graphic_cursor(dcl, QEMU_GRAPHIC_CONSOLE(con));
}
- text_console_update_cursor(NULL);
+ qemu_text_console_update_cursor(NULL);
}
void update_displaychangelistener(DisplayChangeListener *dcl,
@@ -2388,6 +2399,13 @@ bool qemu_console_is_multihead(DeviceState *dev)
return false;
}
+
+static const char *
+qemu_text_console_get_label(QemuTextConsole *c)
+{
+ return c->chr ? c->chr->label : NULL;
+}
+
char *qemu_console_get_label(QemuConsole *con)
{
if (QEMU_IS_GRAPHIC_CONSOLE(con)) {
@@ -2411,9 +2429,9 @@ char *qemu_console_get_label(QemuConsole *con)
}
return g_strdup("VGA");
} else if (QEMU_IS_TEXT_CONSOLE(con)) {
- QemuTextConsole *c = QEMU_TEXT_CONSOLE(con);
- if (c->chr && c->chr->label) {
- return g_strdup(c->chr->label);
+ const char *label =
qemu_text_console_get_label(QEMU_TEXT_CONSOLE(con));
+ if (label) {
+ return g_strdup(label);
}
}
@@ -2513,7 +2531,7 @@ int qemu_invalidate_text_consoles(void)
return count;
}
-static void text_console_update_cursor(void *opaque)
+static void qemu_text_console_update_cursor(void *opaque)
{
cursor_visible_phase = !cursor_visible_phase;
--
2.41.0
- Re: [PATCH 37/67] ui/console: rename vga_ functions → qemu_console_, (continued)
- [PATCH 41/67] ui/console: minor stylistic changes, marcandre . lureau, 2023/08/30
- [PATCH 42/67] ui/vc: move text console invalidate in helper, marcandre . lureau, 2023/08/30
- [PATCH 43/67] ui/vc: do not parse VC-specific options in Spice and GTK, marcandre . lureau, 2023/08/30
- [PATCH 45/67] ui/vc: remove kby_put_keysym() and update function calls, marcandre . lureau, 2023/08/30
- [PATCH 46/67] ui/vc: rename kbd_put → qemu_text_console functions, marcandre . lureau, 2023/08/30
- [PATCH 44/67] ui/vc: change the argument for QemuTextConsole, marcandre . lureau, 2023/08/30
- [PATCH 48/67] ui/vc: preliminary QemuTextConsole changes before split,
marcandre . lureau <=
- [PATCH 47/67] ui/console: remove redundant format field, marcandre . lureau, 2023/08/30
- [PATCH 50/67] ui/console: move DisplaySurface to its own header, marcandre . lureau, 2023/08/30
- [PATCH 52/67] ui: compile out some qemu-pixman functions when !PIXMAN, marcandre . lureau, 2023/08/30
- [PATCH 56/67] virtio-gpu: replace PIXMAN for region/rect test, marcandre . lureau, 2023/08/30
- [PATCH 54/67] ui/vc: console-vc requires PIXMAN, marcandre . lureau, 2023/08/30
- [PATCH 55/67] qmp/hmp: disable screendump if PIXMAN is missing, marcandre . lureau, 2023/08/30
- [PATCH 49/67] ui/vc: split off the VC part from console.c, marcandre . lureau, 2023/08/30
- [PATCH 51/67] build-sys: add optional "pixman" feature, marcandre . lureau, 2023/08/30