From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:55111) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SogMl-0000VC-FE for qemu-devel@nongnu.org; Tue, 10 Jul 2012 15:45:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SogMh-0000RT-Ts for qemu-devel@nongnu.org; Tue, 10 Jul 2012 15:44:59 -0400 Received: from mout.web.de ([212.227.17.11]:60701) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SogMh-0000Qf-JV for qemu-devel@nongnu.org; Tue, 10 Jul 2012 15:44:55 -0400 Message-ID: <4FFC862D.7020000@web.de> Date: Tue, 10 Jul 2012 21:44:45 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <4FF159C1.8080508@siemens.com> <4FFAF082.8040108@siemens.com> In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig8ADBD53653D5394237FBC9B3" Subject: Re: [Qemu-devel] [PATCH v2] console: Implementing blinking of cursor List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: Stefan Weil , Anthony Liguori , qemu-devel This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig8ADBD53653D5394237FBC9B3 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 2012-07-10 21:34, Blue Swirl wrote: > On Mon, Jul 9, 2012 at 2:53 PM, Jan Kiszka wro= te: >> Let the text console cursor blink at 2 HZ. >> >> Signed-off-by: Jan Kiszka >> --- >> >> 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; >=20 > Where did the bool version with the better name go? Oops, it only improved the VGA version. Will fix. Jan >=20 >> + QEMUTimer *cursor_timer; >> >> int update_x0; >> int update_y0; >> @@ -615,7 +618,7 @@ static void console_show_cursor(TextConsole *s, in= t show) >> y +=3D s->total_height; >> if (y < s->height) { >> c =3D &s->cells[y1 * s->width + x]; >> - if (show) { >> + if (show && s->cursor_blink_state) { >> TextAttributes t_attrib =3D s->t_attrib_default; >> t_attrib.invers =3D !(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 =3D consoles[index]; >> if (s) { >> DisplayState *ds =3D s->ds; >> + >> + if (active_console->cursor_timer) { >> + qemu_del_timer(active_console->cursor_timer); >> + } >> active_console =3D s; >> if (ds_get_bits_per_pixel(s->ds)) { >> ds->surface =3D qemu_resize_displaysurface(ds, s->g_width= , s->g_height); >> @@ -1090,6 +1097,10 @@ void console_select(unsigned int index) >> s->ds->surface->width =3D s->width; >> s->ds->surface->height =3D s->height; >> } >> + if (s->cursor_timer) { >> + qemu_mod_timer(s->cursor_timer, >> + qemu_get_clock_ms(rt_clock) + CONSOLE_CURSOR_PERIO= D / 2); >> + } >> dpy_resize(s->ds); >> vga_hw_invalidate(); >> } >> @@ -1454,6 +1465,16 @@ static void text_console_set_echo(CharDriverSta= te *chr, bool echo) >> s->echo =3D echo; >> } >> >> +static void text_console_update_cursor(void *opaque) >> +{ >> + TextConsole *s =3D opaque; >> + >> + s->cursor_blink_state ^=3D 1; >> + vga_hw_invalidate(); >> + qemu_mod_timer(s->cursor_timer, >> + qemu_get_clock_ms(rt_clock) + CONSOLE_CURSOR_PERIO= D / 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 =3D ds_get_height(s->ds); >> } >> >> + s->cursor_timer =3D >> + qemu_new_timer_ms(rt_clock, text_console_update_cursor, s); >> + >> s->hw_invalidate =3D text_console_invalidate; >> s->hw_text_update =3D text_console_update; >> s->hw =3D s; >> -- >> 1.7.3.4 >> >=20 >=20 --------------enig8ADBD53653D5394237FBC9B3 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk/8hjIACgkQitSsb3rl5xT/xACg5otV+anK+DFTLthz8mn12fcP aqMAoKbtHzdd/n6pBSgkIG+TJD964xA4 =UH2z -----END PGP SIGNATURE----- --------------enig8ADBD53653D5394237FBC9B3--