[Spice-devel] [PATCH spice-gtk 3/4] main: add spice_main_update_display_enabled()

Jonathon Jongsma jjongsma at redhat.com
Fri Apr 3 08:20:45 PDT 2015


To me this feels like internal API. I can't think of any reason that an
application would call _update_display_enabled() with update==FALSE. Do
we need to expose this function publicly?

Also, typo in commit message: "sendi"


On Thu, 2015-04-02 at 23:25 +0200, Marc-André Lureau wrote:
> Allow to enable/disable a monitor without setting the timer to sendi the
> current configuration.
> ---
>  doc/reference/spice-gtk-sections.txt |  2 ++
>  gtk/channel-main.c                   | 33 +++++++++++++++++++++++++++++----
>  gtk/channel-main.h                   |  2 ++
>  gtk/map-file                         |  1 +
>  gtk/spice-glib-sym-file              |  1 +
>  5 files changed, 35 insertions(+), 4 deletions(-)
> 
> diff --git a/doc/reference/spice-gtk-sections.txt b/doc/reference/spice-gtk-sections.txt
> index 5d7b176..4733557 100644
> --- a/doc/reference/spice-gtk-sections.txt
> +++ b/doc/reference/spice-gtk-sections.txt
> @@ -63,6 +63,8 @@ SpiceMainChannelClass
>  <SUBSECTION>
>  spice_main_set_display
>  spice_main_set_display_enabled
> +spice_main_update_display
> +spice_main_update_display_enabled
>  spice_main_send_monitor_config
>  spice_main_agent_test_capability
>  spice_main_clipboard_selection_grab
> diff --git a/gtk/channel-main.c b/gtk/channel-main.c
> index c132ffa..33fca06 100644
> --- a/gtk/channel-main.c
> +++ b/gtk/channel-main.c
> @@ -2600,19 +2600,21 @@ 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 resolution 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.
>   *
> - * Since: 0.6
> + * Since: 0.29
>   **/
> -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)
>  {
>      g_return_if_fail(channel != NULL);
>      g_return_if_fail(SPICE_IS_MAIN_CHANNEL(channel));
> @@ -2634,7 +2636,30 @@ void spice_main_set_display_enabled(SpiceMainChannel *channel, int id, gboolean
>          c->display[id].enabled_set = TRUE;
>      }
>  
> -    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)
> +{
> +    g_return_if_fail(channel != NULL);
> +    g_return_if_fail(SPICE_IS_MAIN_CHANNEL(channel));
> +    g_return_if_fail(id >= -1);
> +
> +    spice_main_update_display_enabled(channel, id, enabled, TRUE);
>  }
>  
>  static void file_xfer_completed(SpiceFileXferTask *task, GError *error)
> diff --git a/gtk/channel-main.h b/gtk/channel-main.h
> index 3e4fc42..daee1ab 100644
> --- a/gtk/channel-main.h
> +++ b/gtk/channel-main.h
> @@ -72,6 +72,8 @@ 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/gtk/map-file b/gtk/map-file
> index d5a073f..a9abc61 100644
> --- a/gtk/map-file
> +++ b/gtk/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/gtk/spice-glib-sym-file b/gtk/spice-glib-sym-file
> index 3a8da93..1d62716 100644
> --- a/gtk/spice-glib-sym-file
> +++ b/gtk/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-devel mailing list