mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 10:00:45 -05:00
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:
parent
702facbc91
commit
9b4e1903e1
@ -299,6 +299,58 @@ meta_monitor_config_manager_assign (MetaMonitorManager *manager,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static MetaMonitorsConfigKey *
|
||||||
|
create_key_for_current_state (MetaMonitorManager *monitor_manager)
|
||||||
|
{
|
||||||
|
MetaMonitorsConfigKey *config_key;
|
||||||
|
GList *l;
|
||||||
|
GList *monitor_specs;
|
||||||
|
|
||||||
|
monitor_specs = NULL;
|
||||||
|
for (l = monitor_manager->monitors; l; l = l->next)
|
||||||
|
{
|
||||||
|
MetaMonitor *monitor = l->data;
|
||||||
|
MetaMonitorSpec *monitor_spec;
|
||||||
|
|
||||||
|
if (meta_monitor_is_laptop_panel (monitor) &&
|
||||||
|
meta_monitor_manager_is_lid_closed (monitor_manager))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
monitor_spec = meta_monitor_spec_clone (meta_monitor_get_spec (monitor));
|
||||||
|
monitor_specs = g_list_prepend (monitor_specs, monitor_spec);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!monitor_specs)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
monitor_specs = g_list_sort (monitor_specs,
|
||||||
|
(GCompareFunc) meta_monitor_spec_compare);
|
||||||
|
|
||||||
|
config_key = g_new0 (MetaMonitorsConfigKey, 1);
|
||||||
|
*config_key = (MetaMonitorsConfigKey) {
|
||||||
|
.monitor_specs = monitor_specs
|
||||||
|
};
|
||||||
|
|
||||||
|
return config_key;
|
||||||
|
}
|
||||||
|
|
||||||
|
MetaMonitorsConfig *
|
||||||
|
meta_monitor_config_manager_get_stored (MetaMonitorConfigManager *config_manager)
|
||||||
|
{
|
||||||
|
MetaMonitorsConfigKey *config_key;
|
||||||
|
MetaMonitorsConfig *config;
|
||||||
|
|
||||||
|
config_key = create_key_for_current_state (config_manager->monitor_manager);
|
||||||
|
if (!config_key)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
config = meta_monitor_config_store_lookup (config_manager->config_store,
|
||||||
|
config_key);
|
||||||
|
meta_monitors_config_key_free (config_key);
|
||||||
|
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
typedef enum _MonitorMatchRule
|
typedef enum _MonitorMatchRule
|
||||||
{
|
{
|
||||||
MONITOR_MATCH_ALL = 0,
|
MONITOR_MATCH_ALL = 0,
|
||||||
|
@ -70,6 +70,8 @@ gboolean meta_monitor_config_manager_assign (MetaMonitorManager *manager,
|
|||||||
GPtrArray **output_infos,
|
GPtrArray **output_infos,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
MetaMonitorsConfig * meta_monitor_config_manager_get_stored (MetaMonitorConfigManager *config_manager);
|
||||||
|
|
||||||
MetaMonitorsConfig * meta_monitor_config_manager_create_linear (MetaMonitorConfigManager *config_manager);
|
MetaMonitorsConfig * meta_monitor_config_manager_create_linear (MetaMonitorConfigManager *config_manager);
|
||||||
|
|
||||||
MetaMonitorsConfig * meta_monitor_config_manager_create_fallback (MetaMonitorConfigManager *config_manager);
|
MetaMonitorsConfig * meta_monitor_config_manager_create_fallback (MetaMonitorConfigManager *config_manager);
|
||||||
|
@ -353,6 +353,12 @@ meta_monitor_manager_has_hotplug_mode_update (MetaMonitorManager *manager)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
should_use_stored_config (MetaMonitorManager *manager)
|
||||||
|
{
|
||||||
|
return !meta_monitor_manager_has_hotplug_mode_update (manager);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
legacy_ensure_configured (MetaMonitorManager *manager)
|
legacy_ensure_configured (MetaMonitorManager *manager)
|
||||||
{
|
{
|
||||||
@ -372,6 +378,27 @@ meta_monitor_manager_ensure_configured (MetaMonitorManager *manager)
|
|||||||
return NULL;
|
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);
|
config = meta_monitor_config_manager_create_suggested (manager->config_manager);
|
||||||
if (config)
|
if (config)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user