[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] ui/gtk: Add an option to disable automatic guest resize
From: |
James |
Subject: |
[PATCH] ui/gtk: Add an option to disable automatic guest resize |
Date: |
Thu, 27 May 2021 18:02:45 +1000 |
This patch added an option in the GTK frontend to disable automatic guest
resize when the host window is resized. The purpose of this is to prevent
resolution change loop when zooming in and/or changing guest resolution.
This patch does not include an option to disable automatic guest resize from
command line, but I can add one if desired. As a result, I've set the option
to be enabled by default.
Signed-off-by: James <j1@ionbox.in>
---
include/ui/gtk.h | 1 +
ui/gtk.c | 21 +++++++++++++++++----
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/include/ui/gtk.h b/include/ui/gtk.h
index 9516670ebc..6d61543226 100644
--- a/include/ui/gtk.h
+++ b/include/ui/gtk.h
@@ -111,6 +111,7 @@ struct GtkDisplayState {
GtkWidget *zoom_fit_item;
GtkWidget *grab_item;
GtkWidget *grab_on_hover_item;
+ GtkWidget *update_on_resize_item;
int nb_vcs;
VirtualConsole vc[MAX_VCS];
diff --git a/ui/gtk.c b/ui/gtk.c
index 98046f577b..f1a2b67906 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -671,12 +671,15 @@ static gboolean gd_window_close(GtkWidget *widget,
GdkEvent *event,
static void gd_set_ui_info(VirtualConsole *vc, gint width, gint height)
{
+ GtkDisplayState *s = vc->s;
QemuUIInfo info;
- memset(&info, 0, sizeof(info));
- info.width = width;
- info.height = height;
- dpy_set_ui_info(vc->gfx.dcl.con, &info);
+ if
(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(s->update_on_resize_item)))
{
+ memset(&info, 0, sizeof(info));
+ info.width = width;
+ info.height = height;
+ dpy_set_ui_info(vc->gfx.dcl.con, &info);
+ }
}
#if defined(CONFIG_OPENGL)
@@ -2114,6 +2117,12 @@ static GtkWidget *gd_create_menu_view(GtkDisplayState *s)
separator = gtk_separator_menu_item_new();
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), separator);
+ s->update_on_resize_item = gtk_check_menu_item_new_with_mnemonic(_("Update
Guest Resolution On Resize"));
+ gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->update_on_resize_item);
+
+ separator = gtk_separator_menu_item_new();
+ gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), separator);
+
/* gfx */
for (vc = 0;; vc++) {
con = qemu_console_lookup_by_index(vc);
@@ -2267,6 +2276,10 @@ static void gtk_display_init(DisplayState *ds,
DisplayOptions *opts)
opts->u.gtk.grab_on_hover) {
gtk_menu_item_activate(GTK_MENU_ITEM(s->grab_on_hover_item));
}
+
+ /* Follow old behaviour. */
+ gtk_menu_item_activate(GTK_MENU_ITEM(s->update_on_resize_item));
+
gd_clipboard_init(s);
}
--
2.25.1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] ui/gtk: Add an option to disable automatic guest resize,
James <=