[virt-tools-list] [PATCH virt-viewer 11/19] Add a DISABLED display hint

Christophe Fergeau cfergeau at redhat.com
Tue Jul 17 09:42:31 UTC 2012


On Mon, Jul 16, 2012 at 06:57:46PM +0200, Marc-André Lureau wrote:
> This flag will help to track wether the display has been

whether

> removed/closed and whether it have a really a valid display.

the part starting at "whether" needs fixing. "Whether it really has a valid
display" ?

> 
> Ready in contrast, is used to "hide" temporarily the display (when
> starting or redrawing the display, to avoid artifacts)
> ---
>  src/virt-viewer-app.c           |   15 +++++++++------
>  src/virt-viewer-display-spice.c |   20 ++++++++++++++++++++
>  src/virt-viewer-display.c       |   15 +++++++++++++++
>  src/virt-viewer-display.h       |    2 ++
>  src/virt-viewer-window.c        |   12 ++++++++++++
>  5 files changed, 58 insertions(+), 6 deletions(-)
> 
> diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
> index e5c674a..f581531 100644
> --- a/src/virt-viewer-app.c
> +++ b/src/virt-viewer-app.c
> @@ -611,7 +611,8 @@ display_show_hint(VirtViewerDisplay *display,
>  {
>      VirtViewerApp *self;
>      VirtViewerNotebook *nb = virt_viewer_window_get_notebook(win);
> -    gint nth, hint;
> +    gint nth;
> +    guint hint;

Doesn't this change belong to the patch turning 'hint' into a bitfield?

Patch looks good otherwise.

Christophe

>  
>      g_object_get(win,
>                   "app", &self,
> @@ -621,15 +622,17 @@ display_show_hint(VirtViewerDisplay *display,
>                   "show-hint", &hint,
>                   NULL);
>  
> -    if (hint == 0) {
> +    if (hint & VIRT_VIEWER_DISPLAY_SHOW_HINT_DISABLED) {
> +        virt_viewer_window_hide(win);
> +    } else if (hint & VIRT_VIEWER_DISPLAY_SHOW_HINT_READY) {
> +        virt_viewer_notebook_show_display(nb);
> +        virt_viewer_window_show(win);
> +        gtk_window_present(virt_viewer_window_get_window(win));
> +    } else {
>          if (win != self->priv->main_window &&
>              g_getenv("VIRT_VIEWER_HIDE"))
>              virt_viewer_window_hide(win);
>          virt_viewer_notebook_show_status(nb, _("Waiting for display %d..."), nth + 1);
> -    } else {
> -        virt_viewer_notebook_show_display(nb);
> -        virt_viewer_window_show(win);
> -        gtk_window_present(virt_viewer_window_get_window(win));
>      }
>  
>      g_object_unref(self);
> diff --git a/src/virt-viewer-display-spice.c b/src/virt-viewer-display-spice.c
> index 7bf9a9a..101abc5 100644
> --- a/src/virt-viewer-display-spice.c
> +++ b/src/virt-viewer-display-spice.c
> @@ -75,9 +75,26 @@ virt_viewer_display_spice_class_init(VirtViewerDisplaySpiceClass *klass)
>  }
>  
>  static void
> +show_hint_changed(VirtViewerDisplay *self)
> +{
> +    SpiceMainChannel *main_channel = virt_viewer_session_spice_get_main_channel(
> +        VIRT_VIEWER_SESSION_SPICE(virt_viewer_display_get_session(self)));
> +    guint enabled = TRUE;
> +    guint nth;
> +
> +    g_object_get(self, "nth-display", &nth, NULL);
> +    if (virt_viewer_display_get_show_hint(self) & VIRT_VIEWER_DISPLAY_SHOW_HINT_DISABLED)
> +        enabled = FALSE;
> +
> +    spice_main_set_display_enabled(main_channel, nth, enabled);
> +}
> +
> +static void
>  virt_viewer_display_spice_init(VirtViewerDisplaySpice *self G_GNUC_UNUSED)
>  {
>      self->priv = VIRT_VIEWER_DISPLAY_SPICE_GET_PRIVATE(self);
> +
> +    g_signal_connect(self, "notify::show-hint", G_CALLBACK(show_hint_changed), NULL);
>  }
>  
>  static void
> @@ -166,6 +183,9 @@ virt_viewer_display_spice_size_allocate(VirtViewerDisplaySpice *self,
>      if (virt_viewer_display_get_auto_resize(VIRT_VIEWER_DISPLAY(self)) == FALSE)
>          return;
>  
> +    if (virt_viewer_display_get_show_hint(VIRT_VIEWER_DISPLAY(self)) & VIRT_VIEWER_DISPLAY_SHOW_HINT_DISABLED)
> +        return;
> +
>      if (virt_viewer_display_get_zoom(VIRT_VIEWER_DISPLAY(self))) {
>          zoom = virt_viewer_display_get_zoom_level(VIRT_VIEWER_DISPLAY(self));
>  
> diff --git a/src/virt-viewer-display.c b/src/virt-viewer-display.c
> index a954671..18fed19 100644
> --- a/src/virt-viewer-display.c
> +++ b/src/virt-viewer-display.c
> @@ -553,6 +553,21 @@ void virt_viewer_display_set_show_hint(VirtViewerDisplay *self, guint hint)
>      g_object_notify(G_OBJECT(self), "show-hint");
>  }
>  
> +void virt_viewer_display_set_enabled(VirtViewerDisplay *self, gboolean enabled)
> +{
> +    guint hint;
> +
> +    g_return_if_fail(VIRT_VIEWER_IS_DISPLAY(self));
> +
> +    hint = virt_viewer_display_get_show_hint(self);
> +    if (enabled)
> +        hint &= ~VIRT_VIEWER_DISPLAY_SHOW_HINT_DISABLED;
> +    else
> +        hint |= VIRT_VIEWER_DISPLAY_SHOW_HINT_DISABLED;
> +
> +    virt_viewer_display_set_show_hint(self, hint);
> +}
> +
>  VirtViewerSession* virt_viewer_display_get_session(VirtViewerDisplay *self)
>  {
>      g_return_val_if_fail(VIRT_VIEWER_IS_DISPLAY(self), NULL);
> diff --git a/src/virt-viewer-display.h b/src/virt-viewer-display.h
> index 225080d..89b4817 100644
> --- a/src/virt-viewer-display.h
> +++ b/src/virt-viewer-display.h
> @@ -57,6 +57,7 @@ typedef struct _VirtViewerDisplayChannel VirtViewerDisplayChannel;
>  
>  typedef enum {
>      VIRT_VIEWER_DISPLAY_SHOW_HINT_READY            = 1 << 0,
> +    VIRT_VIEWER_DISPLAY_SHOW_HINT_DISABLED         = 1 << 1,
>  } VirtViewerDisplayShowHintFlags;
>  
>  /* perhaps this become an interface, and be pushed in gtkvnc and spice? */
> @@ -116,6 +117,7 @@ gboolean virt_viewer_display_get_auto_resize(VirtViewerDisplay *display);
>  void virt_viewer_display_release_cursor(VirtViewerDisplay *display);
>  
>  void virt_viewer_display_close(VirtViewerDisplay *display);
> +void virt_viewer_display_set_enabled(VirtViewerDisplay *display, gboolean enabled);
>  
>  G_END_DECLS
>  
> diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
> index 3f7cbbe..46e44be 100644
> --- a/src/virt-viewer-window.c
> +++ b/src/virt-viewer-window.c
> @@ -1062,6 +1062,9 @@ virt_viewer_window_show(VirtViewerWindow *self)
>  {
>      gtk_widget_show(self->priv->window);
>  
> +    if (self->priv->display)
> +        virt_viewer_display_set_enabled(self->priv->display, TRUE);
> +
>      if (self->priv->desktop_resize_pending) {
>          virt_viewer_window_resize(self);
>          self->priv->desktop_resize_pending = FALSE;
> @@ -1072,6 +1075,15 @@ void
>  virt_viewer_window_hide(VirtViewerWindow *self)
>  {
>      gtk_widget_hide(self->priv->window);
> +
> +    if (self->priv->display) {
> +        VirtViewerDisplay *display = self->priv->display;
> +        guint nth;
> +
> +        g_object_get(display, "nth-display", &nth, NULL);
> +        if (nth != 0)
> +            virt_viewer_display_set_enabled(display, FALSE);
> +    }
>  }
>  
>  void
> -- 
> 1.7.10.4
> 
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20120717/f8238115/attachment.sig>


More information about the virt-tools-list mailing list