[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[virt-tools-list] [PATCH virt-viewer] Do not resize guest desktop if !auto-resize



If auto-resize is enabled, the guest desktop size will be resized to
match current window*zoom size.

This can be a problem if the user explicitely set the desktop size to
a different resolution and want to keep it. Disabling auto-resize
sounds like a simple way to allow that.
---
 src/virt-viewer-display-spice.c |    3 +++
 src/virt-viewer-display.c       |   16 ++++++++++++++++
 src/virt-viewer-display.h       |    3 ++-
 src/virt-viewer-window.c        |    3 +++
 4 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/src/virt-viewer-display-spice.c b/src/virt-viewer-display-spice.c
index 570cdd5..e4f41f9 100644
--- a/src/virt-viewer-display-spice.c
+++ b/src/virt-viewer-display-spice.c
@@ -160,6 +160,9 @@ virt_viewer_display_spice_size_allocate(VirtViewerDisplaySpice *self,
     guint zoom = 100;
     guint channelid;
 
+    if (virt_viewer_display_get_auto_resize(VIRT_VIEWER_DISPLAY(self)) == FALSE)
+        return;
+
     if (virt_viewer_display_get_zoom(VIRT_VIEWER_DISPLAY(self))) {
         zoom = virt_viewer_display_get_zoom_level(VIRT_VIEWER_DISPLAY(self));
 
diff --git a/src/virt-viewer-display.c b/src/virt-viewer-display.c
index a62c289..5b2cdc1 100644
--- a/src/virt-viewer-display.c
+++ b/src/virt-viewer-display.c
@@ -42,6 +42,7 @@ struct _VirtViewerDisplayPrivate
     gint nth_display;
     gint show_hint;
     VirtViewerSession *session;
+    gboolean auto_resize;
 };
 
 static void virt_viewer_display_size_request(GtkWidget *widget,
@@ -233,6 +234,7 @@ virt_viewer_display_init(VirtViewerDisplay *display)
     display->priv->zoom_level = 100;
     display->priv->zoom = TRUE;
     display->priv->dirty = TRUE;
+    display->priv->auto_resize = TRUE;
 }
 
 GtkWidget*
@@ -551,6 +553,20 @@ VirtViewerSession* virt_viewer_display_get_session(VirtViewerDisplay *self)
     return self->priv->session;
 }
 
+void virt_viewer_display_set_auto_resize(VirtViewerDisplay *self, gboolean auto_resize)
+{
+    g_return_if_fail(VIRT_VIEWER_IS_DISPLAY(self));
+
+    self->priv->auto_resize = auto_resize;
+}
+
+gboolean virt_viewer_display_get_auto_resize(VirtViewerDisplay *self)
+{
+    g_return_val_if_fail(VIRT_VIEWER_IS_DISPLAY(self), FALSE);
+
+    return self->priv->auto_resize;
+}
+
 /*
  * Local variables:
  *  c-indent-level: 4
diff --git a/src/virt-viewer-display.h b/src/virt-viewer-display.h
index b5a3266..17a3390 100644
--- a/src/virt-viewer-display.h
+++ b/src/virt-viewer-display.h
@@ -107,7 +107,8 @@ void virt_viewer_display_send_keys(VirtViewerDisplay *display,
 GdkPixbuf* virt_viewer_display_get_pixbuf(VirtViewerDisplay *display);
 void virt_viewer_display_set_show_hint(VirtViewerDisplay *display, gint hint);
 VirtViewerSession* virt_viewer_display_get_session(VirtViewerDisplay *display);
-
+void virt_viewer_display_set_auto_resize(VirtViewerDisplay *display, gboolean auto_resize);
+gboolean virt_viewer_display_get_auto_resize(VirtViewerDisplay *display);
 G_END_DECLS
 
 #endif /* _VIRT_VIEWER_DISPLAY_H */
diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index adb45fa..2adb666 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -681,6 +681,8 @@ virt_viewer_window_menu_view_resize(GtkWidget *menu,
     } else {
         priv->auto_resize = FALSE;
     }
+
+    virt_viewer_display_set_auto_resize(priv->display, priv->auto_resize);
 }
 
 static void
@@ -898,6 +900,7 @@ virt_viewer_window_set_display(VirtViewerWindow *self, VirtViewerDisplay *displa
         priv->display = g_object_ref(display);
 
         virt_viewer_display_set_zoom_level(VIRT_VIEWER_DISPLAY(priv->display), priv->zoomlevel);
+        virt_viewer_display_set_auto_resize(VIRT_VIEWER_DISPLAY(priv->display), priv->auto_resize);
 
         gtk_notebook_append_page(GTK_NOTEBOOK(priv->notebook), GTK_WIDGET(display), NULL);
         gtk_widget_show_all(GTK_WIDGET(display));
-- 
1.7.7.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]