src: add --auto-resize <always|never> CLI arg

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é <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2021-03-10 17:52:21 +00:00
parent 707f74b9c4
commit e9e2ebb796
3 changed files with 35 additions and 1 deletions

View File

@ -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 <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 -t TITLE, --title TITLE
Set the window title to B<TITLE>

View File

@ -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

View File

@ -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,