[Spice-devel] [PATCH spice-gtk 1/2] Improve spice_main_set_display_enabled()

Hans de Goede hdegoede at redhat.com
Sun Mar 18 12:02:13 PDT 2012


Looks good, ack series.

On 03/18/2012 05:34 PM, Marc-André Lureau wrote:
> Check given display id is within the range of array.
> Allows to be call with -1 to turn set all displays.
> ---
>   gtk/channel-main.c |   13 +++++++++++--
>   1 files changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/gtk/channel-main.c b/gtk/channel-main.c
> index 50025b0..170610a 100644
> --- a/gtk/channel-main.c
> +++ b/gtk/channel-main.c
> @@ -1951,7 +1951,7 @@ void spice_main_clipboard_selection_request(SpiceMainChannel *channel, guint sel
>   /**
>    * spice_main_set_display_enabled:
>    * @channel: a #SpiceMainChannel
> - * @id: display channel ID
> + * @id: display channel ID (if -1: set all displays)
>    * @enabled: wether display @id is enabled
>    *
>    * When sending monitor configuration to agent guest, don't set
> @@ -1965,7 +1965,16 @@ void spice_main_set_display_enabled(SpiceMainChannel *channel, int id, gboolean
>   {
>       g_return_if_fail(channel != NULL);
>       g_return_if_fail(SPICE_IS_MAIN_CHANNEL(channel));
> +    g_return_if_fail(id>= -1);
>
>       SpiceMainChannelPrivate *c = channel->priv;
> -    c->display[id].enabled = enabled;
> +
> +    if (id == -1) {
> +        gint i;
> +        for (i = 0; i<  G_N_ELEMENTS(c->display); i++)
> +            c->display[i].enabled = enabled;
> +    } else {
> +        g_return_if_fail(id<  G_N_ELEMENTS(c->display));
> +        c->display[id].enabled = enabled;
> +    }
>   }


More information about the Spice-devel mailing list