qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@web.de>
To: Blue Swirl <blauwirbel@gmail.com>
Cc: Stefan Weil <weil@mail.berlios.de>,
	Anthony Liguori <aliguori@us.ibm.com>,
	qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH v2] console: Implementing blinking of cursor
Date: Tue, 10 Jul 2012 21:44:45 +0200	[thread overview]
Message-ID: <4FFC862D.7020000@web.de> (raw)
In-Reply-To: <CAAu8pHuhue-qg-RN_5c=M6inpoppnXaJ__dthSXrzqBN-3jLdA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3783 bytes --]

On 2012-07-10 21:34, Blue Swirl wrote:
> On Mon, Jul 9, 2012 at 2:53 PM, Jan Kiszka <jan.kiszka@siemens.com> wrote:
>> Let the text console cursor blink at 2 HZ.
>>
>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>> ---
>>
>> Changes in v2:
>>  - fixed semantic of CONSOLE_CURSOR_PERIOD and reduced frequency
>>
>> I know there was a concern regarding the approach in general, but I
>> still consider it useful and visually more attractive than the static
>> cursor.
>>
>>  console.c |   26 +++++++++++++++++++++++++-
>>  1 files changed, 25 insertions(+), 1 deletions(-)
>>
>> diff --git a/console.c b/console.c
>> index 6a463f5..7729c08 100644
>> --- a/console.c
>> +++ b/console.c
>> @@ -28,6 +28,7 @@
>>  //#define DEBUG_CONSOLE
>>  #define DEFAULT_BACKSCROLL 512
>>  #define MAX_CONSOLES 12
>> +#define CONSOLE_CURSOR_PERIOD 500
>>
>>  #define QEMU_RGBA(r, g, b, a) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
>>  #define QEMU_RGB(r, g, b) QEMU_RGBA(r, g, b, 0xff)
>> @@ -139,6 +140,8 @@ struct TextConsole {
>>      TextCell *cells;
>>      int text_x[2], text_y[2], cursor_invalidate;
>>      int echo;
>> +    int cursor_blink_state;
> 
> Where did the bool version with the better name go?

Oops, it only improved the VGA version. Will fix.

Jan

> 
>> +    QEMUTimer *cursor_timer;
>>
>>      int update_x0;
>>      int update_y0;
>> @@ -615,7 +618,7 @@ static void console_show_cursor(TextConsole *s, int show)
>>              y += s->total_height;
>>          if (y < s->height) {
>>              c = &s->cells[y1 * s->width + x];
>> -            if (show) {
>> +            if (show && s->cursor_blink_state) {
>>                  TextAttributes t_attrib = s->t_attrib_default;
>>                  t_attrib.invers = !(t_attrib.invers); /* invert fg and bg */
>>                  vga_putcharxy(s->ds, x, y, c->ch, &t_attrib);
>> @@ -1083,6 +1086,10 @@ void console_select(unsigned int index)
>>      s = consoles[index];
>>      if (s) {
>>          DisplayState *ds = s->ds;
>> +
>> +        if (active_console->cursor_timer) {
>> +            qemu_del_timer(active_console->cursor_timer);
>> +        }
>>          active_console = s;
>>          if (ds_get_bits_per_pixel(s->ds)) {
>>              ds->surface = qemu_resize_displaysurface(ds, s->g_width, s->g_height);
>> @@ -1090,6 +1097,10 @@ void console_select(unsigned int index)
>>              s->ds->surface->width = s->width;
>>              s->ds->surface->height = s->height;
>>          }
>> +        if (s->cursor_timer) {
>> +            qemu_mod_timer(s->cursor_timer,
>> +                   qemu_get_clock_ms(rt_clock) + CONSOLE_CURSOR_PERIOD / 2);
>> +        }
>>          dpy_resize(s->ds);
>>          vga_hw_invalidate();
>>      }
>> @@ -1454,6 +1465,16 @@ static void text_console_set_echo(CharDriverState *chr, bool echo)
>>      s->echo = echo;
>>  }
>>
>> +static void text_console_update_cursor(void *opaque)
>> +{
>> +    TextConsole *s = opaque;
>> +
>> +    s->cursor_blink_state ^= 1;
>> +    vga_hw_invalidate();
>> +    qemu_mod_timer(s->cursor_timer,
>> +                   qemu_get_clock_ms(rt_clock) + CONSOLE_CURSOR_PERIOD / 2);
>> +}
>> +
>>  static void text_console_do_init(CharDriverState *chr, DisplayState *ds)
>>  {
>>      TextConsole *s;
>> @@ -1482,6 +1503,9 @@ static void text_console_do_init(CharDriverState *chr, DisplayState *ds)
>>          s->g_height = ds_get_height(s->ds);
>>      }
>>
>> +    s->cursor_timer =
>> +        qemu_new_timer_ms(rt_clock, text_console_update_cursor, s);
>> +
>>      s->hw_invalidate = text_console_invalidate;
>>      s->hw_text_update = text_console_update;
>>      s->hw = s;
>> --
>> 1.7.3.4
>>
> 
> 





[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

  reply	other threads:[~2012-07-10 19:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-02  8:20 [Qemu-devel] [PATCH] console: Implementing blinking of cursor Jan Kiszka
2012-07-03  8:59 ` Alon Levy
2012-07-03  9:05   ` Jan Kiszka
2012-07-03  9:49     ` Alon Levy
2012-07-03 14:41 ` Stefan Weil
2012-07-03 14:50   ` Jan Kiszka
2012-07-09 14:53 ` [Qemu-devel] [PATCH v2] " Jan Kiszka
2012-07-10 19:34   ` Blue Swirl
2012-07-10 19:44     ` Jan Kiszka [this message]
2012-07-10 20:00       ` [Qemu-devel] [PATCH v3] " Jan Kiszka
2012-07-14 12:20         ` Blue Swirl

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=4FFC862D.7020000@web.de \
    --to=jan.kiszka@web.de \
    --cc=aliguori@us.ibm.com \
    --cc=blauwirbel@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=weil@mail.berlios.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).