[gtk-vnc] src: add APIs to control whether desktop resizing is allowed



commit 4821aeb05e1bb95bceaefbba630fdda9ca96b748
Author: Daniel P. Berrangé <dan berrange com>
Date:   Thu Dec 10 18:22:12 2020 +0000

    src: add APIs to control whether desktop resizing is allowed
    
    If desktop resizing is allowed, it will take priority over scaling when
    the server supports it.
    
    Signed-off-by: Daniel P. Berrangé <berrange redhat com>

 src/libgtk-vnc_sym.version |  3 +++
 src/vncdisplay.c           | 61 +++++++++++++++++++++++++++++++++++++++++++++-
 src/vncdisplay.h           |  3 +++
 3 files changed, 66 insertions(+), 1 deletion(-)
---
diff --git a/src/libgtk-vnc_sym.version b/src/libgtk-vnc_sym.version
index 8fa21b6..838b79c 100644
--- a/src/libgtk-vnc_sym.version
+++ b/src/libgtk-vnc_sym.version
@@ -57,6 +57,9 @@
     vnc_display_set_force_size;
     vnc_display_get_force_size;
 
+    vnc_display_set_allow_resize;
+    vnc_display_get_allow_resize;
+
     vnc_display_set_smoothing;
     vnc_display_get_smoothing;
 
diff --git a/src/vncdisplay.c b/src/vncdisplay.c
index d853d60..b30e12f 100644
--- a/src/vncdisplay.c
+++ b/src/vncdisplay.c
@@ -79,6 +79,7 @@ struct _VncDisplayPrivate
     gboolean allow_scaling;
     gboolean shared_flag;
     gboolean force_size;
+    gboolean allow_resize;
     gboolean smoothing;
 
     GSList *preferable_auths;
@@ -112,6 +113,7 @@ enum
     PROP_SCALING,
     PROP_SHARED_FLAG,
     PROP_FORCE_SIZE,
+    PROP_ALLOW_RESIZE,
     PROP_SMOOTHING,
     PROP_DEPTH,
     PROP_GRAB_KEYS,
@@ -212,6 +214,9 @@ vnc_display_get_property (GObject    *object,
         case PROP_FORCE_SIZE:
             g_value_set_boolean (value, vnc->priv->force_size);
             break;
+        case PROP_ALLOW_RESIZE:
+            g_value_set_boolean (value, vnc->priv->allow_resize);
+            break;
         case PROP_SMOOTHING:
             g_value_set_boolean (value, vnc->priv->smoothing);
             break;
@@ -264,6 +269,9 @@ vnc_display_set_property (GObject      *object,
         case PROP_FORCE_SIZE:
             vnc_display_set_force_size (vnc, g_value_get_boolean (value));
             break;
+        case PROP_ALLOW_RESIZE:
+            vnc_display_set_allow_resize (vnc, g_value_get_boolean (value));
+            break;
         case PROP_SMOOTHING:
             vnc_display_set_smoothing (vnc, g_value_get_boolean (value));
             break;
@@ -1222,7 +1230,7 @@ static void do_size_request(VncDisplay *obj)
         VNC_DEBUG("Setting size request %dx%d", width, height);
         gtk_widget_set_size_request(GTK_WIDGET(obj), width, height);
 
-        if (priv->allow_scaling) {
+        if (priv->allow_resize || priv->allow_scaling) {
             g_idle_add(do_size_request_clear, obj);
         }
     } else {
@@ -2292,6 +2300,17 @@ static void vnc_display_class_init(VncDisplayClass *klass)
                                                             G_PARAM_STATIC_NAME |
                                                             G_PARAM_STATIC_NICK |
                                                             G_PARAM_STATIC_BLURB));
+    g_object_class_install_property (object_class,
+                                     PROP_ALLOW_RESIZE,
+                                     g_param_spec_boolean ( "allow-resize",
+                                                            "Allow desktop resize",
+                                                            "Whether we should resize the desktop to match 
widget size",
+                                                            FALSE,
+                                                            G_PARAM_READWRITE |
+                                                            G_PARAM_CONSTRUCT |
+                                                            G_PARAM_STATIC_NAME |
+                                                            G_PARAM_STATIC_NICK |
+                                                            G_PARAM_STATIC_BLURB));
 
     g_object_class_install_property (object_class,
                                      PROP_SMOOTHING,
@@ -2571,6 +2590,7 @@ static void vnc_display_init(VncDisplay *display)
     priv->local_pointer = FALSE;
     priv->shared_flag = FALSE;
     priv->force_size = TRUE;
+    priv->allow_resize = FALSE;
     priv->smoothing = TRUE;
     priv->vncgrabseq = vnc_grab_sequence_new_from_string("Control_L+Alt_L");
     priv->vncactiveseq = g_new0(gboolean, priv->vncgrabseq->nkeysyms);
@@ -3028,6 +3048,28 @@ void vnc_display_set_force_size(VncDisplay *obj, gboolean enabled)
 }
 
 
+/**
+ * vnc_display_allow_resize:
+ * @obj: (transfer none): the VNC display widget
+ * @enabled: TRUE to allow the desktop resize, FALSE otherwise
+ *
+ * Set whether changes in the widget size will be translated
+ * into requests to resize the remote desktop. Resizing of
+ * the remote desktop is not guaranteed to be honoured by
+ * servers, but when it is, it will avoid the need todo
+ * scaling.
+ */
+void vnc_display_set_allow_resize(VncDisplay *obj, gboolean enabled)
+{
+    g_return_if_fail (VNC_IS_DISPLAY (obj));
+    obj->priv->allow_resize = enabled;
+
+    if (obj->priv->fb != NULL && enabled) {
+        do_size_request(obj);
+    }
+}
+
+
 /**
  * vnc_display_smoothing:
  * @obj: (transfer none): the VNC display widget
@@ -3113,6 +3155,23 @@ gboolean vnc_display_get_force_size(VncDisplay *obj)
 }
 
 
+/**
+ * vnc_display_get_allow_resize:
+ * @obj: (transfer none): the VNC display widget
+ *
+ * Determine whether widget size is used to request
+ * rsize of the remote desktop
+ *
+ * Returns: TRUE if allow resize is enabled, FALSE otherwise
+ */
+gboolean vnc_display_get_allow_resize(VncDisplay *obj)
+{
+    g_return_val_if_fail (VNC_IS_DISPLAY (obj), FALSE);
+
+    return obj->priv->allow_resize;
+}
+
+
 /**
  * vnc_display_get_smoothing:
  * @obj: (transfer none): the VNC display widget
diff --git a/src/vncdisplay.h b/src/vncdisplay.h
index 57a3f8f..4c398d1 100644
--- a/src/vncdisplay.h
+++ b/src/vncdisplay.h
@@ -134,6 +134,9 @@ gboolean vnc_display_get_scaling(VncDisplay *obj);
 void vnc_display_set_force_size(VncDisplay *obj, gboolean enable);
 gboolean vnc_display_get_force_size(VncDisplay *obj);
 
+void vnc_display_set_allow_resize(VncDisplay *obj, gboolean enable);
+gboolean vnc_display_get_allow_resize(VncDisplay *obj);
+
 void vnc_display_set_smoothing(VncDisplay *obj, gboolean enable);
 gboolean vnc_display_get_smoothing(VncDisplay *obj);
 


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