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

Alon Levy alevy at redhat.com
Sun Mar 18 12:21:34 PDT 2012


On Sun, Mar 18, 2012 at 05:34:43PM +0100, 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.

ACK series.

> ---
>  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;
> +    }
>  }
> -- 
> 1.7.7.6
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel


More information about the Spice-devel mailing list