From 499739cee3601a6867747ffd3cc9680649fb0e6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Thu, 8 Apr 2021 12:48:57 +0100 Subject: [PATCH] details: enable resizing of displays with new GtkVnc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 1.2.0 release of GtkVnc introduces support for remote desktop resize. This is also supported in QEMU >= 6.0.0 when using virtio-gpu. This introduces support for resize without forcing a new min version of GtkVnc by just checking for existance of the new API. We don't attempt to check if the current QEMU instance supports resize, as we gracefully degrade - the guest simply won't resize and will be rendered as before. Reviewed-by: Cole Robinson Signed-off-by: Daniel P. Berrangé --- virtManager/details/console.py | 15 +++++++++------ virtManager/details/viewers.py | 5 ++++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/virtManager/details/console.py b/virtManager/details/console.py index 18f9ddd9..f00a7458 100644 --- a/virtManager/details/console.py +++ b/virtManager/details/console.py @@ -5,8 +5,11 @@ # This work is licensed under the GNU GPLv2 or later. # See the COPYING file in the top-level directory. +import gi +gi.require_version('GtkVnc', '2.0') from gi.repository import Gtk from gi.repository import Gdk +from gi.repository import GtkVnc from virtinst import log @@ -487,12 +490,12 @@ class vmmConsolePages(vmmGObjectUI): def _viewer_get_resizeguest_tooltip(self): tooltip = "" if self._viewer: - if self._viewer.viewer_type != "spice": - tooltip = ( - _("Graphics type '%s' does not support auto resize.") % - self._viewer.viewer_type) - elif not self._viewer.console_has_agent(): - tooltip = _("Guest agent is not available.") + if self._viewer.viewer_type == "spice": + if not self._viewer.console_has_agent(): + tooltip = _("Guest agent is not available.") + elif self._viewer.viewer_type == "vnc": + if not hasattr(GtkVnc.Display, "set_allow_resize"): + tooltip = _("GTK-VNC viewer is too old") return tooltip def _sync_resizeguest_with_display(self): diff --git a/virtManager/details/viewers.py b/virtManager/details/viewers.py index da9f906d..07082aa0 100644 --- a/virtManager/details/viewers.py +++ b/virtManager/details/viewers.py @@ -408,8 +408,11 @@ class VNCViewer(Viewer): self._display.set_credential(GtkVnc.DisplayCredential.PASSWORD, cred) def _set_resizeguest(self, val): - ignore = val + if hasattr(self._display, "set_allow_resize"): + self._display.set_allow_resize(val) # pylint: disable=no-member def _get_resizeguest(self): + if hasattr(self._display, "set_allow_resize"): + return self._display.get_allow_resize() # pylint: disable=no-member return False def _get_usb_widget(self):