From 7ee60e114356d13a40370fb049a1805af0467ff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 28 Oct 2021 15:27:49 +0200 Subject: [PATCH] monitor: Don't only use 'winsys ID' to check sameness What determines whether one MetaMonitor is the same as the other should be whether the actual monitor is the same. The way to check this is comparing the EDID vendor/product/serial fields. Whene these are incomplete, fall back on the 'winsys ID'. Part-of: --- src/backends/meta-monitor.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/backends/meta-monitor.c b/src/backends/meta-monitor.c index 72e3c9e77..717cd8711 100644 --- a/src/backends/meta-monitor.c +++ b/src/backends/meta-monitor.c @@ -405,12 +405,33 @@ gboolean meta_monitor_is_same_as (MetaMonitor *monitor, MetaMonitor *other_monitor) { - MetaMonitorPrivate *priv = - meta_monitor_get_instance_private (monitor); - MetaMonitorPrivate *other_priv = - meta_monitor_get_instance_private (other_monitor); + const MetaMonitorSpec *spec = meta_monitor_get_spec (monitor); + const MetaMonitorSpec *other_spec = meta_monitor_get_spec (other_monitor); - return priv->winsys_id == other_priv->winsys_id; + if ((g_strcmp0 (spec->vendor, "unknown") == 0 || + g_strcmp0 (spec->product, "unknown") == 0 || + g_strcmp0 (spec->serial, "unknown") == 0) && + (g_strcmp0 (other_spec->vendor, "unknown") == 0 || + g_strcmp0 (other_spec->product, "unknown") == 0 || + g_strcmp0 (other_spec->serial, "unknown") == 0)) + { + MetaMonitorPrivate *priv = meta_monitor_get_instance_private (monitor); + MetaMonitorPrivate *other_priv = + meta_monitor_get_instance_private (other_monitor); + + return priv->winsys_id == other_priv->winsys_id; + } + + if (g_strcmp0 (spec->vendor, other_spec->vendor) != 0) + return FALSE; + + if (g_strcmp0 (spec->product, other_spec->product) != 0) + return FALSE; + + if (g_strcmp0 (spec->serial, other_spec->serial) != 0) + return FALSE; + + return TRUE; } void