[Spice-devel] [PATCH 2/4] Add spice_main_update_display_enabled()

Jonathon Jongsma jjongsma at redhat.com
Tue Aug 4 09:41:42 PDT 2015


On Thu, 2015-07-16 at 18:19 -0400, Marc-André Lureau wrote:
> Hi
> 
> ----- Original Message -----
> > This is a new function that allows the caller to decide whether to send
> > the new status down to the server or not (analogous to the difference
> > between spice_main_set_display() vs spice_man_update_display()).
> > 
> > This new function is needed to reduce unnecessary MonitorsConfig
> > messages from being sent to the server. Because spice-gtk does not
> > maintain any display state internally, it depends on the application to
> > maintain that state. Some state changes come from the server itself
> > (e.g. the guest has changed resolution due to some activity within the
> > guest), and some come from the application (e.g. the user has resized
> > the window of the client). Changes that come from server updates do not
> > need to be sent back down to the server, whereas those that originate
> > from the application *do* need to be sent to the server.
> > ---
> >  src/channel-main.c      | 40 ++++++++++++++++++++++++++++++++--------
> >  src/channel-main.h      |  1 +
> >  src/map-file            |  1 +
> >  src/spice-glib-sym-file |  1 +
> >  4 files changed, 35 insertions(+), 8 deletions(-)
> > 
> 
> Shouldn't it deprecate the old function?

It doesn't seem necessary to deprecate the old one. We didn't deprecate
spice_main_set_display() when we added spice_main_update_display()
(b44281a003640a650dc3d95466d62ec6f053c76e). I'm just following that same
approach.

On the other hand, it does increase the API, so I wouldn't be opposed to
deprecating both of those if people want to, I guess.


> 
> > diff --git a/src/channel-main.c b/src/channel-main.c
> > index 1b9c4d4..e4484e3 100644
> > --- a/src/channel-main.c
> > +++ b/src/channel-main.c
> > @@ -2756,19 +2756,24 @@ 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 display state 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.
> > + * When sending monitor configuration to agent guest, if @enabled is %FALSE,
> > + * don't set display @id, which the agent translates to disabling the
> > display
> > + * id. If @enabled is %TRUE, the monitor will be included in the next
> > monitor
> > + * update. Note: this will take effect next time the monitor configuration
> > is
> > + * sent.
> >   *
> > - * Since: 0.6
> > + * If @update is %FALSE, no server update will be triggered by this call,
> > but
> > + * the value will be saved and used in the next configuration update.
> > + *
> > + * Since: 0.30
> >   **/
> > -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)
> >  {
> >      SpiceDisplayState display_state = enabled ? DISPLAY_ENABLED :
> >      DISPLAY_DISABLED;
> >      g_return_if_fail(channel != NULL);
> > @@ -2789,7 +2794,26 @@ void spice_main_set_display_enabled(SpiceMainChannel
> > *channel, int id, gboolean
> >          c->display[id].display_state = display_state;
> >      }
> >  
> > -    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)
> > +{
> > +    spice_main_update_display_enabled(channel, id, enabled, TRUE);
> >  }
> >  
> >  static void file_xfer_completed(SpiceFileXferTask *task, GError *error)
> > diff --git a/src/channel-main.h b/src/channel-main.h
> > index 3e4fc42..86bb46b 100644
> > --- a/src/channel-main.h
> > +++ b/src/channel-main.h
> > @@ -72,6 +72,7 @@ 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/src/map-file b/src/map-file
> > index d5a073f..a9abc61 100644
> > --- a/src/map-file
> > +++ b/src/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/src/spice-glib-sym-file b/src/spice-glib-sym-file
> > index 3a8da93..1d62716 100644
> > --- a/src/spice-glib-sym-file
> > +++ b/src/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
> > --
> > 2.1.0
> > 
> > _______________________________________________
> > 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