From e9e2ebb7969f917738d4d2f73f762d3a59d7cc7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Wed, 10 Mar 2021 17:52:21 +0000 Subject: [PATCH] src: add --auto-resize CLI arg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is used to control whether resizing of the remote framebuffer is permitted. Fixes: https://gitlab.com/virt-viewer/virt-viewer/-/issues/20 Signed-off-by: Daniel P. Berrangé --- man/remote-viewer.pod | 9 ++++++++- man/virt-viewer.pod | 6 ++++++ src/virt-viewer-app.c | 21 +++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/man/remote-viewer.pod b/man/remote-viewer.pod index 353b5fc..c25b70e 100644 --- a/man/remote-viewer.pod +++ b/man/remote-viewer.pod @@ -53,11 +53,18 @@ Start with the windows maximized to fullscreen. If supported, the remote display will be reconfigured to match the physical client monitor configuration, by enabling or disabling extra monitors as -necessary. This is currently implemented by the Spice backend only. +necessary. This is currently implemented by the Spice backend only and +can be disabled by the C<--auto-resize> arguemnt. To specify which client monitors are used in fullscreen mode, see the CONFIGURATION section below. +=item -r , --auto-resize + +Controls whether it is permitted to attempt to resize the remote framebuffer +to match the local window size. This currently defaults to on, but note that +not all servers will support this. + =item -t TITLE, --title TITLE Set the window title to B diff --git a/man/virt-viewer.pod b/man/virt-viewer.pod index 9a88c92..f766c88 100644 --- a/man/virt-viewer.pod +++ b/man/virt-viewer.pod @@ -82,6 +82,12 @@ necessary. This is currently implemented by the Spice backend only. To specify which client monitors are used in fullscreen mode, see the CONFIGURATION section below. +=item -r <always|never>, --auto-resize <always|never> + +Controls whether it is permitted to attempt to resize the remote framebuffer +to match the local window size. This currently defaults to on, but note that +not all servers will support this. + =item -s, --shared Permitted a shared session with multiple clients diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c index 560d1f5..359616f 100644 --- a/src/virt-viewer-app.c +++ b/src/virt-viewer-app.c @@ -2127,6 +2127,7 @@ static gboolean opt_fullscreen = FALSE; static gboolean opt_kiosk = FALSE; static gboolean opt_kiosk_quit = FALSE; static gchar *opt_cursor = NULL; +static gchar *opt_resize = NULL; #ifndef G_OS_WIN32 static gboolean @@ -2561,6 +2562,24 @@ virt_viewer_app_local_command_line (GApplication *gapp, virt_viewer_app_set_cursor(self, cursor); } + if (opt_resize) { + GAction *resize = g_action_map_lookup_action(G_ACTION_MAP(self), + "auto-resize"); + gboolean enabled = TRUE; + if (g_str_equal(opt_resize, "always")) { + enabled = TRUE; + } else if (g_str_equal(opt_resize, "never")) { + enabled = FALSE; + } else { + g_printerr("--auto-resize expects 'always' or 'never'\n"); + *status = 1; + ret = TRUE; + goto end; + } + g_simple_action_set_state(G_SIMPLE_ACTION(resize), + g_variant_new_boolean(enabled)); + } + end: g_option_context_free(context); return ret; @@ -3445,6 +3464,8 @@ virt_viewer_app_add_option_entries(G_GNUC_UNUSED VirtViewerApp *self, N_("Open in full screen mode (adjusts guest resolution to fit the client)"), NULL }, { "hotkeys", 'H', 0, G_OPTION_ARG_STRING, &opt_hotkeys, N_("Customise hotkeys"), NULL }, + { "auto-resize", 'r', 0, G_OPTION_ARG_STRING, &opt_resize, + N_("Automatically resize remote framebuffer"), N_("<never|always>") }, { "keymap", 'K', 0, G_OPTION_ARG_STRING, &opt_keymap, N_("Remap keys format key=keymod+key e.g. F1=SHIFT+CTRL+F1,1=SHIFT+F1,ALT_L=Void"), NULL }, { "cursor", '\0', 0, G_OPTION_ARG_STRING, &opt_cursor,