Commit af3a9031061251fbbee2c1f06b876c3732cfee71
1 parent
37a4c539
New features for QEMU text console, by Stefan Weil.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3068 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
4 changed files
with
61 additions
and
21 deletions
console.c
... | ... | @@ -104,10 +104,16 @@ int qemu_fifo_read(QEMUFIFO *f, uint8_t *buf, int len1) |
104 | 104 | return len1; |
105 | 105 | } |
106 | 106 | |
107 | +typedef enum { | |
108 | + GRAPHIC_CONSOLE, | |
109 | + TEXT_CONSOLE, | |
110 | + TEXT_CONSOLE_FIXED_SIZE | |
111 | +} console_type_t; | |
112 | + | |
107 | 113 | /* ??? This is mis-named. |
108 | 114 | It is used for both text and graphical consoles. */ |
109 | 115 | struct TextConsole { |
110 | - int text_console; /* true if text console */ | |
116 | + console_type_t console_type; | |
111 | 117 | DisplayState *ds; |
112 | 118 | /* Graphic console state. */ |
113 | 119 | vga_hw_update_ptr hw_update; |
... | ... | @@ -587,7 +593,7 @@ static void console_scroll(int ydelta) |
587 | 593 | int i, y1; |
588 | 594 | |
589 | 595 | s = active_console; |
590 | - if (!s || !s->text_console) | |
596 | + if (!s || (s->console_type == GRAPHIC_CONSOLE)) | |
591 | 597 | return; |
592 | 598 | |
593 | 599 | if (ydelta > 0) { |
... | ... | @@ -990,13 +996,17 @@ void console_select(unsigned int index) |
990 | 996 | s = consoles[index]; |
991 | 997 | if (s) { |
992 | 998 | active_console = s; |
993 | - if (s->text_console) { | |
999 | + if (s->console_type != GRAPHIC_CONSOLE) { | |
994 | 1000 | if (s->g_width != s->ds->width || |
995 | 1001 | s->g_height != s->ds->height) { |
1002 | + if (s->console_type == TEXT_CONSOLE_FIXED_SIZE) { | |
1003 | + dpy_resize(s->ds, s->g_width, s->g_height); | |
1004 | + } else { | |
996 | 1005 | s->g_width = s->ds->width; |
997 | 1006 | s->g_height = s->ds->height; |
998 | 1007 | text_console_resize(s); |
999 | 1008 | } |
1009 | + } | |
1000 | 1010 | console_refresh(s); |
1001 | 1011 | } else { |
1002 | 1012 | vga_hw_invalidate(); |
... | ... | @@ -1062,7 +1072,7 @@ void kbd_put_keysym(int keysym) |
1062 | 1072 | int c; |
1063 | 1073 | |
1064 | 1074 | s = active_console; |
1065 | - if (!s || !s->text_console) | |
1075 | + if (!s || (s->console_type == GRAPHIC_CONSOLE)) | |
1066 | 1076 | return; |
1067 | 1077 | |
1068 | 1078 | switch(keysym) { |
... | ... | @@ -1104,7 +1114,7 @@ void kbd_put_keysym(int keysym) |
1104 | 1114 | } |
1105 | 1115 | } |
1106 | 1116 | |
1107 | -static TextConsole *new_console(DisplayState *ds, int text) | |
1117 | +static TextConsole *new_console(DisplayState *ds, console_type_t console_type) | |
1108 | 1118 | { |
1109 | 1119 | TextConsole *s; |
1110 | 1120 | int i; |
... | ... | @@ -1115,16 +1125,18 @@ static TextConsole *new_console(DisplayState *ds, int text) |
1115 | 1125 | if (!s) { |
1116 | 1126 | return NULL; |
1117 | 1127 | } |
1118 | - if (!active_console || (active_console->text_console && !text)) | |
1128 | + if (!active_console || ((active_console->console_type != GRAPHIC_CONSOLE) && | |
1129 | + (console_type == GRAPHIC_CONSOLE))) { | |
1119 | 1130 | active_console = s; |
1131 | + } | |
1120 | 1132 | s->ds = ds; |
1121 | - s->text_console = text; | |
1122 | - if (text) { | |
1133 | + s->console_type = console_type; | |
1134 | + if (console_type != GRAPHIC_CONSOLE) { | |
1123 | 1135 | consoles[nb_consoles++] = s; |
1124 | 1136 | } else { |
1125 | 1137 | /* HACK: Put graphical consoles before text consoles. */ |
1126 | 1138 | for (i = nb_consoles; i > 0; i--) { |
1127 | - if (!consoles[i - 1]->text_console) | |
1139 | + if (consoles[i - 1]->console_type == GRAPHIC_CONSOLE) | |
1128 | 1140 | break; |
1129 | 1141 | consoles[i] = consoles[i - 1]; |
1130 | 1142 | } |
... | ... | @@ -1140,7 +1152,7 @@ TextConsole *graphic_console_init(DisplayState *ds, vga_hw_update_ptr update, |
1140 | 1152 | { |
1141 | 1153 | TextConsole *s; |
1142 | 1154 | |
1143 | - s = new_console(ds, 0); | |
1155 | + s = new_console(ds, GRAPHIC_CONSOLE); | |
1144 | 1156 | if (!s) |
1145 | 1157 | return NULL; |
1146 | 1158 | s->hw_update = update; |
... | ... | @@ -1152,20 +1164,22 @@ TextConsole *graphic_console_init(DisplayState *ds, vga_hw_update_ptr update, |
1152 | 1164 | |
1153 | 1165 | int is_graphic_console(void) |
1154 | 1166 | { |
1155 | - return !active_console->text_console; | |
1167 | + return active_console->console_type == GRAPHIC_CONSOLE; | |
1156 | 1168 | } |
1157 | 1169 | |
1158 | -CharDriverState *text_console_init(DisplayState *ds) | |
1170 | +CharDriverState *text_console_init(DisplayState *ds, const char *p) | |
1159 | 1171 | { |
1160 | 1172 | CharDriverState *chr; |
1161 | 1173 | TextConsole *s; |
1162 | 1174 | int i,j; |
1175 | + unsigned width; | |
1176 | + unsigned height; | |
1163 | 1177 | static int color_inited; |
1164 | 1178 | |
1165 | 1179 | chr = qemu_mallocz(sizeof(CharDriverState)); |
1166 | 1180 | if (!chr) |
1167 | 1181 | return NULL; |
1168 | - s = new_console(ds, 1); | |
1182 | + s = new_console(ds, (p == 0) ? TEXT_CONSOLE : TEXT_CONSOLE_FIXED_SIZE); | |
1169 | 1183 | if (!s) { |
1170 | 1184 | free(chr); |
1171 | 1185 | return NULL; |
... | ... | @@ -1193,8 +1207,25 @@ CharDriverState *text_console_init(DisplayState *ds) |
1193 | 1207 | s->total_height = DEFAULT_BACKSCROLL; |
1194 | 1208 | s->x = 0; |
1195 | 1209 | s->y = 0; |
1196 | - s->g_width = s->ds->width; | |
1197 | - s->g_height = s->ds->height; | |
1210 | + width = s->ds->width; | |
1211 | + height = s->ds->height; | |
1212 | + if (p != 0) { | |
1213 | + width = strtoul(p, (char **)&p, 10); | |
1214 | + if (*p == 'C') { | |
1215 | + p++; | |
1216 | + width *= FONT_WIDTH; | |
1217 | + } | |
1218 | + if (*p == 'x') { | |
1219 | + p++; | |
1220 | + height = strtoul(p, (char **)&p, 10); | |
1221 | + if (*p == 'C') { | |
1222 | + p++; | |
1223 | + height *= FONT_HEIGHT; | |
1224 | + } | |
1225 | + } | |
1226 | + } | |
1227 | + s->g_width = width; | |
1228 | + s->g_height = height; | |
1198 | 1229 | |
1199 | 1230 | /* Set text attribute defaults */ |
1200 | 1231 | s->t_attrib_default.bold = 0; | ... | ... |
qemu-doc.texi
... | ... | @@ -555,8 +555,15 @@ Use @code{-serial none} to disable all serial ports. |
555 | 555 | |
556 | 556 | Available character devices are: |
557 | 557 | @table @code |
558 | -@item vc | |
559 | -Virtual console | |
558 | +@item vc[:WxH] | |
559 | +Virtual console. Optionally, a width and height can be given in pixel with | |
560 | +@example | |
561 | +vc:800x600 | |
562 | +@end example | |
563 | +It is also possible to specify width or height in characters: | |
564 | +@example | |
565 | +vc:80Cx24C | |
566 | +@end example | |
560 | 567 | @item pty |
561 | 568 | [Linux only] Pseudo TTY (a new PTY is automatically allocated) |
562 | 569 | @item none | ... | ... |
vl.c
... | ... | @@ -2923,7 +2923,9 @@ CharDriverState *qemu_chr_open(const char *filename) |
2923 | 2923 | const char *p; |
2924 | 2924 | |
2925 | 2925 | if (!strcmp(filename, "vc")) { |
2926 | - return text_console_init(&display_state); | |
2926 | + return text_console_init(&display_state, 0); | |
2927 | + } else if (strstart(filename, "vc:", &p)) { | |
2928 | + return text_console_init(&display_state, p); | |
2927 | 2929 | } else if (!strcmp(filename, "null")) { |
2928 | 2930 | return qemu_chr_open_null(); |
2929 | 2931 | } else |
... | ... | @@ -7970,7 +7972,7 @@ int main(int argc, char **argv) |
7970 | 7972 | devname); |
7971 | 7973 | exit(1); |
7972 | 7974 | } |
7973 | - if (!strcmp(devname, "vc")) | |
7975 | + if (strstart(devname, "vc", 0)) | |
7974 | 7976 | qemu_chr_printf(serial_hds[i], "serial%d console\r\n", i); |
7975 | 7977 | } |
7976 | 7978 | } |
... | ... | @@ -7984,7 +7986,7 @@ int main(int argc, char **argv) |
7984 | 7986 | devname); |
7985 | 7987 | exit(1); |
7986 | 7988 | } |
7987 | - if (!strcmp(devname, "vc")) | |
7989 | + if (strstart(devname, "vc", 0)) | |
7988 | 7990 | qemu_chr_printf(parallel_hds[i], "parallel%d console\r\n", i); |
7989 | 7991 | } |
7990 | 7992 | } | ... | ... |
vl.h
... | ... | @@ -351,7 +351,7 @@ void vga_hw_invalidate(void); |
351 | 351 | void vga_hw_screen_dump(const char *filename); |
352 | 352 | |
353 | 353 | int is_graphic_console(void); |
354 | -CharDriverState *text_console_init(DisplayState *ds); | |
354 | +CharDriverState *text_console_init(DisplayState *ds, const char *p); | |
355 | 355 | void console_select(unsigned int index); |
356 | 356 | |
357 | 357 | /* serial ports */ | ... | ... |