Skip to content

Commit e99441a

Browse files
akihikodakielmarco
authored andcommitted
ui/curses: Do not use console_select()
ui/curses is the only user of console_select(). Move the implementation to ui/curses. Signed-off-by: Akihiko Odaki <[email protected]> Reviewed-by: Marc-André Lureau <[email protected]> Message-Id: <[email protected]>
1 parent ca3de7b commit e99441a

File tree

6 files changed

+51
-126
lines changed

6 files changed

+51
-126
lines changed

include/ui/console.h

-1
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,6 @@ int qemu_console_get_window_id(QemuConsole *con);
433433
/* Set the low-level window id for the console */
434434
void qemu_console_set_window_id(QemuConsole *con, int window_id);
435435

436-
void console_select(unsigned int index);
437436
void qemu_console_resize(QemuConsole *con, int width, int height);
438437
DisplaySurface *qemu_console_surface(QemuConsole *con);
439438
void coroutine_fn qemu_console_co_wait_update(QemuConsole *con);

ui/console-priv.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ struct QemuConsole {
3535
QTAILQ_ENTRY(QemuConsole) next;
3636
};
3737

38-
void qemu_text_console_select(QemuTextConsole *c);
38+
void qemu_text_console_update_size(QemuTextConsole *c);
3939
const char * qemu_text_console_get_label(QemuTextConsole *c);
4040
void qemu_text_console_update_cursor(void);
4141
void qemu_text_console_handle_keysym(QemuTextConsole *s, int keysym);

ui/console-vc-stubs.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "chardev/char.h"
1111
#include "ui/console-priv.h"
1212

13-
void qemu_text_console_select(QemuTextConsole *c)
13+
void qemu_text_console_update_size(QemuTextConsole *c)
1414
{
1515
}
1616

ui/console-vc.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -958,10 +958,9 @@ static void vc_chr_set_echo(Chardev *chr, bool echo)
958958
drv->console->echo = echo;
959959
}
960960

961-
void qemu_text_console_select(QemuTextConsole *c)
961+
void qemu_text_console_update_size(QemuTextConsole *c)
962962
{
963963
dpy_text_resize(QEMU_CONSOLE(c), c->width, c->height);
964-
qemu_text_console_update_cursor();
965964
}
966965

