From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:43323) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Slz3e-0002gR-Bm for qemu-devel@nongnu.org; Tue, 03 Jul 2012 05:06:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Slz3U-0007MF-CI for qemu-devel@nongnu.org; Tue, 03 Jul 2012 05:06:05 -0400 Received: from goliath.siemens.de ([192.35.17.28]:17664) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Slz3U-0007Lg-2W for qemu-devel@nongnu.org; Tue, 03 Jul 2012 05:05:56 -0400 Message-ID: <4FF2B5EE.8070809@siemens.com> Date: Tue, 03 Jul 2012 11:05:50 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <4FF159C1.8080508@siemens.com> <20120703085932.GU5973@garlic.tlv.redhat.com> In-Reply-To: <20120703085932.GU5973@garlic.tlv.redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] console: Implementing blinking of cursor List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 > >> Let the text console cursor blink at 5 HZ. >> >> Signed-off-by: Jan Kiszka >> --- >> 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