All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ryan Harper <ryanh@us.ibm.com>
To: andrzej zaborowski <balrogg@gmail.com>
Cc: qemu-devel@nongnu.org, Ryan Harper <ryanh@us.ibm.com>,
	kvm@vger.kernel.org
Subject: Re: [Qemu-devel] [PATCH 1/2] Fix text console size/resize when using curses
Date: Fri, 22 Aug 2008 17:56:47 -0500	[thread overview]
Message-ID: <20080822225647.GC17312@us.ibm.com> (raw)
In-Reply-To: <fb249edb0808221540n2caf2017k26842e0bcfc08b40@mail.gmail.com>

* andrzej zaborowski <balrogg@gmail.com> [2008-08-22 17:40]:
> 2008/8/22 Ryan Harper <ryanh@us.ibm.com>:
> > 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 <ryanh@us.ibm.com>
> >
> > 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.

Hrm, indeed.  I had initially included that because without it the
first display of the monitor wasn't correct.  Pulling those changes out,
that doesn't seem to be needed any more.

> I can't comment on the console.c changes at the moment.

I'll await comments on console.c and resend without the above two
superflous changes.

-- 
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
(512) 838-9253   T/L: 678-9253
ryanh@us.ibm.com

WARNING: multiple messages have this Message-ID (diff)
From: Ryan Harper <ryanh@us.ibm.com>
To: andrzej zaborowski <balrogg@gmail.com>
Cc: Ryan Harper <ryanh@us.ibm.com>,
	qemu-devel@nongnu.org, kvm@vger.kernel.org
Subject: Re: [Qemu-devel] [PATCH 1/2] Fix text console size/resize when using curses
Date: Fri, 22 Aug 2008 17:56:47 -0500	[thread overview]
Message-ID: <20080822225647.GC17312@us.ibm.com> (raw)
In-Reply-To: <fb249edb0808221540n2caf2017k26842e0bcfc08b40@mail.gmail.com>

* andrzej zaborowski <balrogg@gmail.com> [2008-08-22 17:40]:
> 2008/8/22 Ryan Harper <ryanh@us.ibm.com>:
> > 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 <ryanh@us.ibm.com>
> >
> > 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.

Hrm, indeed.  I had initially included that because without it the
first display of the monitor wasn't correct.  Pulling those changes out,
that doesn't seem to be needed any more.

> I can't comment on the console.c changes at the moment.

I'll await comments on console.c and resend without the above two
superflous changes.

-- 
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
(512) 838-9253   T/L: 678-9253
ryanh@us.ibm.com

  reply	other threads:[~2008-08-22 22:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-22 18:03 [PATCH 0/2] Fix monitor console in curses mode Ryan Harper
2008-08-22 18:03 ` [Qemu-devel] " Ryan Harper
2008-08-22 18:03 ` [PATCH 1/2] Fix text console size/resize when using curses Ryan Harper
2008-08-22 18:03   ` [Qemu-devel] " Ryan Harper
2008-08-22 22:40   ` andrzej zaborowski
2008-08-22 22:56     ` Ryan Harper [this message]
2008-08-22 22:56       ` Ryan Harper
2008-08-22 18:03 ` [PATCH 2/2] Fix typo in console.c comment Ryan Harper
2008-08-22 18:03   ` [Qemu-devel] " Ryan Harper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080822225647.GC17312@us.ibm.com \
    --to=ryanh@us.ibm.com \
    --cc=balrogg@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.