It should not be prevented when the zoom level was not set before, otherwise it can avoid resizing the guest desktop. Related: rhbz#1221501 --- src/virt-viewer-display-spice.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/virt-viewer-display-spice.c b/src/virt-viewer-display-spice.c index 399c207..f16b8db 100644 --- a/src/virt-viewer-display-spice.c +++ b/src/virt-viewer-display-spice.c @@ -47,9 +47,11 @@ struct _VirtViewerDisplaySpicePrivate { AutoResizeState auto_resize; guint x; guint y; + guint previous_zoom; }; #define VIRT_VIEWER_DISPLAY_SPICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), VIRT_VIEWER_TYPE_DISPLAY_SPICE, VirtViewerDisplaySpicePrivate)) +#define ZOOM_NOT_SET 0 static void virt_viewer_display_spice_send_keys(VirtViewerDisplay *display, const guint *keyvals, @@ -174,14 +176,17 @@ virt_viewer_display_spice_mouse_grab(SpiceDisplay *display G_GNUC_UNUSED, static void virt_viewer_display_spice_size_allocate(VirtViewerDisplaySpice *self, - GtkAllocation *allocation, + GtkAllocation *allocation G_GNUC_UNUSED, gpointer data G_GNUC_UNUSED) { - GtkRequisition preferred; guint hint = virt_viewer_display_get_show_hint(VIRT_VIEWER_DISPLAY(self)); if (hint & VIRT_VIEWER_DISPLAY_SHOW_HINT_READY) { + guint actual_zoom = virt_viewer_display_get_zoom_level(VIRT_VIEWER_DISPLAY(self)); + gboolean zoom_changed = self->priv->previous_zoom != ZOOM_NOT_SET && + self->priv->previous_zoom != actual_zoom; + self->priv->previous_zoom = actual_zoom; /* ignore all allocations before the widget gets mapped to screen since we * only want to trigger guest resizing due to user actions */ @@ -193,9 +198,7 @@ virt_viewer_display_spice_size_allocate(VirtViewerDisplaySpice *self, * resizes the window to the size it already wants to be (based on desktop * size and zoom level), just return early */ - virt_viewer_display_get_preferred_size(VIRT_VIEWER_DISPLAY(self), &preferred); - if (preferred.width == allocation->width - && preferred.height == allocation->height) { + if (zoom_changed) { return; } } @@ -277,6 +280,7 @@ virt_viewer_display_spice_new(VirtViewerSessionSpice *session, "nth-display", channelid + monitorid, NULL); self->priv->channel = channel; + self->priv->previous_zoom = ZOOM_NOT_SET; g_object_get(session, "spice-session", &s, NULL); self->priv->display = spice_display_new_with_monitor(s, channelid, monitorid); -- 2.4.1 _______________________________________________ virt-tools-list mailing list virt-tools-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/virt-tools-list