Skip to contentSkip to conversation

Switch back from graphical mode to text mode

Qemu-devel Samuel Thibault 2 participants 2 messages Feb 10, 2008 – Feb 11, 2008

lore
Share & tools
lore
#0 lore raw

Hello,

Thanks for merging the ncurses interface, that'll be very useful!

However there is a small bug when switching back from graphical mode to text mode in vga.c: in graphical mode, the text screen is resized to 60x3 so as to display a message, but nothing is done to make sure that it will be reset back to e.g. 80x25 when switching back to text mode. The attached patch fixes that by recording when a message is displayed (and thus fake resize performed), and when going back to text mode, force the resize.

Samuel

Index: hw/vga.c
===================================================================
RCS file: /sources/qemu/qemu/hw/vga.c,v
retrieving revision 1.60

vga.c +5 -2
diff -u -p -r1.60 vga.c
@@ -1152,7 +1152,7 @@ static void vga_draw_text(VGAState *s, i
     }
 
     if (width != s->last_width || height != s->last_height ||
-        cw != s->last_cw || cheight != s->last_ch) {
+        cw != s->last_cw || cheight != s->last_ch || s->message_screen) {
         s->last_scr_width = width * cw;
         s->last_scr_height = height * cheight;
         dpy_resize(s->ds, s->last_scr_width, s->last_scr_height);
@@ -1160,6 +1160,7 @@ static void vga_draw_text(VGAState *s, i
         s->last_height = height;
         s->last_ch = cheight;
         s->last_cw = cw;
+        s->message_screen = 0;
         full_update = 1;
     }
     cursor_offset = ((s->cr[0x0e] << 8) | s->cr[0x0f]) - s->start_addr;
@@ -1724,7 +1725,7 @@ static void vga_update_text(void *opaque
         }
 
         if (width != s->last_width || height != s->last_height ||
-            cw != s->last_cw || cheight != s->last_ch) {
+            cw != s->last_cw || cheight != s->last_ch || s->message_screen) {
             s->last_scr_width = width * cw;
             s->last_scr_height = height * cheight;
             dpy_resize(s->ds, width, height);
@@ -1732,6 +1733,7 @@ static void vga_update_text(void *opaque
             s->last_height = height;
             s->last_ch = cheight;
             s->last_cw = cw;
+            s->message_screen = 0;
             full_update = 1;
         }
 
@@ -1806,6 +1808,7 @@ static void vga_update_text(void *opaque
     /* Display a message */
     dpy_cursor(s->ds, -1, -1);
     dpy_resize(s->ds, 60, 3);
+    s->message_screen = 1;
 
     for (dst = chardata, i = 0; i < 60 * 3; i ++)
         console_write_ch(dst ++, ' ');

Index: hw/vga_int.h
===================================================================
RCS file: /sources/qemu/qemu/hw/vga_int.h,v
retrieving revision 1.16

vga_int.h +1 -0
diff -u -p -r1.16 vga_int.h
@@ -129,6 +129,7 @@
     uint32_t line_compare;                                              \
     uint32_t start_addr;                                                \
     uint32_t plane_updated;                                             \
+    int message_screen;                                                 \
     uint8_t last_cw, last_ch;                                           \
     uint32_t last_width, last_height; /* in chars or pixels */          \
     uint32_t last_scr_width, last_scr_height; /* in pixels */           \
#1 lore raw

Hi,

Quoted 4 lines · Samuel Thibault

However there is a small bug when switching back from graphical mode to text mode in vga.c: in graphical mode, the text screen is resized to 60x3 so as to display a message, but nothing is done to make sure that it will be reset back to e.g. 80x25 when switching back to text mode.

Oops, right. I committed a slightly different fix from that in your patch, so that the size change is automatically noticed instead of having to be forced.

Thanks for the patch though and for the report.

Signature · 2 lines
Please do not print this email unless absolutely necessary. Spread
environmental awareness.