@samitouri / QOSamiQemu / commits / 049f422117

ui/console: remove qemu_console_is_visible()

Drop the bookkeeping, we can simply afford an empty "foreach". Notice that dpy_gfx_update_texture() is now called even when there are no listeners. This is more correct, as the texture is not fully refreshed when a listener connects, so it may be outdated/garbaged. Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Marc-André Lureau committed Feb 27, 2026 at 08:19 UTC 049f4221172f0df832d01f707f08c379afdb85ba
3 files changed -31
include/ui/console.h
-1
@@ -399,7 +399,6 @@ QemuConsole *qemu_console_lookup_by_device(DeviceState *dev, uint32_t head);
399 QemuConsole *qemu_console_lookup_by_device_name(const char *device_id,
400 uint32_t head, Error **errp);
401 QEMUCursor *qemu_console_get_cursor(QemuConsole *con);
402 -bool qemu_console_is_visible(QemuConsole *con);
402 bool qemu_console_is_graphic(QemuConsole *con);
403 bool qemu_console_is_fixedsize(QemuConsole *con);
404 bool qemu_console_is_gl_blocked(QemuConsole *con);
ui/console-priv.h
-1
@@ -16,7 +16,6 @@ struct QemuConsole {
16 DisplayState *ds;
17 DisplaySurface *surface;
18 DisplayScanout scanout;
19 - int dcls;
19 DisplayGLCtx *gl;
20 int gl_block;
21 QEMUTimer *gl_unblock_timer;
ui/console.c
-29
@@ -648,9 +648,6 @@ void register_displaychangelistener(DisplayChangeListener *dcl)
648 dcl->ds = get_alloc_displaystate();
649 QLIST_INSERT_HEAD(&dcl->ds->listeners, dcl, next);
650 gui_setup_refresh(dcl->ds);
651 - if (dcl->con) {
652 - dcl->con->dcls++;
653 - }
651 displaychangelistener_display_console(dcl, &error_fatal);
652 if (QEMU_IS_GRAPHIC_CONSOLE(dcl->con)) {
653 dcl_set_graphic_cursor(dcl, QEMU_GRAPHIC_CONSOLE(dcl->con));
@@ -678,9 +675,6 @@ void unregister_displaychangelistener(DisplayChangeListener *dcl)
675 if (!ds) {
676 return;
677 }
681 - if (dcl->con) {
682 - dcl->con->dcls--;
683 - }
678 QLIST_REMOVE(dcl, next);
679 dcl->ds = NULL;
680 gui_setup_refresh(ds);
@@ -745,9 +739,6 @@ void dpy_gfx_update(QemuConsole *con, int x, int y, int w, int h)
739 w = MIN(w, width - x);
740 h = MIN(h, height - y);
741
748 - if (!qemu_console_is_visible(con)) {
749 - return;
750 - }
742 dpy_gfx_update_texture(con, con->surface, x, y, w, h);
743 QLIST_FOREACH(dcl, &s->listeners, next) {
744 if (con != dcl->con) {
@@ -846,9 +837,6 @@ void dpy_text_cursor(QemuConsole *con, int x, int y)
837 DisplayState *s = con->ds;
838 DisplayChangeListener *dcl;
839
849 - if (!qemu_console_is_visible(con)) {
850 - return;
851 - }
840 QLIST_FOREACH(dcl, &s->listeners, next) {
841 if (con != dcl->con) {
842 continue;
@@ -864,9 +852,6 @@ void dpy_text_update(QemuConsole *con, int x, int y, int w, int h)
852 DisplayState *s = con->ds;
853 DisplayChangeListener *dcl;
854
867 - if (!qemu_console_is_visible(con)) {
868 - return;
869 - }
855 QLIST_FOREACH(dcl, &s->listeners, next) {
856 if (con != dcl->con) {
857 continue;
@@ -882,9 +867,6 @@ void dpy_text_resize(QemuConsole *con, int w, int h)
867 DisplayState *s = con->ds;
868 DisplayChangeListener *dcl;
869
885 - if (!qemu_console_is_visible(con)) {
886 - return;
887 - }
870 QLIST_FOREACH(dcl, &s->listeners, next) {
871 if (con != dcl->con) {
872 continue;
@@ -904,9 +886,6 @@ void dpy_mouse_set(QemuConsole *c, int x, int y, bool on)
886 con->cursor_x = x;
887 con->cursor_y = y;
888 con->cursor_on = on;
907 - if (!qemu_console_is_visible(c)) {
908 - return;
909 - }
889 QLIST_FOREACH(dcl, &s->listeners, next) {
890 if (c != dcl->con) {
891 continue;
@@ -925,9 +904,6 @@ void dpy_cursor_define(QemuConsole *c, QEMUCursor *cursor)
904
905 cursor_unref(con->cursor);
906 con->cursor = cursor_ref(cursor);
928 - if (!qemu_console_is_visible(c)) {
929 - return;
930 - }
907 QLIST_FOREACH(dcl, &s->listeners, next) {
908 if (c != dcl->con) {
909 continue;
@@ -1285,11 +1261,6 @@ QEMUCursor *qemu_console_get_cursor(QemuConsole *con)
1261 return QEMU_IS_GRAPHIC_CONSOLE(con) ? QEMU_GRAPHIC_CONSOLE(con)->cursor : NULL;
1262 }
1263
1288 -bool qemu_console_is_visible(QemuConsole *con)
1289 -{
1290 - return con->dcls > 0;
1291 -}
1292 -
1264 bool qemu_console_is_graphic(QemuConsole *con)
1265 {
1266 return con && QEMU_IS_GRAPHIC_CONSOLE(con);