[Spice-devel] [PATCH spice-gtk] main: do not send monitors config if some are missing

Marc-André Lureau marcandre.lureau at gmail.com
Wed May 8 13:22:38 PDT 2013


Spice-gtk does a bit of client-side work by optionnally delaying sending
the monitor configuration to the guest automatically. However, the
client may be slow to set all the monitors, so teach the timer to not
fire the event unless at least the number of monitors set explicitely
enabled or disabled matches the number of display channels.

This avoid some configuration races when connecting to a multi-channel
display server which is slow to set up.
---
 gtk/channel-main.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/gtk/channel-main.c b/gtk/channel-main.c
index 623ff79..2e9fac7 100644
--- a/gtk/channel-main.c
+++ b/gtk/channel-main.c
@@ -96,6 +96,7 @@ struct _SpiceMainChannelPrivate  {
         int                     width;
         int                     height;
         gboolean                enabled;
+        gboolean                enabled_set;
     } display[MAX_DISPLAY];
     gint                        timer_id;
     GQueue                      *agent_msg_queue;
@@ -1327,10 +1328,24 @@ static gboolean timer_set_display(gpointer data)
 {
     SpiceMainChannel *channel = data;
     SpiceMainChannelPrivate *c = channel->priv;
+    SpiceSession *session;
+    gint i;
 
     c->timer_id = 0;
-    if (c->agent_connected)
-        spice_main_send_monitor_config(channel);
+    if (!c->agent_connected)
+        return FALSE;
+
+    session = spice_channel_get_session(SPICE_CHANNEL(channel));
+
+    /* ensure we have an explicit monitor configuration at least for
+       number of display channels */
+    for (i = 0; i < session->priv->display_channels_count; i++)
+        if (!c->display[i].enabled_set) {
+            SPICE_DEBUG("Not sending monitors config, missing monitors");
+            return FALSE;
+        }
+
+    spice_main_send_monitor_config(channel);
 
     return FALSE;
 }
@@ -2609,13 +2624,16 @@ void spice_main_set_display_enabled(SpiceMainChannel *channel, int id, gboolean
 
     if (id == -1) {
         gint i;
-        for (i = 0; i < G_N_ELEMENTS(c->display); i++)
+        for (i = 0; i < G_N_ELEMENTS(c->display); i++) {
             c->display[i].enabled = enabled;
+            c->display[i].enabled_set = TRUE;
+        }
     } else {
         g_return_if_fail(id < G_N_ELEMENTS(c->display));
         if (c->display[id].enabled == enabled)
             return;
         c->display[id].enabled = enabled;
+        c->display[id].enabled_set = TRUE;
     }
 
     update_display_timer(channel, 1);
-- 
1.8.2.1.342.gfa7285d



More information about the Spice-devel mailing list