[virt-tools-list] [PATCH virt-viewer 2/3] virt_viewer_parse_monitor_mappings: Add parameter for client monitors

Fabiano Fidêncio fidencio at redhat.com
Tue Mar 8 12:00:40 UTC 2016


On Tue, Mar 8, 2016 at 9:20 AM, Pavel Grunt <pgrunt at redhat.com> wrote:
> Drop dependency on gdk. it allows to write tests not depending
> on the client's configuration.
> ---
>  src/virt-viewer-app.c  | 2 +-
>  src/virt-viewer-util.c | 4 ++--
>  src/virt-viewer-util.h | 3 ++-
>  3 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
> index c2e9bbe..6573961 100644
> --- a/src/virt-viewer-app.c
> +++ b/src/virt-viewer-app.c
> @@ -378,7 +378,7 @@ virt_viewer_app_get_monitor_mapping_for_section(VirtViewerApp *self, const gchar
>              g_warning("Error reading monitor assignments for %s: %s", section, error->message);
>          g_clear_error(&error);
>      } else {
> -        mapping = virt_viewer_parse_monitor_mappings(mappings, nmappings);
> +        mapping = virt_viewer_parse_monitor_mappings(mappings, nmappings, get_n_client_monitors());
>      }
>      g_strfreev(mappings);
>
> diff --git a/src/virt-viewer-util.c b/src/virt-viewer-util.c
> index 577d65b..fc2ace4 100644
> --- a/src/virt-viewer-util.c
> +++ b/src/virt-viewer-util.c
> @@ -605,6 +605,7 @@ virt_viewer_shift_monitors_to_origin(GHashTable *displays)
>   * virt_viewer_parse_monitor_mappings:
>   * @mappings: (array zero-terminated=1) values for the "monitor-mapping" key
>   * @nmappings: the size of @mappings
> + * @nmonitors: the count of client's monitors
>   *
>   * Parses and validates monitor mappings values to return a hash table
>   * containing the mapping from guest display ids to client monitors ids.
> @@ -613,9 +614,8 @@ virt_viewer_shift_monitors_to_origin(GHashTable *displays)
>   *  ids to client monitor ids or %NULL if the mapping is invalid.
>   */
>  GHashTable*
> -virt_viewer_parse_monitor_mappings(gchar **mappings, const gsize nmappings)
> +virt_viewer_parse_monitor_mappings(gchar **mappings, const gsize nmappings, const gint nmonitors)
>  {
> -    const gint nmonitors = gdk_screen_get_n_monitors(gdk_screen_get_default());
>      GHashTable *displaymap = g_hash_table_new(g_direct_hash, g_direct_equal);
>      GHashTable *monitormap = g_hash_table_new(g_direct_hash, g_direct_equal);
>      gint i, max_display_id = 0;
> diff --git a/src/virt-viewer-util.h b/src/virt-viewer-util.h
> index 249ace1..5515f66 100644
> --- a/src/virt-viewer-util.h
> +++ b/src/virt-viewer-util.h
> @@ -63,7 +63,8 @@ void virt_viewer_shift_monitors_to_origin(GHashTable *displays);
>
>  /* monitor mapping */
>  GHashTable* virt_viewer_parse_monitor_mappings(gchar **mappings,
> -                                               const gsize nmappings);
> +                                               const gsize nmappings,
> +                                               const gint nmonitors);
>  #endif
>
>  /*
> --
> 2.5.0
>
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list

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




More information about the virt-tools-list mailing list