[virt-tools-list] [PATCH virt-viewer 1/3] display: repurpose zoom property, rename it scale

Marc-André Lureau marcandre.lureau at gmail.com
Thu Feb 27 15:26:21 UTC 2014


Currently "dead" property zoom can be used instead to control display
scaling behaviour (in fact, it was probably meant to do that).
---
 src/virt-viewer-display.c | 41 +++++++++++++++++++++++++----------------
 src/virt-viewer-display.h |  4 ++--
 2 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/src/virt-viewer-display.c b/src/virt-viewer-display.c
index feefcca..3c893e2 100644
--- a/src/virt-viewer-display.c
+++ b/src/virt-viewer-display.c
@@ -42,7 +42,7 @@ struct _VirtViewerDisplayPrivate
     guint desktopWidth;
     guint desktopHeight;
     guint zoom_level;
-    gboolean zoom;
+    gboolean scale;
     gint nth_display; /* Monitor number inside the guest */
     gint monitor;     /* Monitor number on the client */
     guint show_hint;
@@ -84,7 +84,7 @@ enum {
     PROP_DESKTOP_HEIGHT,
     PROP_FULLSCREEN,
     PROP_NTH_DISPLAY,
-    PROP_ZOOM,
+    PROP_SCALE,
     PROP_ZOOM_LEVEL,
     PROP_SHOW_HINT,
     PROP_SESSION,
@@ -132,10 +132,10 @@ virt_viewer_display_class_init(VirtViewerDisplayClass *class)
                                                      G_PARAM_READWRITE));
 
     g_object_class_install_property(object_class,
-                                    PROP_ZOOM,
-                                    g_param_spec_boolean("zoom",
-                                                         "Zoom",
-                                                         "Zoom",
+                                    PROP_SCALE,
+                                    g_param_spec_boolean("scale",
+                                                         "Scale",
+                                                         "Scale",
                                                          TRUE,
                                                          G_PARAM_READWRITE));
 
@@ -279,7 +279,7 @@ virt_viewer_display_init(VirtViewerDisplay *display)
     display->priv->desktopWidth = 100;
     display->priv->desktopHeight = 100;
     display->priv->zoom_level = 100;
-    display->priv->zoom = TRUE;
+    display->priv->scale = TRUE;
     display->priv->auto_resize = TRUE;
 #if !GTK_CHECK_VERSION(3, 0, 0)
     display->priv->dirty = TRUE;
@@ -322,6 +322,10 @@ virt_viewer_display_set_property(GObject *object,
     case PROP_MONITOR:
         priv->monitor = g_value_get_int(value);
         break;
+    case PROP_SCALE:
+        virt_viewer_display_set_scale(display,
+                                      g_value_get_boolean(value));
+    break;
 
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -363,6 +367,9 @@ virt_viewer_display_get_property(GObject *object,
     case PROP_FULLSCREEN:
         g_value_set_boolean(value, virt_viewer_display_get_fullscreen(display));
         break;
+    case PROP_SCALE:
+        g_value_set_boolean(value, virt_viewer_display_get_scale(display));
+        break;
 
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -404,7 +411,7 @@ virt_viewer_display_size_request(GtkWidget *widget,
     requisition->height = border_width * 2;
 
     if (priv->dirty) {
-        if (priv->zoom) {
+        if (priv->scale) {
             requisition->width += round(priv->desktopWidth * priv->zoom_level / 100.0);
             requisition->height += round(priv->desktopHeight * priv->zoom_level / 100.0);
         } else {
@@ -456,7 +463,7 @@ static void virt_viewer_display_get_preferred_width(GtkWidget *widget,
 
     *minwidth = 50 + 2 * border_width;
 
-    if (priv->zoom) {
+    if (priv->scale) {
         *defwidth = round(priv->desktopWidth * priv->zoom_level / 100.0) +
                     2 * border_width;
     } else {
@@ -475,7 +482,7 @@ static void virt_viewer_display_get_preferred_height(GtkWidget *widget,
 
     *minheight = 50 + 2 * border_height;
 
-    if (priv->zoom) {
+    if (priv->scale) {
         *defheight = round(priv->desktopHeight * priv->zoom_level / 100.0) +
                     2 * border_height;
     } else {
@@ -609,20 +616,22 @@ guint virt_viewer_display_get_zoom_level(VirtViewerDisplay *display)
 }
 
 
-void virt_viewer_display_set_zoom(VirtViewerDisplay *display,
-                                  gboolean zoom)
+void virt_viewer_display_set_scale(VirtViewerDisplay *display,
+                                   gboolean scale)
 {
     VirtViewerDisplayPrivate *priv = display->priv;
 
-    priv->zoom = zoom;
+    priv->scale = scale;
+    g_object_notify(G_OBJECT(display), "scale");
+
     virt_viewer_display_queue_resize(display);
 }
 
 
-gboolean virt_viewer_display_get_zoom(VirtViewerDisplay *display)
+gboolean virt_viewer_display_get_scale(VirtViewerDisplay *display)
 {
     VirtViewerDisplayPrivate *priv = display->priv;
-    return priv->zoom;
+    return priv->scale;
 }
 
 
@@ -822,7 +831,7 @@ void virt_viewer_display_get_preferred_monitor_geometry(VirtViewerDisplay* self,
             preferred->y = topy;
         }
 
-        if (virt_viewer_display_get_zoom(VIRT_VIEWER_DISPLAY(self))) {
+        if (virt_viewer_display_get_scale(VIRT_VIEWER_DISPLAY(self))) {
             guint zoom = virt_viewer_display_get_zoom_level(VIRT_VIEWER_DISPLAY(self));
 
             preferred->width = round(preferred->width * 100 / zoom);
diff --git a/src/virt-viewer-display.h b/src/virt-viewer-display.h
index 195eeee..f3e4bdd 100644
--- a/src/virt-viewer-display.h
+++ b/src/virt-viewer-display.h
@@ -104,9 +104,9 @@ void virt_viewer_display_get_desktop_size(VirtViewerDisplay *display,
 void virt_viewer_display_set_zoom_level(VirtViewerDisplay *display,
                                         guint zoom);
 guint virt_viewer_display_get_zoom_level(VirtViewerDisplay *display);
-void virt_viewer_display_set_zoom(VirtViewerDisplay *display,
+void virt_viewer_display_set_scale(VirtViewerDisplay *display,
                                   gboolean zoom);
-gboolean virt_viewer_display_get_zoom(VirtViewerDisplay *display);
+gboolean virt_viewer_display_get_scale(VirtViewerDisplay *display);
 
 void virt_viewer_display_send_keys(VirtViewerDisplay *display,
                                    const guint *keyvals, int nkeyvals);
-- 
1.8.5.3




More information about the virt-tools-list mailing list