[Spice-commits] 2 commits - doc/reference src/channel-main.c src/channel-main.h src/map-file src/spice-glib-sym-file src/spice-widget.c

Jonathon Jongsma jjongsma at kemper.freedesktop.org
Thu Sep 10 13:53:03 PDT 2015


 doc/reference/spice-gtk-sections.txt |    1 
 src/channel-main.c                   |   40 ++++++++++++++++++++++++++++-------
 src/channel-main.h                   |    1 
 src/map-file                         |    1 
 src/spice-glib-sym-file              |    1 
 src/spice-widget.c                   |   38 +++++++++++++++++++++------------
 6 files changed, 60 insertions(+), 22 deletions(-)

New commits:
commit 7f46b1575f8659bbaf7502baa6cd2a0d33e203b4
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date:   Thu Aug 6 11:46:39 2015 -0500

    Don't send monitors config when Display widget is created
    
    When a display channel is associated with a particular SpiceDisplay
    widget, it previously set the display to 'enabled' unconditionally.
    There is a couple of problems with this behavior.
    
    First, simply because a display widget has an associated display
    channel, it doesn't necessarily mean that the display is enabled. On
    linux guests, for instance, a display channel can have up to 4 displays
    for one channel, and perhaps only one of them is enabled. So, we
    shouldn't set the display to 'enabled' until we actually receive a
    monitors configuration message indicating that this display is enabled.
    
    The second problem is that this was triggering the client to send down a
    new monitors-config message to the server. This message is completely
    unnecessary since it is triggered by a message from the server. We
    should only be sending down new monitor configurations in response to
    changes from the client, not from the server.

diff --git a/src/spice-widget.c b/src/spice-widget.c
index 3ec2e65..34bc128 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -219,6 +219,19 @@ static void update_keyboard_focus(SpiceDisplay *display, gboolean state)
     spice_gtk_session_request_auto_usbredir(d->gtk_session, state);
 }
 
+static gint get_display_id(SpiceDisplay *display)
+{
+    SpiceDisplayPrivate *d = display->priv;
+
+    /* supported monitor_id only with display channel #0 */
+    if (d->channel_id == 0 && d->monitor_id >= 0)
+        return d->monitor_id;
+
+    g_return_val_if_fail(d->monitor_id <= 0, -1);
+
+    return d->channel_id;
+}
+
 static void update_ready(SpiceDisplay *display)
 {
     SpiceDisplayPrivate *d = display->priv;
@@ -226,6 +239,16 @@ static void update_ready(SpiceDisplay *display)
 
     ready = d->mark != 0 && d->monitor_ready;
 
+    /* If the 'resize-guest' property is set, the application expects spice-gtk
+     * to manage the size and state of the displays, so update the 'enabled'
+     * state here. If 'resize-guest' is false, we can assume that the
+     * application will manage the state of the displays.
+     */
+    if (d->resize_guest_enable) {
+        spice_main_update_display_enabled(d->main, get_display_id(display),
+                                          ready, TRUE);
+    }
+
     if (d->ready == ready)
         return;
 
@@ -244,19 +267,6 @@ static void set_monitor_ready(SpiceDisplay *self, gboolean ready)
     update_ready(self);
 }
 
-static gint get_display_id(SpiceDisplay *display)
-{
-    SpiceDisplayPrivate *d = display->priv;
-
-    /* supported monitor_id only with display channel #0 */
-    if (d->channel_id == 0 && d->monitor_id >= 0)
-        return d->monitor_id;
-
-    g_return_val_if_fail(d->monitor_id <= 0, -1);
-
-    return d->channel_id;
-}
-
 static void update_monitor_area(SpiceDisplay *display)
 {
     SpiceDisplayPrivate *d = display->priv;
@@ -344,6 +354,7 @@ static void spice_display_set_property(GObject      *object,
         break;
     case PROP_RESIZE_GUEST:
         d->resize_guest_enable = g_value_get_boolean(value);
+        update_ready(display);
         update_size_request(display);
         break;
     case PROP_SCALING:
@@ -2439,7 +2450,6 @@ static void channel_new(SpiceSession *s, SpiceChannel *channel, gpointer data)
             mark(display, primary.marked);
         }
         spice_channel_connect(channel);
-        spice_main_set_display_enabled(d->main, get_display_id(display), TRUE);
         return;
     }
 
commit 94347e71d225408e5e21577770e6e5d2e78ca780
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date:   Thu Jul 16 14:01:06 2015 -0500

    Add spice_main_update_display_enabled()
    
    This is a new function that allows the caller to decide whether to send
    the new status down to the server or not (analogous to the difference
    between spice_main_set_display() vs spice_man_update_display()).
    
    This new function is needed to reduce unnecessary MonitorsConfig
    messages from being sent to the server. Because spice-gtk does not
    maintain any display state internally, it depends on the application to
    maintain that state. Some state changes come from the server itself
    (e.g. the guest has changed resolution due to some activity within the
    guest), and some come from the application (e.g. the user has resized
    the window of the client). Changes that come from server updates do not
    need to be sent back down to the server, whereas those that originate
    from the application *do* need to be sent to the server.

