gtk: support multiple gfx displays
Each display gets its own tab. Tab switching continues to work like it did, just the hotkeys of the vte consoles changes in case a secondary display is present as it will get ctrl-alt-2 assigned and the vtes are shifted by one. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
e3500d1f5f
commit
ed1132e41a
80
ui/gtk.c
80
ui/gtk.c
@ -1206,6 +1206,26 @@ static gboolean gd_focus_out_event(GtkWidget *widget,
|
|||||||
|
|
||||||
/** Virtual Console Callbacks **/
|
/** Virtual Console Callbacks **/
|
||||||
|
|
||||||
|
static GSList *gd_vc_menu_init(GtkDisplayState *s, VirtualConsole *vc,
|
||||||
|
const char *label, int idx,
|
||||||
|
GSList *group, GtkWidget *view_menu)
|
||||||
|
{
|
||||||
|
char path[32];
|
||||||
|
|
||||||
|
snprintf(path, sizeof(path), "<QEMU>/View/VC%d", idx);
|
||||||
|
|
||||||
|
vc->menu_item = gtk_radio_menu_item_new_with_mnemonic(group, label);
|
||||||
|
group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(vc->menu_item));
|
||||||
|
gtk_menu_item_set_accel_path(GTK_MENU_ITEM(vc->menu_item), path);
|
||||||
|
gtk_accel_map_add_entry(path, GDK_KEY_1 + idx, HOTKEY_MODIFIERS);
|
||||||
|
|
||||||
|
g_signal_connect(vc->menu_item, "activate",
|
||||||
|
G_CALLBACK(gd_menu_switch_vc), s);
|
||||||
|
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), vc->menu_item);
|
||||||
|
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_VTE)
|
#if defined(CONFIG_VTE)
|
||||||
static void gd_vc_adjustment_changed(GtkAdjustment *adjustment, void *opaque)
|
static void gd_vc_adjustment_changed(GtkAdjustment *adjustment, void *opaque)
|
||||||
{
|
{
|
||||||
@ -1253,32 +1273,22 @@ static gboolean gd_vc_in(VteTerminal *terminal, gchar *text, guint size,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GSList *gd_vc_vte_init(GtkDisplayState *s, VirtualConsole *vc, int index,
|
static GSList *gd_vc_vte_init(GtkDisplayState *s, VirtualConsole *vc,
|
||||||
|
CharDriverState *chr, int idx,
|
||||||
GSList *group, GtkWidget *view_menu)
|
GSList *group, GtkWidget *view_menu)
|
||||||
{
|
{
|
||||||
const char *label;
|
const char *label;
|
||||||
char buffer[32];
|
char buffer[32];
|
||||||
char path[32];
|
|
||||||
GtkWidget *box;
|
GtkWidget *box;
|
||||||
GtkWidget *scrollbar;
|
GtkWidget *scrollbar;
|
||||||
GtkAdjustment *vadjustment;
|
GtkAdjustment *vadjustment;
|
||||||
|
|
||||||
snprintf(buffer, sizeof(buffer), "vc%d", index);
|
|
||||||
snprintf(path, sizeof(path), "<QEMU>/View/VC%d", index);
|
|
||||||
|
|
||||||
vc->s = s;
|
vc->s = s;
|
||||||
vc->vte.chr = vcs[index];
|
vc->vte.chr = chr;
|
||||||
|
|
||||||
if (vc->vte.chr->label) {
|
snprintf(buffer, sizeof(buffer), "vc%d", idx);
|
||||||
label = vc->vte.chr->label;
|
label = vc->vte.chr->label ? vc->vte.chr->label : buffer;
|
||||||
} else {
|
group = gd_vc_menu_init(s, vc, vc->vte.chr->label, idx, group, view_menu);
|
||||||
label = buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
vc->menu_item = gtk_radio_menu_item_new_with_mnemonic(group, label);
|
|
||||||
group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(vc->menu_item));
|
|
||||||
gtk_menu_item_set_accel_path(GTK_MENU_ITEM(vc->menu_item), path);
|
|
||||||
gtk_accel_map_add_entry(path, GDK_KEY_2 + index, HOTKEY_MODIFIERS);
|
|
||||||
|
|
||||||
vc->vte.terminal = vte_terminal_new();
|
vc->vte.terminal = vte_terminal_new();
|
||||||
g_signal_connect(vc->vte.terminal, "commit", G_CALLBACK(gd_vc_in), vc);
|
g_signal_connect(vc->vte.terminal, "commit", G_CALLBACK(gd_vc_in), vc);
|
||||||
@ -1315,10 +1325,6 @@ static GSList *gd_vc_vte_init(GtkDisplayState *s, VirtualConsole *vc, int index,
|
|||||||
vc->tab_item = box;
|
vc->tab_item = box;
|
||||||
gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook), vc->tab_item,
|
gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook), vc->tab_item,
|
||||||
gtk_label_new(label));
|
gtk_label_new(label));
|
||||||
g_signal_connect(vc->menu_item, "activate",
|
|
||||||
G_CALLBACK(gd_menu_switch_vc), s);
|
|
||||||
|
|
||||||
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), vc->menu_item);
|
|
||||||
|
|
||||||
qemu_chr_be_generic_open(vc->vte.chr);
|
qemu_chr_be_generic_open(vc->vte.chr);
|
||||||
if (vc->vte.chr->init) {
|
if (vc->vte.chr->init) {
|
||||||
@ -1328,15 +1334,14 @@ static GSList *gd_vc_vte_init(GtkDisplayState *s, VirtualConsole *vc, int index,
|
|||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gd_vcs_init(GtkDisplayState *s, int offset, GSList *group,
|
static void gd_vcs_init(GtkDisplayState *s, GSList *group,
|
||||||
GtkWidget *view_menu)
|
GtkWidget *view_menu)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < nb_vcs; i++) {
|
for (i = 0; i < nb_vcs; i++) {
|
||||||
VirtualConsole *vc = &s->vc[offset+i];
|
VirtualConsole *vc = &s->vc[s->nb_vcs];
|
||||||
|
group = gd_vc_vte_init(s, vc, vcs[i], s->nb_vcs, group, view_menu);
|
||||||
group = gd_vc_vte_init(s, vc, i, group, view_menu);
|
|
||||||
s->nb_vcs++;
|
s->nb_vcs++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1449,7 +1454,7 @@ static const DisplayChangeListenerOps dcl_ops = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc,
|
static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc,
|
||||||
QemuConsole *con, int index,
|
QemuConsole *con, int idx,
|
||||||
GSList *group, GtkWidget *view_menu)
|
GSList *group, GtkWidget *view_menu)
|
||||||
{
|
{
|
||||||
vc->s = s;
|
vc->s = s;
|
||||||
@ -1475,15 +1480,7 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc,
|
|||||||
vc->tab_item, gtk_label_new("VGA"));
|
vc->tab_item, gtk_label_new("VGA"));
|
||||||
gd_connect_vc_gfx_signals(vc);
|
gd_connect_vc_gfx_signals(vc);
|
||||||
|
|
||||||
vc->menu_item = gtk_radio_menu_item_new_with_mnemonic(group, "_VGA");
|
group = gd_vc_menu_init(s, vc, "VGA", idx, group, view_menu);
|
||||||
group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(vc->menu_item));
|
|
||||||
gtk_menu_item_set_accel_path(GTK_MENU_ITEM(vc->menu_item),
|
|
||||||
"<QEMU>/View/VGA");
|
|
||||||
gtk_accel_map_add_entry("<QEMU>/View/VGA", GDK_KEY_1, HOTKEY_MODIFIERS);
|
|
||||||
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), vc->menu_item);
|
|
||||||
|
|
||||||
g_signal_connect(vc->menu_item, "activate",
|
|
||||||
G_CALLBACK(gd_menu_switch_vc), s);
|
|
||||||
|
|
||||||
vc->gfx.dcl.ops = &dcl_ops;
|
vc->gfx.dcl.ops = &dcl_ops;
|
||||||
vc->gfx.dcl.con = con;
|
vc->gfx.dcl.con = con;
|
||||||
@ -1497,6 +1494,8 @@ static GtkWidget *gd_create_menu_view(GtkDisplayState *s, GtkAccelGroup *accel_g
|
|||||||
GSList *group = NULL;
|
GSList *group = NULL;
|
||||||
GtkWidget *view_menu;
|
GtkWidget *view_menu;
|
||||||
GtkWidget *separator;
|
GtkWidget *separator;
|
||||||
|
QemuConsole *con;
|
||||||
|
int vc;
|
||||||
|
|
||||||
view_menu = gtk_menu_new();
|
view_menu = gtk_menu_new();
|
||||||
gtk_menu_set_accel_group(GTK_MENU(view_menu), accel_group);
|
gtk_menu_set_accel_group(GTK_MENU(view_menu), accel_group);
|
||||||
@ -1552,12 +1551,19 @@ static GtkWidget *gd_create_menu_view(GtkDisplayState *s, GtkAccelGroup *accel_g
|
|||||||
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), separator);
|
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), separator);
|
||||||
|
|
||||||
/* gfx */
|
/* gfx */
|
||||||
group = gd_vc_gfx_init(s, &s->vc[0], qemu_console_lookup_by_index(0), 0,
|
for (vc = 0;; vc++) {
|
||||||
group, view_menu);
|
con = qemu_console_lookup_by_index(vc);
|
||||||
|
if (!con || !qemu_console_is_graphic(con)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
group = gd_vc_gfx_init(s, &s->vc[vc], con,
|
||||||
|
vc, group, view_menu);
|
||||||
|
s->nb_vcs++;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_VTE)
|
#if defined(CONFIG_VTE)
|
||||||
/* vte */
|
/* vte */
|
||||||
gd_vcs_init(s, 1, group, view_menu);
|
gd_vcs_init(s, group, view_menu);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
separator = gtk_separator_menu_item_new();
|
separator = gtk_separator_menu_item_new();
|
||||||
|
Loading…
Reference in New Issue
Block a user