From ab603d8e25ac83c805745f6ad5a90bd413cd09ac Mon Sep 17 00:00:00 2001 From: Pavel Grunt Date: Mar 08 2016 18:04:04 +0000 Subject: virt_viewer_parse_monitor_mappings: Add parameter for client monitors Drop dependency on gdk. it allows to write tests not depending on the client's configuration. --- 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 /*