mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-22 13:34:07 +03:00
console: drop manual size request, let widgets do it for us
_adjust_viewer_size has one remaining function: when scaling and resizeguest is disabled, do viewer.set_size_request(*desktop_resolution), so the viewer fills out the scrolled window and scrollbars show up. After playing with this all a bunch, I discovered two things * spice already behaves the way we want, so we don't need to manually intervene. so all that is unnecessary * vnc has an option to behave the way we want, via the set_force_size knob So instead lets rip it all out, and implement the VNC piece by toggling set_force_size based on whether scaling+resizeguest is enabled. Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
1d7fcac3df
commit
2ee224193d
@ -466,38 +466,6 @@ class vmmConsolePages(vmmGObjectUI):
|
||||
# Resize and scaling APIs #
|
||||
###########################
|
||||
|
||||
def _adjust_viewer_size(self):
|
||||
if not self._viewer_is_visible():
|
||||
return
|
||||
|
||||
scroll = self.widget("console-gfx-scroll")
|
||||
is_scale = self._viewer.console_get_scaling()
|
||||
is_resizeguest = self._viewer.console_get_resizeguest()
|
||||
scale_factor = scroll.get_scale_factor()
|
||||
|
||||
# If scaling is enabled, we set the viewer widget to the same
|
||||
# size as the scrollwindow, and the viewer scales the VM to fit.
|
||||
#
|
||||
# If resizeguest is enabled, regardless of scaling, we need to
|
||||
# do the same as the scaling case, so the viewer knows the size
|
||||
# of the window. The viewer then sends that size to the guest,
|
||||
# and it (hopefully) changes VM resolution to match.
|
||||
#
|
||||
# When neither are enabled, we force the viewer widget to the size
|
||||
# of VM resolution, so scroll bars show up when the window is shrunk.
|
||||
#
|
||||
# ...except when scale_factor != 1. Any other scale_factor, and
|
||||
# gtk3 doesn't give us a reliable way to map VM resolution to
|
||||
# host widget pixel dimensions. This means our scroll window
|
||||
# effectively won't work when desktop scaling is enabled.
|
||||
if not is_scale and not is_resizeguest and scale_factor == 1:
|
||||
res = self._viewer.console_get_desktop_resolution() or (-1, -1)
|
||||
self._viewer.console_set_size_request(*res)
|
||||
return
|
||||
|
||||
# Reset any previous size_request
|
||||
self._viewer.console_set_size_request(-1, -1)
|
||||
|
||||
def _viewer_get_resizeguest_tooltip(self):
|
||||
tooltip = ""
|
||||
if self._viewer:
|
||||
@ -510,7 +478,6 @@ class vmmConsolePages(vmmGObjectUI):
|
||||
|
||||
val = bool(self.vm.get_console_resizeguest())
|
||||
self._viewer.console_set_resizeguest(val)
|
||||
self._adjust_viewer_size()
|
||||
|
||||
def _set_size_to_vm(self):
|
||||
# Resize the console to best fit the VM resolution
|
||||
@ -555,8 +522,6 @@ class vmmConsolePages(vmmGObjectUI):
|
||||
elif scale_type == self.config.CONSOLE_SCALE_FULLSCREEN:
|
||||
self._viewer.console_set_scaling(self._in_fullscreen)
|
||||
|
||||
self._adjust_viewer_size()
|
||||
|
||||
|
||||
###################
|
||||
# Fullscreen APIs #
|
||||
@ -763,12 +728,6 @@ class vmmConsolePages(vmmGObjectUI):
|
||||
self._pointer_is_grabbed = False
|
||||
self.emit("change-title")
|
||||
|
||||
def _viewer_size_allocate_cb(self, src, req):
|
||||
self._adjust_viewer_size()
|
||||
|
||||
def _viewer_desktop_resolution_changed_cb(self, src):
|
||||
self._adjust_viewer_size()
|
||||
|
||||
def _viewer_keyboard_grab_cb(self, src):
|
||||
self._viewer_sync_modifiers()
|
||||
|
||||
@ -856,9 +815,6 @@ class vmmConsolePages(vmmGObjectUI):
|
||||
self._viewer.connect("add-display-widget", self._viewer_add_display_cb)
|
||||
self._viewer.connect("pointer-grab", self._pointer_grabbed_cb)
|
||||
self._viewer.connect("pointer-ungrab", self._pointer_ungrabbed_cb)
|
||||
self._viewer.connect("size-allocate", self._viewer_size_allocate_cb)
|
||||
self._viewer.connect("desktop-resolution-changed",
|
||||
self._viewer_desktop_resolution_changed_cb)
|
||||
self._viewer.connect("keyboard-grab", self._viewer_keyboard_grab_cb)
|
||||
self._viewer.connect("keyboard-ungrab", self._viewer_keyboard_grab_cb)
|
||||
self._viewer.connect("connected", self._viewer_connected_cb)
|
||||
|
@ -128,8 +128,6 @@ class Viewer(vmmGObject):
|
||||
def _grab_focus(self):
|
||||
if self._display:
|
||||
self._display.grab_focus()
|
||||
def _set_size_request(self, *args, **kwargs):
|
||||
return self._display.set_size_request(*args, **kwargs)
|
||||
|
||||
def _get_pixbuf(self):
|
||||
return self._display.get_pixbuf()
|
||||
@ -268,8 +266,6 @@ class Viewer(vmmGObject):
|
||||
return self._grab_focus()
|
||||
def console_has_keyboard_grab(self):
|
||||
return bool(self._display and self._keyboard_grab)
|
||||
def console_set_size_request(self, *args, **kwargs):
|
||||
return self._set_size_request(*args, **kwargs)
|
||||
|
||||
def console_get_pixbuf(self):
|
||||
return self._get_pixbuf()
|
||||
@ -291,13 +287,9 @@ class Viewer(vmmGObject):
|
||||
def console_get_desktop_resolution(self):
|
||||
return self._get_desktop_resolution()
|
||||
|
||||
def console_get_scaling(self):
|
||||
return self._get_scaling()
|
||||
def console_set_scaling(self, val):
|
||||
return self._set_scaling(val)
|
||||
|
||||
def console_get_resizeguest(self):
|
||||
return self._get_resizeguest()
|
||||
def console_set_resizeguest(self, val):
|
||||
return self._set_resizeguest(val)
|
||||
def console_get_resizeguest_warning(self):
|
||||
@ -342,7 +334,6 @@ class VNCViewer(Viewer):
|
||||
def _init_display(self):
|
||||
display = GtkVnc.Display()
|
||||
|
||||
display.set_force_size(False)
|
||||
display.set_pointer_grab(True)
|
||||
|
||||
if _gtkvnc_check_display_support("set_keep_aspect_ratio"):
|
||||
@ -402,6 +393,10 @@ class VNCViewer(Viewer):
|
||||
if withUsername or withPassword:
|
||||
self.emit("need-auth", withPassword, withUsername)
|
||||
|
||||
def _sync_force_size(self):
|
||||
force_size = not self._get_scaling() and not self._get_resizeguest()
|
||||
self._display.set_force_size(force_size)
|
||||
|
||||
|
||||
###############################
|
||||
# Private API implementations #
|
||||
@ -418,7 +413,8 @@ class VNCViewer(Viewer):
|
||||
return self._display.get_scaling()
|
||||
def _set_scaling(self, scaling):
|
||||
if self._display:
|
||||
return self._display.set_scaling(scaling)
|
||||
self._display.set_scaling(scaling)
|
||||
self._sync_force_size()
|
||||
|
||||
def _set_grab_keys(self, keys):
|
||||
seq = GtkVnc.GrabSequence.new(keys)
|
||||
@ -435,6 +431,7 @@ class VNCViewer(Viewer):
|
||||
def _set_resizeguest(self, val):
|
||||
if _gtkvnc_supports_resizeguest():
|
||||
self._display.set_allow_resize(val) # pylint: disable=no-member
|
||||
self._sync_force_size()
|
||||
def _get_resizeguest(self):
|
||||
if _gtkvnc_supports_resizeguest():
|
||||
return self._display.get_allow_resize() # pylint: disable=no-member
|
||||
|
Loading…
Reference in New Issue
Block a user