ui/console-vc: move cursor blinking logic into VT100 layer
Maintain a list of QemuVT100 instances so the cursor timer can directly iterate over them and call vt100_refresh(), instead of going through qemu_invalidate_text_consoles() which iterated over all consoles (including graphic ones) and called back into the generic display layer. This removes the qemu_invalidate_text_consoles() function from console.c, further decoupling VT100 text rendering from the console core. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Marc-André Lureau committed
Feb 19, 2026 at 22:03 UTC
cddc99e81cc6d8b85eedae9f2b41973b1d505cfe
5 files changed
+26
-26
include/ui/console.h
-1
@@ -416,7 +416,6 @@ void qemu_console_set_window_id(QemuConsole *con, int window_id);
416
void qemu_console_resize(QemuConsole *con, int width, int height);
417
DisplaySurface *qemu_console_surface(QemuConsole *con);
418
void coroutine_fn qemu_console_co_wait_update(QemuConsole *con);
419
-int qemu_invalidate_text_consoles(void);
419
420
/* console-gl.c */
421
#ifdef CONFIG_OPENGL
ui/console-priv.h
+1
-1
@@ -36,7 +36,7 @@ struct QemuConsole {
36
};
37
38
void qemu_text_console_update_size(QemuTextConsole *c);
39
-void qemu_text_console_update_cursor(void);
39
+void vt100_update_cursor(void);
40
void qemu_text_console_handle_keysym(QemuTextConsole *s, int keysym);
41
42
#endif
ui/console-vc-stubs.c
+1
-1
@@ -14,7 +14,7 @@ void qemu_text_console_update_size(QemuTextConsole *c)
14
{
15
}
16
17
-void qemu_text_console_update_cursor(void)
17
+void vt100_update_cursor(void)
18
{
19
}
20
ui/console-vc.c
+23
-5
@@ -8,6 +8,7 @@
8
#include "qapi/error.h"
9
#include "qemu/fifo8.h"
10
#include "qemu/option.h"
11
+#include "qemu/queue.h"
12
#include "ui/console.h"
13
14
#include "trace.h"
@@ -68,8 +69,13 @@ struct QemuVT100 {
69
int update_y0;
70
int update_x1;
71
int update_y1;
72
+
73
+ QTAILQ_ENTRY(QemuVT100) list;
74
};
75
76
+static QTAILQ_HEAD(QemuVT100Head, QemuVT100) vt100s =
77
+ QTAILQ_HEAD_INITIALIZER(vt100s);
78
+
79
typedef struct QemuTextConsole {
80
QemuConsole parent;
81
@@ -1042,20 +1048,28 @@ static int vc_chr_write(Chardev *chr, const uint8_t *buf, int len)
1048
return len;
1049
}
1050
1045
-void qemu_text_console_update_cursor(void)
1051
+void vt100_update_cursor(void)
1052
{
1053
+ QemuVT100 *vt;
1054
+
1055
cursor_visible_phase = !cursor_visible_phase;
1056
1049
- if (qemu_invalidate_text_consoles()) {
1050
- timer_mod(cursor_timer,
1051
- qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + CONSOLE_CURSOR_PERIOD / 2);
1057
+ if (QTAILQ_EMPTY(&vt100s)) {
1058
+ return;
1059
+ }
1060
+
1061
+ QTAILQ_FOREACH(vt, &vt100s, list) {
1062
+ vt100_refresh(vt);
1063
}
1064
+
1065
+ timer_mod(cursor_timer,
1066
+ qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + CONSOLE_CURSOR_PERIOD / 2);
1067
}
1068
1069
static void
1070
cursor_timer_cb(void *opaque)
1071
{
1058
- qemu_text_console_update_cursor();
1072
+ vt100_update_cursor();
1073
}
1074
1075
static void text_console_invalidate(void *opaque)
@@ -1071,6 +1085,9 @@ static void text_console_invalidate(void *opaque)
1085
static void
1086
qemu_text_console_finalize(Object *obj)
1087
{
1088
+ QemuTextConsole *s = QEMU_TEXT_CONSOLE(obj);
1089
+
1090
+ QTAILQ_REMOVE(&vt100s, &s->vt, list);
1091
}
1092
1093
static void
@@ -1095,6 +1112,7 @@ qemu_text_console_init(Object *obj)
1112
{
1113
QemuTextConsole *c = QEMU_TEXT_CONSOLE(obj);
1114
1115
+ QTAILQ_INSERT_HEAD(&vt100s, &c->vt, list);
1116
fifo8_create(&c->out_fifo, 16);
1117
c->vt.total_height = DEFAULT_BACKSCROLL;
1118
QEMU_CONSOLE(c)->hw_ops = &text_console_ops;
ui/console.c
+1
-18
@@ -752,7 +752,7 @@ void register_displaychangelistener(DisplayChangeListener *dcl)
752
} else if (QEMU_IS_TEXT_CONSOLE(dcl->con)) {
753
qemu_text_console_update_size(QEMU_TEXT_CONSOLE(dcl->con));
754
}
755
- qemu_text_console_update_cursor();
755
+ vt100_update_cursor();
756
}
757
758
void update_displaychangelistener(DisplayChangeListener *dcl,
@@ -1457,23 +1457,6 @@ int qemu_console_get_height(QemuConsole *con, int fallback)
1457
}
1458
}
1459
1460
-int qemu_invalidate_text_consoles(void)
1461
-{
1462
- QemuConsole *s;
1463
- int count = 0;
1464
-
1465
- QTAILQ_FOREACH(s, &consoles, next) {
1466
- if (qemu_console_is_graphic(s) ||
1467
- !qemu_console_is_visible(s)) {
1468
- continue;
1469
- }
1470
- count++;
1471
- graphic_hw_invalidate(s);
1472
- }
1473
-
1474
- return count;
1475
-}
1476
-
1460
void qemu_console_resize(QemuConsole *s, int width, int height)
1461
{
1462
DisplaySurface *surface = qemu_console_surface(s);