[virt-tools-list] [PATCH virt-viewer v2] app: Compute monitor mapping only in fullscreen

Fabiano Fidêncio fabiano at fidencio.org
Mon Feb 15 10:59:06 UTC 2016


Pavel,

On Mon, Feb 15, 2016 at 11:53 AM, Pavel Grunt <pgrunt at redhat.com> wrote:
> ---
> v2: move monitor config setting from _set_uuid_string()
> ---
>  src/virt-viewer-app.c | 26 ++++++++++++++++++++------
>  1 file changed, 20 insertions(+), 6 deletions(-)
>
> diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
> index c49d3e8..55559d6 100644
> --- a/src/virt-viewer-app.c
> +++ b/src/virt-viewer-app.c
> @@ -473,15 +473,13 @@ virt_viewer_app_get_monitor_mapping_for_section(VirtViewerApp *self, const gchar
>  }
>
>  static
> -void virt_viewer_app_set_uuid_string(VirtViewerApp *self, const gchar *uuid_string)
> +void virt_viewer_app_apply_monitor_mapping(VirtViewerApp *self)
>  {
>      GHashTable *mapping = NULL;
>
> -    g_debug("%s: UUID changed to %s", G_STRFUNC, uuid_string);
> +    g_return_if_fail(virt_viewer_app_get_fullscreen(self));

I wouldn't go for g_return_ir_fail() here. I would just do a normal
check returning earlier in case of fail ...

>
> -    g_free(self->priv->uuid);
> -    self->priv->uuid = g_strdup(uuid_string);
> -    mapping = virt_viewer_app_get_monitor_mapping_for_section(self, uuid_string);
> +    mapping = virt_viewer_app_get_monitor_mapping_for_section(self, self->priv->uuid);
>      if (!mapping) {
>          g_debug("No guest-specific fullscreen config, using fallback");
>          mapping = virt_viewer_app_get_monitor_mapping_for_section(self, "fallback");
> @@ -494,7 +492,7 @@ void virt_viewer_app_set_uuid_string(VirtViewerApp *self, const gchar *uuid_stri
>
>      // if we're changing our initial display map, move any existing windows to
>      // the appropriate monitors according to the per-vm configuration
> -    if (mapping && self->priv->fullscreen) {
> +    if (mapping) {
>          GList *l;
>          gint i = 0;
>
> @@ -505,6 +503,22 @@ void virt_viewer_app_set_uuid_string(VirtViewerApp *self, const gchar *uuid_stri
>      }
>  }
>
> +static
> +void virt_viewer_app_set_uuid_string(VirtViewerApp *self, const gchar *uuid_string)
> +{
> +    if (g_strcmp0(self->priv->uuid, uuid_string) == 0)
> +        return;
> +
> +    g_debug("%s: UUID changed to %s", G_STRFUNC, uuid_string);
> +
> +    g_free(self->priv->uuid);
> +    self->priv->uuid = g_strdup(uuid_string);
> +
> +    // apply mapping only in fullscreen
> +    if (virt_viewer_app_get_fullscreen(self))
> +        virt_viewer_app_apply_monitor_mapping(self);

.. and then I wouldn't do the check here, just leaving all the needed
checks for the _apply_monitor_mapping() function.

> +}
> +
>  void
>  virt_viewer_app_maybe_quit(VirtViewerApp *self, VirtViewerWindow *window)
>  {
> --
> 2.5.0
>
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list


Reviewed-by: Fabiano Fidêncio <fidencio at redhat.com>

-- 
Fabiano Fidêncio




More information about the virt-tools-list mailing list