diff --git a/doc/reference/spice-gtk-sections.txt b/doc/reference/spice-gtk-sections.txt
index 5d7b176..2f3e09e 100644
--- a/doc/reference/spice-gtk-sections.txt
+++ b/doc/reference/spice-gtk-sections.txt
@@ -63,6 +63,7 @@ SpiceMainChannelClass
 <SUBSECTION>
 spice_main_set_display
 spice_main_set_display_enabled
+spice_main_update_display_enabled
 spice_main_send_monitor_config
 spice_main_agent_test_capability
 spice_main_clipboard_selection_grab
diff --git a/src/channel-main.c b/src/channel-main.c
index 42c9a65..03e407e 100644
--- a/src/channel-main.c
+++ b/src/channel-main.c
@@ -2788,19 +2788,24 @@ void spice_main_clipboard_selection_request(SpiceMainChannel *channel, guint sel
 }
 
 /**
- * spice_main_set_display_enabled:
+ * spice_main_update_display_enabled:
  * @channel: a #SpiceMainChannel
  * @id: display ID (if -1: set all displays)
  * @enabled: wether display @id is enabled
+ * @update: if %TRUE, update guest display state after 1sec.
  *
- * When sending monitor configuration to agent guest, don't set
- * display @id, which the agent translates to disabling the display
- * id. Note: this will take effect next time the monitor
- * configuration is sent.
+ * When sending monitor configuration to agent guest, if @enabled is %FALSE,
+ * don't set display @id, which the agent translates to disabling the display
+ * id. If @enabled is %TRUE, the monitor will be included in the next monitor
+ * update. Note: this will take effect next time the monitor configuration is
+ * sent.
  *
- * Since: 0.6
+ * If @update is %FALSE, no server update will be triggered by this call, but
+ * the value will be saved and used in the next configuration update.
+ *
+ * Since: 0.30
  **/
-void spice_main_set_display_enabled(SpiceMainChannel *channel, int id, gboolean enabled)
+void spice_main_update_display_enabled(SpiceMainChannel *channel, int id, gboolean enabled, gboolean update)
 {
     SpiceDisplayState display_state = enabled ? DISPLAY_ENABLED : DISPLAY_DISABLED;
     g_return_if_fail(channel != NULL);
@@ -2821,7 +2826,26 @@ void spice_main_set_display_enabled(SpiceMainChannel *channel, int id, gboolean
         c->display[id].display_state = display_state;
     }
 
-    update_display_timer(channel, 1);
+    if (update)
+        update_display_timer(channel, 1);
+}
+
+/**
+ * spice_main_set_display_enabled:
+ * @channel: a #SpiceMainChannel
+ * @id: display ID (if -1: set all displays)
+ * @enabled: wether display @id is enabled
+ *
+ * When sending monitor configuration to agent guest, don't set
+ * display @id, which the agent translates to disabling the display
+ * id. Note: this will take effect next time the monitor
+ * configuration is sent.
+ *
+ * Since: 0.6
+ **/
+void spice_main_set_display_enabled(SpiceMainChannel *channel, int id, gboolean enabled)
+{
+    spice_main_update_display_enabled(channel, id, enabled, TRUE);
 }
 
 static void file_xfer_completed(SpiceFileXferTask *task, GError *error)
diff --git a/src/channel-main.h b/src/channel-main.h
index 3e4fc42..86bb46b 100644
--- a/src/channel-main.h
+++ b/src/channel-main.h
@@ -72,6 +72,7 @@ void spice_main_set_display(SpiceMainChannel *channel, int id,
 void spice_main_update_display(SpiceMainChannel *channel, int id,
                                int x, int y, int width, int height, gboolean update);
 void spice_main_set_display_enabled(SpiceMainChannel *channel, int id, gboolean enabled);
+void spice_main_update_display_enabled(SpiceMainChannel *channel, int id, gboolean enabled, gboolean update);
 gboolean spice_main_send_monitor_config(SpiceMainChannel *channel);
 
 void spice_main_clipboard_selection_grab(SpiceMainChannel *channel, guint selection, guint32 *types, int ntypes);
diff --git a/src/map-file b/src/map-file
index d5a073f..a9abc61 100644
--- a/src/map-file
+++ b/src/map-file
@@ -71,6 +71,7 @@ spice_main_send_monitor_config;
 spice_main_set_display;
 spice_main_set_display_enabled;
 spice_main_update_display;
+spice_main_update_display_enabled;
 spice_playback_channel_get_type;
 spice_playback_channel_set_delay;
 spice_port_channel_get_type;
diff --git a/src/spice-glib-sym-file b/src/spice-glib-sym-file
index 3a8da93..1d62716 100644
--- a/src/spice-glib-sym-file
+++ b/src/spice-glib-sym-file
@@ -48,6 +48,7 @@ spice_main_send_monitor_config
 spice_main_set_display
 spice_main_set_display_enabled
 spice_main_update_display
+spice_main_update_display_enabled
 spice_playback_channel_get_type
 spice_playback_channel_set_delay
 spice_port_channel_get_type


More information about the Spice-commits mailing list