Query the terminal size from the vte library when creating the console and every time it might change. Vte doesn't send any signal specifically for terminal size changes, so instead we register callbacks for size-allocate and char-size-changed.
Signed-off-by: Filip Hejsek <filip.hej...@gmail.com> --- ui/gtk.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/ui/gtk.c b/ui/gtk.c index e91d093a49e5d05c10f1dbea5b9b94ff1389b456..ff2709160787f0e2974c83802d932758866f6d44 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -2025,6 +2025,27 @@ static gboolean gd_vc_in(VteTerminal *terminal, gchar *text, guint size, return TRUE; } +static void gd_vc_vte_update_size(VirtualConsole *vc) +{ + uint16_t cols = vte_terminal_get_column_count(VTE_TERMINAL(vc->vte.terminal)); + uint16_t rows = vte_terminal_get_row_count(VTE_TERMINAL(vc->vte.terminal)); + qemu_chr_resize(vc->vte.chr, cols, rows); +} + +static void gd_vc_size_allocate(VteTerminal *terminal, + GtkAllocation *allocation, gpointer user_data) +{ + VirtualConsole *vc = user_data; + gd_vc_vte_update_size(vc); +} + +static void gd_vc_char_size_changed(VteTerminal *terminal, guint width, + guint height, gpointer user_data) +{ + VirtualConsole *vc = user_data; + gd_vc_vte_update_size(vc); +} + static GSList *gd_vc_vte_init(GtkDisplayState *s, VirtualConsole *vc, Chardev *chr, int idx, GSList *group, GtkWidget *view_menu) @@ -2090,6 +2111,12 @@ static GSList *gd_vc_vte_init(GtkDisplayState *s, VirtualConsole *vc, qemu_chr_be_event(vc->vte.chr, CHR_EVENT_OPENED); + g_signal_connect(vc->vte.terminal, "size-allocate", + G_CALLBACK(gd_vc_size_allocate), vc); + g_signal_connect(vc->vte.terminal, "char-size-changed", + G_CALLBACK(gd_vc_char_size_changed), vc); + gd_vc_vte_update_size(vc); + return group; } -- 2.51.0