summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2013-05-08 22:18:43 +0200
committerMarc-André Lureau <marcandre.lureau@redhat.com>2013-05-11 21:18:31 +0200
commit51d57cecde47b0b4f074654931ddaf4e0d1bef90 (patch)
tree9ba890d2c286e2218540c18a5b5e5acda42833cd
parent68c4dbe04ce2420ea1433647f07ecc5d3413ffcf (diff)
main: do not send monitors config if some are missing
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.
-rw-r--r--gtk/channel-main.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/gtk/channel-main.c b/gtk/channel-main.c
index 8e79bbd..b58af52 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;
@@ -1325,10 +1326,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;
}
@@ -2606,13 +2621,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);