All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] console: Implementing blinking of cursor
@ 2012-07-02  8:20 Jan Kiszka
  2012-07-03  8:59 ` Alon Levy
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Jan Kiszka @ 2012-07-02  8:20 UTC (permalink / raw)
  To: qemu-devel, Anthony Liguori

Let the text console cursor blink at 5 HZ.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 console.c |   26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/console.c b/console.c
index 6a463f5..29b0f1c 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 200
 
 #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;
+    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);
+        }
         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);
+}
+
 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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH] console: Implementing blinking of cursor
  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 14:41 ` Stefan Weil
  2012-07-09 14:53 ` [Qemu-devel] [PATCH v2] " Jan Kiszka
  2 siblings, 1 reply; 11+ messages in thread
From: Alon Levy @ 2012-07-03  8:59 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Anthony Liguori, qemu-devel

On Mon, Jul 02, 2012 at 10:20:17AM +0200, Jan Kiszka wrote:

One comment below.

Reviewed-by: Alon Levy <alevy@redhat.com>

> Let the text console cursor blink at 5 HZ.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>  console.c |   26 +++++++++++++++++++++++++-
>  1 files changed, 25 insertions(+), 1 deletions(-)
> 
> diff --git a/console.c b/console.c
> index 6a463f5..29b0f1c 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 200
>  
>  #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;
> +    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);
> +        }
>          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);
> +}
> +
>  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);
> +
missing initialization of cursor_blink_state

>      s->hw_invalidate = text_console_invalidate;
>      s->hw_text_update = text_console_update;
>      s->hw = s;
> -- 
> 1.7.3.4
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH] console: Implementing blinking of cursor
  2012-07-03  8:59 ` Alon Levy
@ 2012-07-03  9:05   ` Jan Kiszka
  2012-07-03  9:49     ` Alon Levy
  0 siblings, 1 reply; 11+ messages in thread
From: Jan Kiszka @ 2012-07-03  9:05 UTC (permalink / raw)
  To: Alon Levy; +Cc: Anthony Liguori, qemu-devel

On 2012-07-03 10:59, Alon Levy wrote:
> On Mon, Jul 02, 2012 at 10:20:17AM +0200, Jan Kiszka wrote:
> 
> One comment below.
> 
> Reviewed-by: Alon Levy <alevy@redhat.com>
> 
>> Let the text console cursor blink at 5 HZ.
>>
>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>> ---
>>  console.c |   26 +++++++++++++++++++++++++-
>>  1 files changed, 25 insertions(+), 1 deletions(-)
>>
>> diff --git a/console.c b/console.c
>> index 6a463f5..29b0f1c 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 200
>>  
>>  #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;
>> +    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);
>> +        }
>>          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);
>> +}
>> +
>>  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);
>> +
> missing initialization of cursor_blink_state

TextConsole is zero-initialized, so it does not really matter. Can add
it if preferred though.

Thanks for reviewing,
Jan

-- 
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH] console: Implementing blinking of cursor
  2012-07-03  9:05   ` Jan Kiszka
@ 2012-07-03  9:49     ` Alon Levy
  0 siblings, 0 replies; 11+ messages in thread
From: Alon Levy @ 2012-07-03  9:49 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Anthony Liguori, qemu-devel

On Tue, Jul 03, 2012 at 11:05:50AM +0200, Jan Kiszka wrote:
> On 2012-07-03 10:59, Alon Levy wrote:
> > On Mon, Jul 02, 2012 at 10:20:17AM +0200, Jan Kiszka wrote:
> > 
> > One comment below.
> > 
> > Reviewed-by: Alon Levy <alevy@redhat.com>
> > 
> >> Let the text console cursor blink at 5 HZ.
> >>
> >> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> >> ---
> >>  console.c |   26 +++++++++++++++++++++++++-
> >>  1 files changed, 25 insertions(+), 1 deletions(-)
> >>
> >> diff --git a/console.c b/console.c
> >> index 6a463f5..29b0f1c 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 200
> >>  
> >>  #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;
> >> +    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);
> >> +        }
> >>          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);
> >> +}
> >> +
> >>  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);
> >> +
> > missing initialization of cursor_blink_state
> 
> TextConsole is zero-initialized, so it does not really matter. Can add
> it if preferred though.

I just thought because you initialized the same named field in the vga patch.
No need if everything is zero initialized, missed that.

> 
> Thanks for reviewing,
> Jan
> 
> -- 
> Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
> Corporate Competence Center Embedded Linux
> 
> 
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH] console: Implementing blinking of cursor
  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 14:41 ` Stefan Weil
  2012-07-03 14:50   ` Jan Kiszka
  2012-07-09 14:53 ` [Qemu-devel] [PATCH v2] " Jan Kiszka
  2 siblings, 1 reply; 11+ messages in thread
From: Stefan Weil @ 2012-07-03 14:41 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Anthony Liguori, qemu-devel

Am 02.07.2012 10:20, schrieb Jan Kiszka:
> Let the text console cursor blink at 5 HZ.
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
> console.c | 26 +++++++++++++++++++++++++-
> 1 files changed, 25 insertions(+), 1 deletions(-)
>

Hi Jan,

I know that there was a "bug" report. Nevertheless I'd like
to ask whether QEMU really needs a blinking text cursor.

Blinking cursors are a matter of taste. I personally don't
want a blinking cursors. Nor do I want programs which
wake my cpu 5 times a second for something which I
don't need.

It's possible to get a blinking cursor without your patch
by redirecting QEMU's text console to one of the common
X terminal emulations (xterm, konsole, ...).

When QEMU gets GTK support, it might use a terminal
emulation which allows configurable cursor blinking.
IMHO that would be better than implementing that feature
in QEMU code.

That's why I suggest not to apply the patch.

Cheers,

Stefan

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH] console: Implementing blinking of cursor
  2012-07-03 14:41 ` Stefan Weil
