monitor-config-manager: Prefer to use stored config

If not explicitly set by the backend, prefer to use the stored config
instead of creating a new one, if available.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
This commit is contained in:
Jonas Ådahl
2017-01-13 11:01:27 +08:00
parent 702facbc91
commit 9b4e1903e1
3 changed files with 81 additions and 0 deletions

View File

@ -353,6 +353,12 @@ meta_monitor_manager_has_hotplug_mode_update (MetaMonitorManager *manager)
return FALSE;
}
static gboolean
should_use_stored_config (MetaMonitorManager *manager)
{
return !meta_monitor_manager_has_hotplug_mode_update (manager);
}
static void
legacy_ensure_configured (MetaMonitorManager *manager)
{
@ -372,6 +378,27 @@ meta_monitor_manager_ensure_configured (MetaMonitorManager *manager)
return NULL;
}
if (should_use_stored_config (manager))
{
config = meta_monitor_config_manager_get_stored (manager->config_manager);
if (config)
{
if (!meta_monitor_manager_apply_monitors_config (manager, config,
&error))
{
config = NULL;
g_warning ("Failed to use stored monitor configuration: %s",
error->message);
g_clear_error (&error);
}
else
{
g_object_ref (config);
goto done;
}
}
}
config = meta_monitor_config_manager_create_suggested (manager->config_manager);
if (config)
{