From: Kevin Wolf <kwolf@redhat.com>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: Stefan Weil <sw@weilnetz.de>, Paolo Bonzini <pbonzini@redhat.com>,
qemu-devel@nongnu.org, Alex Graf <agraf@suse.de>
Subject: Re: [Qemu-devel] [PATCH 4/8] gtk: add virtual console support (v2)
Date: Mon, 27 Feb 2012 11:45:16 +0100 [thread overview]
Message-ID: <4F4B5EBC.7000004@redhat.com> (raw)
In-Reply-To: <1330299995-8688-5-git-send-email-aliguori@us.ibm.com>
Am 27.02.2012 00:46, schrieb Anthony Liguori:
> This enables VteTerminal to be used to render the text consoles. VteTerminal is
> the same widget used by gnome-terminal which means it's VT100 emulation is as
> good as they come.
>
> It's also screen reader accessible, supports copy/paste, proper scrolling and
> most of the other features you would expect from a terminal widget.
>
> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
> ---
> v1 -> v2
> - make sure to activate the menu item when switching tabs
> - fix sizing of non-0 pages
> ---
> console.c | 4 +-
> console.h | 4 +-
> ui/gtk.c | 160 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 164 insertions(+), 4 deletions(-)
>
> diff --git a/console.c b/console.c
> index 6434ed0..c12f02a 100644
> --- a/console.c
> +++ b/console.c
> @@ -1551,9 +1551,9 @@ static CharDriverState *text_console_init(QemuOpts *opts)
>
> static VcHandler *vc_handler = text_console_init;
>
> -int vc_init(QemuOpts *opts, CharDriverState **_chr)
> +CharDriverState *vc_init(QemuOpts *opts)
> {
> - return vc_handler(opts, _chr);
> + return vc_handler(opts);
> }
>
> void register_vc_handler(VcHandler *handler)
> diff --git a/console.h b/console.h
> index 9b4b390..27d7929 100644
> --- a/console.h
> +++ b/console.h
> @@ -363,9 +363,9 @@ void qemu_console_resize(DisplayState *ds, int width, int height);
> void qemu_console_copy(DisplayState *ds, int src_x, int src_y,
> int dst_x, int dst_y, int w, int h);
>
> -typedef int (VcHandler)(QemuOpts *, CharDriverState **);
> +typedef CharDriverState *(VcHandler)(QemuOpts *);
>
> -int vc_init(QemuOpts *opts, CharDriverState **_chr);
> +CharDriverState *vc_init(QemuOpts *opts);
> void register_vc_handler(VcHandler *handler);
>
> /* sdl.c */
> diff --git a/ui/gtk.c b/ui/gtk.c
> index 591a987..0579a55 100644
> --- a/ui/gtk.c
> +++ b/ui/gtk.c
> @@ -56,6 +56,8 @@
> #define dprintf(fmt, ...) do { } while (0)
> #endif
>
> +#define MAX_VCS 10
> +
> typedef struct VirtualConsole
> {
> GtkWidget *menu_item;
> @@ -79,6 +81,9 @@ typedef struct GtkDisplayState
> GtkWidget *view_menu;
> GtkWidget *vga_item;
>
> + int nb_vcs;
> + VirtualConsole vc[MAX_VCS];
> +
> GtkWidget *show_tabs_item;
>
> GtkWidget *vbox;
> @@ -400,6 +405,15 @@ static void gd_menu_switch_vc(GtkMenuItem *item, void *opaque)
>
> if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(s->vga_item))) {
> gtk_notebook_set_current_page(GTK_NOTEBOOK(s->notebook), 0);
> + } else {
> + int i;
> +
> + for (i = 0; i < s->nb_vcs; i++) {
> + if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(s->vc[i].menu_item))) {
> + gtk_notebook_set_current_page(GTK_NOTEBOOK(s->notebook), i + 1);
> + break;
> + }
> + }
> }
> }
>
> @@ -418,16 +432,154 @@ static void gd_change_page(GtkNotebook *nb, gpointer arg1, guint arg2,
> gpointer data)
> {
> GtkDisplayState *s = data;
> + guint last_page;
>
> if (!gtk_widget_get_realized(s->notebook)) {
> return;
> }
>
> + last_page = gtk_notebook_get_current_page(nb);
> +
> + if (last_page) {
> + gtk_widget_set_size_request(s->vc[last_page - 1].terminal, -1, -1);
> + }
> +
> + if (arg2 == 0) {
> + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->vga_item), TRUE);
> + } else {
> + VirtualConsole *vc = &s->vc[arg2 - 1];
> + VteTerminal *term = VTE_TERMINAL(vc->terminal);
> + int width, height;
> +
> + width = 80 * vte_terminal_get_char_width(term);
> + height = 25 * vte_terminal_get_char_height(term);
> +
> + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(vc->menu_item), TRUE);
> + gtk_widget_set_size_request(vc->terminal, width, height);
> + }
> +
> gd_update_cursor(s, TRUE);
> }
>
> +/** Virtual Console Callbacks **/
> +
> +static int gd_vc_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
> +{
> + VirtualConsole *vc = chr->opaque;
> +
> + return write(vc->fd, buf, len);
> +}
> +
> +static int nb_vcs;
> +static CharDriverState *vcs[MAX_VCS];
> +
> +static CharDriverState *gd_vc_handler(QemuOpts *opts)
> +{
> + CharDriverState *chr;
> +
> + chr = g_malloc0(sizeof(*chr));
> + chr->chr_write = gd_vc_chr_write;
> +
> + vcs[nb_vcs++] = chr;
> +
> + return chr;
> +}
> +
> void early_gtk_display_init(void)
> {
> + register_vc_handler(gd_vc_handler);
> +}
> +
> +static gboolean gd_vc_in(GIOChannel *chan, GIOCondition cond, void *opaque)
> +{
> + VirtualConsole *vc = opaque;
> + uint8_t buffer[1024];
> + ssize_t len;
> +
> + len = read(vc->fd, buffer, sizeof(buffer));
> + if (len <= 0) {
> + return FALSE;
> + }
> +
> + qemu_chr_be_write(vc->chr, buffer, len);
> +
> + return TRUE;
> +}
> +
> +static GSList *gd_vc_init(GtkDisplayState *s, VirtualConsole *vc, int index, GSList *group)
> +{
> + const char *label;
> + char buffer[32];
> + char path[32];
> + VtePty *pty;
> + GIOChannel *chan;
> + GtkWidget *scrolled_window;
> + GtkAdjustment *hadjustment, *vadjustment;
Doesn't build without modifications:
ui/gtk.c: In function 'gd_vc_init':
ui/gtk.c:661:20: error: variable 'hadjustment' set but not used
[-Werror=unused-but-set-variable]
cc1: all warnings being treated as errors
Kevin
next prev parent reply other threads:[~2012-02-27 10:42 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-26 23:46 [Qemu-devel] [PATCH 0/8] Add GTK UI to enable basic accessibility (v2) Anthony Liguori
2012-02-26 23:46 ` [Qemu-devel] [PATCH 1/8] console: allow VCs to be overridden by UI Anthony Liguori
2012-02-26 23:46 ` [Qemu-devel] [PATCH 2/8] chr: check to see if front end has registered a read function Anthony Liguori
2012-02-26 23:46 ` [Qemu-devel] [PATCH 3/8] ui: add basic GTK gui (v2) Anthony Liguori
2012-02-26 23:46 ` [Qemu-devel] [PATCH 4/8] gtk: add virtual console support (v2) Anthony Liguori
2012-02-27 10:45 ` Kevin Wolf [this message]
2012-02-26 23:46 ` [Qemu-devel] [PATCH 5/8] gtk: add support for input grabbing Anthony Liguori
2012-02-26 23:46 ` [Qemu-devel] [PATCH 6/8] gtk: add support for screen scaling and full screen (v2) Anthony Liguori
2012-02-27 20:10 ` Stefan Weil
2012-02-27 22:01 ` Anthony Liguori
2012-02-28 14:18 ` Kevin Wolf
2012-02-26 23:46 ` [Qemu-devel] [PATCH 7/8] gtk: add translation support Anthony Liguori
2012-02-27 8:32 ` Paolo Bonzini
2012-02-27 13:11 ` Anthony Liguori
2012-02-28 15:10 ` Kevin Wolf
2012-02-27 22:09 ` Stefan Weil
2012-02-26 23:46 ` [Qemu-devel] [PATCH 8/8] gtk: make default UI Anthony Liguori
2012-02-27 7:23 ` [Qemu-devel] [PATCH 0/8] Add GTK UI to enable basic accessibility (v2) malc
2012-02-27 8:21 ` Jan Kiszka
2012-02-27 13:10 ` Anthony Liguori
2012-02-27 13:26 ` Jan Kiszka
2012-02-27 13:33 ` Anthony Liguori
2012-02-27 13:42 ` Jan Kiszka
2012-02-27 13:50 ` Anthony Liguori
2012-02-27 13:54 ` Jan Kiszka
2012-02-27 16:39 ` Gerd Hoffmann
2012-02-27 16:44 ` Anthony Liguori
2012-02-27 16:54 ` Gerd Hoffmann
2012-02-27 14:24 ` Kevin Wolf
2012-02-27 14:39 ` Anthony Liguori
2012-02-27 15:03 ` Kevin Wolf
2012-03-11 17:29 ` Stefan Weil
2012-03-11 18:24 ` François Revol
2012-03-11 18:47 ` Stefan Weil
2012-03-12 2:31 ` Anthony Liguori
2012-03-12 16:39 ` François Revol
2012-03-12 17:13 ` Anthony Liguori
2012-03-12 2:30 ` Anthony Liguori
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=4F4B5EBC.7000004@redhat.com \
--to=kwolf@redhat.com \
--cc=agraf@suse.de \
--cc=aliguori@us.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=sw@weilnetz.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).