@samitouri / QOSamiQemu / commits / d0f2245b5a

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>

Marc-André Lureau committed Jun 23, 2026 at 11:44 UTC d0f2245b5a404b8045d349b07ab7db60a2c52dd7
1 file changed +23 -23
ui/gtk.c
+23 -23
@@ -2269,8 +2269,6 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc,
2269 GSList *group, GtkWidget *view_menu)
2270 {
2271 const DisplayChangeListenerOps *ops = &dcl_ops;
2272 - bool zoom_to_fit = false;
2273 - int i;
2272
2273 vc->label = qemu_console_get_label(con);
2274 vc->s = s;
@@ -2350,26 +2348,6 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc,
2348 gd_connect_vc_gfx_signals(vc);
2349 group = gd_vc_menu_init(s, vc, idx, group, view_menu);
2350
2353 - if (qemu_console_ui_info_supported(vc->gfx.dcl.con)) {
2354 - zoom_to_fit = true;
2355 - }
2356 - if (s->opts->u.gtk.has_zoom_to_fit) {
2357 - zoom_to_fit = s->opts->u.gtk.zoom_to_fit;
2358 - }
2359 - if (zoom_to_fit) {
2360 - gtk_menu_item_activate(GTK_MENU_ITEM(s->zoom_fit_item));
2361 - s->free_scale = true;
2362 - }
2363 -
2364 - s->keep_aspect_ratio = true;
2365 - if (s->opts->u.gtk.has_keep_aspect_ratio)
2366 - s->keep_aspect_ratio = s->opts->u.gtk.keep_aspect_ratio;
2367 -
2368 - for (i = 0; i < INPUT_EVENT_SLOTS_MAX; i++) {
2369 - struct touch_slot *slot = &touch_slots[i];
2370 - slot->tracking_id = -1;
2371 - }
2372 -
2351 return group;
2352 }
2353
@@ -2379,7 +2357,8 @@ static GtkWidget *gd_create_menu_view(GtkDisplayState *s, DisplayOptions *opts)
2357 GtkWidget *view_menu;
2358 GtkWidget *separator;
2359 QemuConsole *con;
2382 - int vc;
2360 + bool zoom_to_fit = false;
2361 + int vc, i;
2362
2363 view_menu = gtk_menu_new();
2364 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)
2432 v = g_new0(VirtualConsole, 1);
2433 g_ptr_array_add(s->vcs, v);
2434 group = gd_vc_gfx_init(s, v, con, vc, group, view_menu);
2435 + if (qemu_console_ui_info_supported(con)) {
2436 + zoom_to_fit = true;
2437 + }
2438 + }
2439 +
2440 + if (s->opts->u.gtk.has_zoom_to_fit) {
2441 + zoom_to_fit = s->opts->u.gtk.zoom_to_fit;
2442 + }
2443 + if (zoom_to_fit) {
2444 + gtk_menu_item_activate(GTK_MENU_ITEM(s->zoom_fit_item));
2445 + s->free_scale = true;
2446 + }
2447 +
2448 + s->keep_aspect_ratio = true;
2449 + if (s->opts->u.gtk.has_keep_aspect_ratio) {
2450 + s->keep_aspect_ratio = s->opts->u.gtk.keep_aspect_ratio;
2451 + }
2452 +
2453 + for (i = 0; i < INPUT_EVENT_SLOTS_MAX; i++) {
2454 + struct touch_slot *slot = &touch_slots[i];
2455 + slot->tracking_id = -1;
2456 }
2457
2458 #if defined(CONFIG_VTE)