Commit d0f2245b5a for qemu.org
commit d0f2245b5a404b8045d349b07ab7db60a2c52dd7
Author: Marc-André Lureau <marcandre.lureau@redhat.com>
Date: Tue Jun 23 11:44:42 2026 +0400
ui/gtk: move global display settings out of per-console init
Move zoom_to_fit, keep_aspect_ratio and touch_slots initialisation
from gd_vc_gfx_init() to gd_create_menu_view(). These are global
display settings that should be set once after all consoles are
created, not repeated on every per-console init (where the last
iteration's values silently win).
Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20260623-b4-ui-v4-27-4656aec3398d@redhat.com>
diff --git a/ui/gtk.c b/ui/gtk.c
index b4dcdcd9a4..929e4cf43f 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -2269,8 +2269,6 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc,
GSList *group, GtkWidget *view_menu)
{
const DisplayChangeListenerOps *ops = &dcl_ops;
- bool zoom_to_fit = false;
- int i;
vc->label = qemu_console_get_label(con);
vc->s = s;
@@ -2350,26 +2348,6 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc,
gd_connect_vc_gfx_signals(vc);
group = gd_vc_menu_init(s, vc, idx, group, view_menu);
- if (qemu_console_ui_info_supported(vc->gfx.dcl.con)) {
- zoom_to_fit = true;
- }
- if (s->opts->u.gtk.has_zoom_to_fit) {
- zoom_to_fit = s->opts->u.gtk.zoom_to_fit;
- }
- if (zoom_to_fit) {
- gtk_menu_item_activate(GTK_MENU_ITEM(s->zoom_fit_item));
- s->free_scale = true;
- }
-
- s->keep_aspect_ratio = true;
- if (s->opts->u.gtk.has_keep_aspect_ratio)
- s->keep_aspect_ratio = s->opts->u.gtk.keep_aspect_ratio;
-
- for (i = 0; i < INPUT_EVENT_SLOTS_MAX; i++) {
- struct touch_slot *slot = &touch_slots[i];
- slot->tracking_id = -1;
- }
-
return group;
}
@@ -2379,7 +2357,8 @@ static GtkWidget *gd_create_menu_view(GtkDisplayState *s, DisplayOptions *opts)
GtkWidget *view_menu;
GtkWidget *separator;
QemuConsole *con;
- int vc;
+ bool zoom_to_fit = false;
+ int vc, i;
view_menu = gtk_menu_new();
gtk_menu_set_accel_group(GTK_MENU(view_menu), s->accel_group);
@@ -2453,6 +2432,27 @@ static GtkWidget *gd_create_menu_view(GtkDisplayState *s, DisplayOptions *opts)
v = g_new0(VirtualConsole, 1);
g_ptr_array_add(s->vcs, v);
group = gd_vc_gfx_init(s, v, con, vc, group, view_menu);
+ if (qemu_console_ui_info_supported(con)) {
+ zoom_to_fit = true;
+ }
+ }
+
+ if (s->opts->u.gtk.has_zoom_to_fit) {
+ zoom_to_fit = s->opts->u.gtk.zoom_to_fit;
+ }
+ if (zoom_to_fit) {
+ gtk_menu_item_activate(GTK_MENU_ITEM(s->zoom_fit_item));
+ s->free_scale = true;
+ }
+
+ s->keep_aspect_ratio = true;
+ if (s->opts->u.gtk.has_keep_aspect_ratio) {
+ s->keep_aspect_ratio = s->opts->u.gtk.keep_aspect_ratio;
+ }
+
+ for (i = 0; i < INPUT_EVENT_SLOTS_MAX; i++) {
+ struct touch_slot *slot = &touch_slots[i];
+ slot->tracking_id = -1;
}
#if defined(CONFIG_VTE)