From: "andrzej zaborowski" Subject: Re: [Qemu-devel] [PATCH 1/2] Fix text console size/resize when using curses Date: Sat, 23 Aug 2008 00:40:13 +0200 Message-ID: References: <1219428221-22947-1-git-send-email-ryanh@us.ibm.com> <1219428221-22947-2-git-send-email-ryanh@us.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: "Ryan Harper" , kvm@vger.kernel.org To: qemu-devel@nongnu.org Return-path: Received: from rv-out-0506.google.com ([209.85.198.227]:22090 "EHLO rv-out-0506.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751958AbYHVWkN (ORCPT ); Fri, 22 Aug 2008 18:40:13 -0400 Received: by rv-out-0506.google.com with SMTP id k40so630544rvb.1 for ; Fri, 22 Aug 2008 15:40:13 -0700 (PDT) In-Reply-To: <1219428221-22947-2-git-send-email-ryanh@us.ibm.com> Content-Disposition: inline Sender: kvm-owner@vger.kernel.org List-ID: 2008/8/22 Ryan Harper : > The current console output is broken in curses mode size the default starting > size might not match the launching terminal size. Change initial size to be > based on the terminal. Also, resize events fail to ensure that both the text > console and curses display areas are the same size; this causes broken output > like: > > QEMU 0.9.1 monitor - type 'help' for more information > (qemu) > (qemu) > (qemu) > > To fix this, ensure that the display width and the text area width are sync for > text consoles on refresh; also force a resize event whenever we invalidate the > text console. > > Signed-off-by: Ryan Harper > > diff --git a/console.c b/console.c > index 1c94980..89bdc52 100644 > --- a/console.c > +++ b/console.c > @@ -608,6 +608,9 @@ static void console_refresh(TextConsole *s) > s->text_y[0] = 0; > s->text_x[1] = s->width - 1; > s->text_y[1] = s->height - 1; > + /* ensure that textconsole area is the same size as the display */ > + s->g_width = s->ds->width; > + s->g_height = s->ds->height; > s->cursor_invalidate = 1; > return; > } > @@ -1158,6 +1161,8 @@ static void text_console_invalidate(void *opaque) > TextConsole *s = (TextConsole *) opaque; > > console_refresh(s); > + /* resize if needed */ > + text_console_resize(s); > } > > static void text_console_update(void *opaque, console_ch_t *chardata) > diff --git a/curses.c b/curses.c > index d09eff2..a8972f4 100644 > --- a/curses.c > +++ b/curses.c > @@ -362,8 +362,8 @@ void curses_display_init(DisplayState *ds, int full_screen) > ds->data = (void *) screen; > ds->linesize = 0; > ds->depth = 0; > - ds->width = 640; > - ds->height = 400; > + ds->width = COLS * FONT_WIDTH; > + ds->height = LINES * FONT_HEIGHT; > ds->dpy_update = curses_update; > ds->dpy_resize = curses_resize; > ds->dpy_refresh = curses_refresh; > @@ -371,6 +371,6 @@ void curses_display_init(DisplayState *ds, int full_screen) > > invalidate = 1; > > - /* Standard VGA initial text mode dimensions */ > - curses_resize(ds, 80, 25); > + /* setup up initial display size based on terminal settings */ > + curses_resize(ds, COLS, LINES); These two changes in curses.c don't look ok. ds->width/height and the curses_resize() parameters are not supposed to be the host terminal size, they're just the default settings for the virtual display size (same way as sdl.c sets 640x400 at start regardless of the host, and likely the bios will force the resize anyway). The host terminal dimensions are later taken into account in curses_calc_pad to ensure correct display. I can't comment on the console.c changes at the moment. Cheers