From patchwork Tue Jul 10 20:00:55 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 170272 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E2CFA2C01D3 for ; Wed, 11 Jul 2012 06:02:04 +1000 (EST) Received: from localhost ([::1]:55393 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SogdG-0008Co-Ph for incoming@patchwork.ozlabs.org; Tue, 10 Jul 2012 16:02:02 -0400 Received: from eggs.gnu.org ([208.118.235.92]:39151) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sogd9-0008CY-Qr for qemu-devel@nongnu.org; Tue, 10 Jul 2012 16:01:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sogcz-000569-Oc for qemu-devel@nongnu.org; Tue, 10 Jul 2012 16:01:55 -0400 Received: from mout.web.de ([212.227.17.11]:55748) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sogcz-00055x-E6 for qemu-devel@nongnu.org; Tue, 10 Jul 2012 16:01:45 -0400 Received: from mchn199C.mchp.siemens.de ([95.157.56.37]) by smtp.web.de (mrweb102) with ESMTPSA (Nemesis) id 0MZlMw-1SUP6k45QE-00LxMA; Tue, 10 Jul 2012 22:00:57 +0200 Message-ID: <4FFC89F7.3080706@web.de> Date: Tue, 10 Jul 2012 22:00:55 +0200 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: Blue Swirl References: <4FF159C1.8080508@siemens.com> <4FFAF082.8040108@siemens.com> <4FFC862D.7020000@web.de> In-Reply-To: <4FFC862D.7020000@web.de> X-Enigmail-Version: 1.4.2 X-Provags-ID: V02:K0:OmpsGu2bO78hbIRj2j4nGbV30mf8rfU4go3YHcvdzDn Pt2JLsEnNkOViIljgSMaiLJlvYR+6tEV2kmN5tBnhVPG5H6gQe Nl1hPMi+s1hnqJ/hwKV+QKMONqkbVUxTvcI8g+zv1JpuvF7TmG ADbjYdc2QIZ6ygTCD/X8RR1dPsHkG05SWe5BnldfmXoBPF4BSw SOyi/o7lXAVoGmXrachkg== X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.227.17.11 Cc: Stefan Weil , Anthony Liguori , qemu-devel Subject: [Qemu-devel] [PATCH v3] console: Implementing blinking of cursor X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jan Kiszka Let the text console cursor blink at 2 HZ. Signed-off-by: Jan Kiszka --- 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;