967966
static void vc_chr_open(Chardev *chr,

ui/console.c

+21-100
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ struct DisplayState {
6666
};
6767

6868
static DisplayState *display_state;
69-
static QemuConsole *active_console;
7069
static QTAILQ_HEAD(, QemuConsole) consoles =
7170
QTAILQ_HEAD_INITIALIZER(consoles);
7271

@@ -135,7 +134,6 @@ void graphic_hw_update_done(QemuConsole *con)
135134
void graphic_hw_update(QemuConsole *con)
136135
{
137136
bool async = false;
138-
con = con ? con : active_console;
139137
if (!con) {
140138
return;
141139
}
@@ -209,19 +207,13 @@ void qemu_console_set_window_id(QemuConsole *con, int window_id)
209207

210208
void graphic_hw_invalidate(QemuConsole *con)
211209
{
212-
if (!con) {
213-
con = active_console;
214-
}
215210
if (con && con->hw_ops->invalidate) {
216211
con->hw_ops->invalidate(con->hw);
217212
}
218213
}
219214

220215
void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata)
221216
{
222-
if (!con) {
223-
con = active_console;
224-
}
225217
if (con && con->hw_ops->text_update) {
226218
con->hw_ops->text_update(con->hw, chardata);
227219
}
@@ -265,12 +257,12 @@ static void dpy_gfx_update_texture(QemuConsole *con, DisplaySurface *surface,
265257
}
266258

267259
static void displaychangelistener_display_console(DisplayChangeListener *dcl,
268-
QemuConsole *con,
269260
Error **errp)
270261
{
271262
static const char nodev[] =
272263
"This VM has no graphic display device.";
273264
static DisplaySurface *dummy;
265+
QemuConsole *con = dcl->con;
274266

275267
if (!con || !console_compatible_with(con, dcl, errp)) {
276268
if (!dummy) {
@@ -305,39 +297,8 @@ static void displaychangelistener_display_console(DisplayChangeListener *dcl,
305297
}
306298
}
307299

308-
void console_select(unsigned int index)
309-
{
310-
DisplayChangeListener *dcl;
311-
QemuConsole *s;
312-
313-
trace_console_select(index);
314-
s = qemu_console_lookup_by_index(index);
315-
if (s) {
316-
DisplayState *ds = s->ds;
317-
318-
active_console = s;
319-
QLIST_FOREACH (dcl, &ds->listeners, next) {
320-
if (dcl->con != NULL) {
321-
continue;
322-
}
323-
displaychangelistener_display_console(dcl, s, NULL);
324-
}
325-
326-
if (QEMU_IS_TEXT_CONSOLE(s)) {
327-
qemu_text_console_select(QEMU_TEXT_CONSOLE(s));
328-
}
329-
}
330-
}
331-
332300
void qemu_text_console_put_keysym(QemuTextConsole *s, int keysym)
333301
{
334-
if (!s) {
335-
if (!QEMU_IS_TEXT_CONSOLE(active_console)) {
336-
return;
337-
}
338-
s = QEMU_TEXT_CONSOLE(active_console);
339-
}
340-
341302
qemu_text_console_handle_keysym(s, keysym);
342303
}
343304

@@ -392,11 +353,6 @@ qemu_console_register(QemuConsole *c)
392353
{
393354
int i;
394355

395-
if (!active_console || (!QEMU_IS_GRAPHIC_CONSOLE(active_console) &&
396-
QEMU_IS_GRAPHIC_CONSOLE(c))) {
397-
active_console = c;
398-
}
399-
400356
if (QTAILQ_EMPTY(&consoles)) {
401357
c->index = 0;
402358
QTAILQ_INSERT_TAIL(&consoles, c, next);
@@ -751,8 +707,6 @@ dcl_set_graphic_cursor(DisplayChangeListener *dcl, QemuGraphicConsole *con)
751707

752708
void register_displaychangelistener(DisplayChangeListener *dcl)
753709
{
754-
QemuConsole *con;
755-
756710
assert(!dcl->ds);
757711

758712
trace_displaychangelistener_register(dcl, dcl->ops->dpy_name);
@@ -761,13 +715,12 @@ void register_displaychangelistener(DisplayChangeListener *dcl)
761715
gui_setup_refresh(dcl->ds);
762716
if (dcl->con) {
763717
dcl->con->dcls++;
764-
con = dcl->con;
765-
} else {
766-
con = active_console;
767718
}
768-
displaychangelistener_display_console(dcl, con, dcl->con ? &error_fatal : NULL);
769-
if (QEMU_IS_GRAPHIC_CONSOLE(con)) {
770-
dcl_set_graphic_cursor(dcl, QEMU_GRAPHIC_CONSOLE(con));
719+
displaychangelistener_display_console(dcl, &error_fatal);
720+
if (QEMU_IS_GRAPHIC_CONSOLE(dcl->con)) {
721+
dcl_set_graphic_cursor(dcl, QEMU_GRAPHIC_CONSOLE(dcl->con));
722+
} else if (QEMU_IS_TEXT_CONSOLE(dcl->con)) {
723+
qemu_text_console_update_size(QEMU_TEXT_CONSOLE(dcl->con));
771724
}
772725
qemu_text_console_update_cursor();
773726
}
@@ -805,9 +758,6 @@ static void dpy_set_ui_info_timer(void *opaque)
805758

806759
bool dpy_ui_info_supported(const QemuConsole *con)
807760
{
808-
if (con == NULL) {
809-
con = active_console;
810-
}
811761
if (con == NULL) {
812762
return false;
813763
}
@@ -819,19 +769,11 @@ const QemuUIInfo *dpy_get_ui_info(const QemuConsole *con)
819769
{
820770
assert(dpy_ui_info_supported(con));
821771

822-
if (con == NULL) {
823-
con = active_console;
824-
}
825-
826772
return &con->ui_info;
827773
}
828774

829775
int dpy_set_ui_info(QemuConsole *con, QemuUIInfo *info, bool delay)
830776
{
831-
if (con == NULL) {
832-
con = active_console;
833-
}
834-
835777
if (!dpy_ui_info_supported(con)) {
836778
return -1;
837779
}
@@ -870,7 +812,7 @@ void dpy_gfx_update(QemuConsole *con, int x, int y, int w, int h)
870812
}
871813
dpy_gfx_update_texture(con, con->surface, x, y, w, h);
872814
QLIST_FOREACH(dcl, &s->listeners, next) {
873-
if (con != (dcl->con ? dcl->con : active_console)) {
815+
if (con != dcl->con) {
874816
continue;
875817
}
876818
if (dcl->ops->dpy_gfx_update) {
@@ -916,7 +858,7 @@ void dpy_gfx_replace_surface(QemuConsole *con,
916858
con->surface = new_surface;
917859
dpy_gfx_create_texture(con, new_surface);
918860
QLIST_FOREACH(dcl, &s->listeners, next) {
919-
if (con != (dcl->con ? dcl->con : active_console)) {
861+
if (con != dcl->con) {
920862
continue;
921863
}
922864
displaychangelistener_gfx_switch(dcl, new_surface, surface ? FALSE : TRUE);
@@ -970,7 +912,7 @@ void dpy_text_cursor(QemuConsole *con, int x, int y)
970912
return;
971913
}
972914
QLIST_FOREACH(dcl, &s->listeners, next) {
973-
if (con != (dcl->con ? dcl->con : active_console)) {
915+
if (con != dcl->con) {
974916
continue;
975917
}
976918
if (dcl->ops->dpy_text_cursor) {
@@ -988,7 +930,7 @@ void dpy_text_update(QemuConsole *con, int x, int y, int w, int h)
988930
return;
989931
}
990932
QLIST_FOREACH(dcl, &s->listeners, next) {
991-
if (con != (dcl->con ? dcl->con : active_console)) {
933+
if (con != dcl->con) {
992934
continue;
993935
}
994936
if (dcl->ops->dpy_text_update) {
@@ -1006,7 +948,7 @@ void dpy_text_resize(QemuConsole *con, int w, int h)
1006948
return;
1007949
}
1008950
QLIST_FOREACH(dcl, &s->listeners, next) {
1009-
if (con != (dcl->con ? dcl->con : active_console)) {
951+
if (con != dcl->con) {
1010952
continue;
1011953
}
1012954
if (dcl->ops->dpy_text_resize) {
@@ -1028,7 +970,7 @@ void dpy_mouse_set(QemuConsole *c, int x, int y, int on)
1028970
return;
1029971
}
1030972
QLIST_FOREACH(dcl, &s->listeners, next) {
1031-
if (c != (dcl->con ? dcl->con : active_console)) {
973+
if (c != dcl->con) {
1032974
continue;
1033975
}
1034976
if (dcl->ops->dpy_mouse_set) {
@@ -1049,7 +991,7 @@ void dpy_cursor_define(QemuConsole *c, QEMUCursor *cursor)
1049991
return;
1050992
}
1051993
QLIST_FOREACH(dcl, &s->listeners, next) {
1052-
if (c != (dcl->con ? dcl->con : active_console)) {
994+
if (c != dcl->con) {
1053995
continue;
1054996
}
1055997
if (dcl->ops->dpy_cursor_define) {
@@ -1099,7 +1041,7 @@ void dpy_gl_scanout_disable(QemuConsole *con)
10991041
con->scanout.kind = SCANOUT_NONE;
11001042
}
11011043
QLIST_FOREACH(dcl, &s->listeners, next) {
1102-
if (con != (dcl->con ? dcl->con : active_console)) {
1044+
if (con != dcl->con) {
11031045
continue;
11041046
}
11051047
if (dcl->ops->dpy_gl_scanout_disable) {
@@ -1126,7 +1068,7 @@ void dpy_gl_scanout_texture(QemuConsole *con,
11261068
x, y, width, height, d3d_tex2d,
11271069
};
11281070
QLIST_FOREACH(dcl, &s->listeners, next) {
1129-
if (con != (dcl->con ? dcl->con : active_console)) {
1071+
if (con != dcl->con) {
11301072
continue;
11311073
}
11321074
if (dcl->ops->dpy_gl_scanout_texture) {
@@ -1148,7 +1090,7 @@ void dpy_gl_scanout_dmabuf(QemuConsole *con,
11481090
con->scanout.kind = SCANOUT_DMABUF;
11491091
con->scanout.dmabuf = dmabuf;
11501092
QLIST_FOREACH(dcl, &s->listeners, next) {
1151-
if (con != (dcl->con ? dcl->con : active_console)) {
1093+
if (con != dcl->con) {
11521094
continue;
11531095
}
11541096
if (dcl->ops->dpy_gl_scanout_dmabuf) {
@@ -1164,7 +1106,7 @@ void dpy_gl_cursor_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf,
11641106
DisplayChangeListener *dcl;
11651107

11661108
QLIST_FOREACH(dcl, &s->listeners, next) {
1167-
if (con != (dcl->con ? dcl->con : active_console)) {
1109+
if (con != dcl->con) {
11681110
continue;
11691111
}
11701112
if (dcl->ops->dpy_gl_cursor_dmabuf) {
@@ -1181,7 +1123,7 @@ void dpy_gl_cursor_position(QemuConsole *con,
11811123
DisplayChangeListener *dcl;
11821124

11831125
QLIST_FOREACH(dcl, &s->listeners, next) {
1184-
if (con != (dcl->con ? dcl->con : active_console)) {
1126+
if (con != dcl->con) {
11851127
continue;
11861128
}
11871129
if (dcl->ops->dpy_gl_cursor_position) {
@@ -1197,7 +1139,7 @@ void dpy_gl_release_dmabuf(QemuConsole *con,
11971139
DisplayChangeListener *dcl;
11981140

11991141
QLIST_FOREACH(dcl, &s->listeners, next) {
1200-
if (con != (dcl->con ? dcl->con : active_console)) {
1142+
if (con != dcl->con) {
12011143
continue;
12021144
}
12031145
if (dcl->ops->dpy_gl_release_dmabuf) {
@@ -1216,7 +1158,7 @@ void dpy_gl_update(QemuConsole *con,
12161158

12171159
graphic_hw_gl_block(con, true);
12181160
QLIST_FOREACH(dcl, &s->listeners, next) {
1219-
if (con != (dcl->con ? dcl->con : active_console)) {
1161+
if (con != dcl->con) {
12201162
continue;
12211163
}
12221164
if (dcl->ops->dpy_gl_update) {
@@ -1415,30 +1357,21 @@ static QemuConsole *qemu_graphic_console_lookup_unused(void)
14151357

14161358
QEMUCursor *qemu_console_get_cursor(QemuConsole *con)
14171359
{
1418-
if (con == NULL) {
1419-
con = active_console;
1420-
}
14211360
return QEMU_IS_GRAPHIC_CONSOLE(con) ? QEMU_GRAPHIC_CONSOLE(con)->cursor : NULL;
14221361
}
14231362

14241363
bool qemu_console_is_visible(QemuConsole *con)
14251364
{
1426-
return (con == active_console) || (con->dcls > 0);
1365+
return con->dcls > 0;
14271366
}
14281367

14291368
bool qemu_console_is_graphic(QemuConsole *con)
14301369
{
1431-
if (con == NULL) {
1432-
con = active_console;
1433-
}
14341370
return con && QEMU_IS_GRAPHIC_CONSOLE(con);
14351371
}
14361372

14371373
bool qemu_console_is_fixedsize(QemuConsole *con)
14381374
{
1439-
if (con == NULL) {
1440-
con = active_console;
1441-
}
14421375
return con && (QEMU_IS_GRAPHIC_CONSOLE(con) || QEMU_IS_FIXED_TEXT_CONSOLE(con));
14431376
}
14441377

@@ -1505,17 +1438,11 @@ char *qemu_console_get_label(QemuConsole *con)
15051438

15061439
int qemu_console_get_index(QemuConsole *con)
15071440
{
1508-
if (con == NULL) {
1509-
con = active_console;
1510-
}
15111441
return con ? con->index : -1;
15121442
}
15131443

15141444
uint32_t qemu_console_get_head(QemuConsole *con)
15151445
{
1516-
if (con == NULL) {
1517-
con = active_console;
1518-
}
15191446
if (con == NULL) {
15201447
return -1;
15211448
}
@@ -1527,9 +1454,6 @@ uint32_t qemu_console_get_head(QemuConsole *con)
15271454

15281455
int qemu_console_get_width(QemuConsole *con, int fallback)
15291456
{
1530-
if (con == NULL) {
1531-
con = active_console;
1532-
}
15331457
if (con == NULL) {
15341458
return fallback;
15351459
}
@@ -1547,9 +1471,6 @@ int qemu_console_get_width(QemuConsole *con, int fallback)
15471471

15481472
int qemu_console_get_height(QemuConsole *con, int fallback)
15491473
{
1550-
if (con == NULL) {
1551-
con = active_console;
1552-
}
15531474
if (con == NULL) {
15541475
return fallback;
15551476
}

0 commit comments

Comments
 (0)