diff mbox

[Qemu-devel] Re: [PATCH] Fix display breakage when resizing the screen

Message ID 49D8CFC5.2070203@redhat.com (mailing list archive)
State Accepted
Headers show

Commit Message

Avi Kivity April 5, 2009, 3:35 p.m. UTC
Anthony Liguori wrote:
>
> This patch breaks VC switching with -curses.
>

The attached incremental fixes it, by basically replicating the previous 
behaviour.  I'll follow up with a new combined patch.
diff mbox

Patch

diff --git a/hw/vga.c b/hw/vga.c
index 404450f..54d0246 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -1631,6 +1631,9 @@  static void vga_update_resolution_graphics(VGAState *s)
         s->multi_run != multi_run ||
         s->multi_scan != multi_scan ||
         s->want_full_update) {
+        if (s->ds->surface->pf.depth == 0) {
+            goto dont_touch_display_surface;
+        }
 #if defined(WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN)
         if (depth == 16 || depth == 32) {
 #else
@@ -1647,6 +1650,7 @@  static void vga_update_resolution_graphics(VGAState *s)
         } else {
             qemu_console_resize(s->ds, disp_width, height);
         }
+    dont_touch_display_surface:
         s->last_scr_width = disp_width;
         s->last_scr_height = height;
         s->last_width = disp_width;
@@ -1668,7 +1672,17 @@  static void vga_update_resolution_text(VGAState *s)
         cw != s->last_cw || cheight != s->last_ch || s->last_depth) {
         s->last_scr_width = width * cw;
         s->last_scr_height = height * cheight;
-        qemu_console_resize(s->ds, s->last_scr_width, s->last_scr_height);
+        if (s->ds->surface->pf.depth != 0) {
+            qemu_console_resize(s->ds, s->last_scr_width, s->last_scr_height);
+        } else {
+            /*
+             * curses expects width and height to be in character cell
+             * dimensions, not pixels.
+             */
+            s->ds->surface->width = width;
+            s->ds->surface->height = height;
+            dpy_resize(s->ds);
+        }
         s->last_depth = 0;
         s->last_width = width;
         s->last_height = height;