@ 2012-07-03 14:50   ` Jan Kiszka
  0 siblings, 0 replies; 11+ messages in thread
From: Jan Kiszka @ 2012-07-03 14:50 UTC (permalink / raw)
  To: Stefan Weil; +Cc: Anthony Liguori, qemu-devel

On 2012-07-03 16:41, Stefan Weil wrote:
> Am 02.07.2012 10:20, schrieb Jan Kiszka:
>> Let the text console cursor blink at 5 HZ.
>>
>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>> ---
>> console.c | 26 +++++++++++++++++++++++++-
>> 1 files changed, 25 insertions(+), 1 deletions(-)
>>
> 
> Hi Jan,
> 
> I know that there was a "bug" report. Nevertheless I'd like
> to ask whether QEMU really needs a blinking text cursor.
> 
> Blinking cursors are a matter of taste. I personally don't
> want a blinking cursors. Nor do I want programs which
> wake my cpu 5 times a second for something which I
> don't need.
> 
> It's possible to get a blinking cursor without your patch
> by redirecting QEMU's text console to one of the common
> X terminal emulations (xterm, konsole, ...).
> 
> When QEMU gets GTK support, it might use a terminal
> emulation which allows configurable cursor blinking.
> IMHO that would be better than implementing that feature
> in QEMU code.
> 
> That's why I suggest not to apply the patch.

Well, *if* there should be heavy resistance against this patch, we may
postpone it. But I consider the feature useful to identify the cursor
position and check visually the liveliness of QEMU.

However, the VGA blinking is a feature that should go in, specifically
as there is no impact on wakeups and it fixes an emulation deficit.

Jan

-- 
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PATCH v2] console: Implementing blinking of cursor
  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 14:41 ` Stefan Weil
@ 2012-07-09 14:53 ` Jan Kiszka
  2012-07-10 19:34   ` Blue Swirl
  2 siblings, 1 reply; 11+ messages in thread
From: Jan Kiszka @ 2012-07-09 14:53 UTC (permalink / raw)
  To: qemu-devel, Anthony Liguori; +Cc: Stefan Weil

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;
+    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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH v2] console: Implementing blinking of cursor
  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
  0 siblings, 1 reply; 11+ messages in thread
From: Blue Swirl @ 2012-07-10 19:34 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Stefan Weil, Anthony Liguori, qemu-devel

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?

> +    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
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH v2] console: Implementing blinking of cursor
  2012-07-10 19:34   ` Blue Swirl
@ 2012-07-10 19:44     ` Jan Kiszka
  2012-07-10 20:00       ` [Qemu-devel] [PATCH v3] " Jan Kiszka
  0 siblings, 1 reply; 11+ messages in thread
From: Jan Kiszka @ 2012-07-10 19:44 UTC (permalink / raw)
  To: Blue Swirl; +Cc: Stefan Weil, Anthony Liguori, qemu-devel

[-- 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 --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PATCH v3] console: Implementing blinking of cursor
  2012-07-10 19:44     ` Jan Kiszka
@ 2012-07-10 20:00       ` Jan Kiszka
  2012-07-14 12:20         ` Blue Swirl
  0 siblings, 1 reply; 11+ messages in thread
From: Jan Kiszka @ 2012-07-10 20:00 UTC (permalink / raw)
  To: Blue Swirl; +Cc: Stefan Weil, Anthony Liguori, qemu-devel

From: Jan Kiszka <jan.kiszka@siemens.com>

Let the text console cursor blink at 2 HZ.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---

Changes in v3:
 - renamed cursor_blink_state to cursor_visible_phase and made it a bool

 console.c |   26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/console.c b/console.c
index 6a463f5..4525cc7 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;
+    bool cursor_visible_phase;
+    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_visible_phase) {
                 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_visible_phase = !s->cursor_visible_phase;
+    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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH v3] console: Implementing blinking of cursor
  2012-07-10 20:00       ` [Qemu-devel] [PATCH v3] " Jan Kiszka
@ 2012-07-14 12:20         ` Blue Swirl
  0 siblings, 0 replies; 11+ messages in thread
From: Blue Swirl @ 2012-07-14 12:20 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Stefan Weil, Anthony Liguori, qemu-devel

On Tue, Jul 10, 2012 at 8:00 PM, Jan Kiszka <jan.kiszka@web.de> wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
>
> Let the text console cursor blink at 2 HZ.
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>

Thanks, applied.

> ---
>
> Changes in v3:
>  - renamed cursor_blink_state to cursor_visible_phase and made it a bool
>
>  console.c |   26 +++++++++++++++++++++++++-
>  1 files changed, 25 insertions(+), 1 deletions(-)
>
> diff --git a/console.c b/console.c
> index 6a463f5..4525cc7 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;
> +    bool cursor_visible_phase;
> +    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_visible_phase) {
>                  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_visible_phase = !s->cursor_visible_phase;
> +    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

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-07-14 12:20 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2012-07-10 20:00       ` [Qemu-devel] [PATCH v3] " Jan Kiszka
2012-07-14 12:20         ` Blue Swirl

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.