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.
This commit is contained in:
Pavel Grunt 2016-03-08 08:55:19 +01:00
parent e0c6718c3f
commit ab603d8e25
3 changed files with 5 additions and 4 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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
/*