@@ -1098,8 +1098,8 @@ static void gd_change_page(GtkNotebook *nb, gpointer arg1, guint arg2,
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 (last_page && s->vc[last_page - 1].terminal) {
+ gtk_widget_hide(s->vc[last_page - 1].terminal);
}
on_vga = arg2 == 0;
@@ -1117,14 +1117,9 @@ static void gd_change_page(GtkNotebook *nb, gpointer arg1, guint arg2,
} else {
#if defined(CONFIG_VTE)
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);
+ gtk_widget_show(vc->terminal);
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(vc->menu_item),
+ TRUE);
#else
g_assert_not_reached();
#endif
@@ -1230,6 +1225,7 @@ static GSList *gd_vc_init(GtkDisplayState *s, VirtualConsole *vc, int index, GSL
GtkWidget *scrolled_window;
GtkAdjustment *vadjustment;
int master_fd, slave_fd;
+ int width, height;
snprintf(buffer, sizeof(buffer), "vc%d", index);
snprintf(path, sizeof(path), "<QEMU>/View/VC%d", index);
@@ -1270,7 +1266,16 @@ static GSList *gd_vc_init(GtkDisplayState *s, VirtualConsole *vc, int index, GSL
scrolled_window = gtk_scrolled_window_new(NULL, vadjustment);
gtk_container_add(GTK_CONTAINER(scrolled_window), vc->terminal);
- vte_terminal_set_size(VTE_TERMINAL(vc->terminal), 80, 25);
+ width = 80 * vte_terminal_get_char_width(VTE_TERMINAL(vc->terminal));
+ height = 25 * vte_terminal_get_char_height(VTE_TERMINAL(vc->terminal));
+#if GTK_CHECK_VERSION(3, 0, 0)
+ gtk_scrolled_window_set_min_content_width(
+ GTK_SCROLLED_WINDOW(scrolled_window), width);
+ gtk_scrolled_window_set_min_content_height(
+ GTK_SCROLLED_WINDOW(scrolled_window), height);
+#else
+ gtk_widget_set_size_request(vc->terminal, width, height);
+#endif
vc->fd = slave_fd;
vc->chr->opaque = vc;
@@ -1514,6 +1519,7 @@ void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover)
{
GtkDisplayState *s = g_malloc0(sizeof(*s));
char *filename;
+ int i;
gtk_init(NULL, NULL);
@@ -1586,6 +1592,12 @@ void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover)
gtk_widget_show_all(s->window);
+ for (i = 0; i < s->nb_vcs; i++) {
+ if (s->vc[i].terminal) {
+ gtk_widget_hide(s->vc[i].terminal);
+ }
+ }
+
if (full_screen) {
gtk_menu_item_activate(GTK_MENU_ITEM(s->full_screen_item));
}
The monitor greeting is line wrapped like: QEMU 1.6.1 m onitor - typ e 'help' for more inform ation (qemu) Apparently requesting the vte terminal size isn't sufficient, we need to force a size_request so text doesn't line wrap. We use slightly different APIs for gtk3, since on 3.10 the size_request trick doesn't seem to work. Rather than duplicate the size request logic on tab change, just hide/unhide the terminal widget when we switch tabs. This ensures that the initial terminal size request doesn't restrict the minimum size of the graphical window. Signed-off-by: Cole Robinson <crobinso@redhat.com> --- ui/gtk.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-)