monitor: Add flag whether EDID is sufficient to disambiguate monitors

If the EDID of the attached or stored monitor configurations contain
proper serial numbers, then we do not need to rely on the connector to
disambiguate them. Add a boolean to both MetaMonitorManager and
MetaMonitorsConfigKey to store this information.

https://gitlab.gnome.org/GNOME/mutter/issues/932
This commit is contained in:
Benjamin Berg 2019-12-20 14:17:46 +01:00
parent 0d27c7ee1d
commit d79fe1960b
5 changed files with 41 additions and 3 deletions

View File

@ -410,6 +410,25 @@ is_lid_closed (MetaMonitorManager *monitor_manager)
return meta_backend_is_lid_closed (backend);
}
gboolean
meta_config_key_edid_sufficient_for_specs (GList *monitor_specs)
{
GList *l;
for (l = monitor_specs; l && l->next; l = l->next)
{
MetaMonitorSpec *spec = l->data;
MetaMonitorSpec *spec_next = l->next->data;
if (meta_monitor_spec_equals (spec, spec_next, TRUE))
return FALSE;
/* XXX: Should we reject e.g. only 0 serial numbers? */
}
return TRUE;
}
MetaMonitorsConfigKey *
meta_create_monitors_config_key_for_current_state (MetaMonitorManager *monitor_manager)
{
@ -439,7 +458,8 @@ meta_create_monitors_config_key_for_current_state (MetaMonitorManager *monitor_m
config_key = g_new0 (MetaMonitorsConfigKey, 1);
*config_key = (MetaMonitorsConfigKey) {
.monitor_specs = monitor_specs
.monitor_specs = monitor_specs,
.edid_sufficient = meta_config_key_edid_sufficient_for_specs (monitor_specs)
};
return config_key;
@ -1356,7 +1376,8 @@ meta_monitors_config_key_new (GList *logical_monitor_configs,
config_key = g_new0 (MetaMonitorsConfigKey, 1);
*config_key = (MetaMonitorsConfigKey) {
.monitor_specs = monitor_specs
.monitor_specs = monitor_specs,
.edid_sufficient = meta_config_key_edid_sufficient_for_specs (monitor_specs)
};
return config_key;

View File

@ -48,7 +48,9 @@ typedef struct _MetaLogicalMonitorConfig
typedef struct _MetaMonitorsConfigKey
{
/* monitor_specs needs to be sorted using meta_monitor_spec_compare. */
GList *monitor_specs;
gboolean edid_sufficient;
} MetaMonitorsConfigKey;
typedef enum _MetaMonitorsConfigFlag
@ -159,6 +161,9 @@ META_EXPORT_TEST
gboolean meta_monitors_config_key_equal (gconstpointer config_key_a,
gconstpointer config_key_b);
META_EXPORT_TEST
gboolean meta_config_key_edid_sufficient_for_specs (GList *monitor_specs);
META_EXPORT_TEST
void meta_monitors_config_key_free (MetaMonitorsConfigKey *config_key);

View File

@ -122,6 +122,7 @@ struct _MetaMonitorManager
int screen_height;
GList *monitors;
gboolean edid_sufficient;
GList *logical_monitors;
MetaLogicalMonitor *primary_logical_monitor;

View File

@ -2621,6 +2621,7 @@ rebuild_monitors (MetaMonitorManager *manager)
{
GList *gpus;
GList *l;
GList *specs;
if (manager->monitors)
{
@ -2659,6 +2660,15 @@ rebuild_monitors (MetaMonitorManager *manager)
}
}
}
specs = NULL;
for (l = manager->monitors; l; l = l->next)
specs = g_list_prepend (specs, meta_monitor_get_spec (l->data));
specs = g_list_sort (specs,
(GCompareFunc) meta_monitor_spec_compare);
manager->edid_sufficient = meta_config_key_edid_sufficient_for_specs (specs);
g_list_free (specs);
}
void

View File

@ -108,7 +108,8 @@ create_config_key_from_expect (MonitorStoreTestConfiguration *expect_config)
config_key = g_new0 (MetaMonitorsConfigKey, 1);
*config_key = (MetaMonitorsConfigKey) {
.monitor_specs = monitor_specs
.monitor_specs = monitor_specs,
.edid_sufficient = meta_config_key_edid_sufficient_for_specs (monitor_specs)
};
return config_key;