monitor: Only hash the connector when required

If the monitors in the configuration can already be uniquely identified
using the EDID information and connector type, then remove the connector
from the hash. This ensures that monitor configurations will land in the
same bucket if only the connectors are different.

Also add a quick return to the equal function by checking the
edid_sufficient boolean.

https://gitlab.gnome.org/GNOME/mutter/issues/932
This commit is contained in:
Benjamin Berg 2019-12-20 14:21:27 +01:00
parent d79fe1960b
commit 2f2efdefcf

View File

@ -1403,10 +1403,12 @@ meta_monitors_config_key_hash (gconstpointer data)
{
MetaMonitorSpec *monitor_spec = l->data;
hash ^= (g_str_hash (monitor_spec->connector) ^
g_str_hash (monitor_spec->vendor) ^
hash ^= (g_str_hash (monitor_spec->vendor) ^
g_str_hash (monitor_spec->product) ^
g_str_hash (monitor_spec->serial));
if (!config_key->edid_sufficient)
hash ^= g_str_hash (monitor_spec->connector);
}
return hash;
@ -1420,6 +1422,9 @@ meta_monitors_config_key_equal (gconstpointer data_a,
const MetaMonitorsConfigKey *config_key_b = data_b;
GList *l_a, *l_b;
if (config_key_a->edid_sufficient != config_key_b->edid_sufficient)
return FALSE;
for (l_a = config_key_a->monitor_specs, l_b = config_key_b->monitor_specs;
l_a && l_b;
l_a = l_a->next, l_b = l_b->next)