From 4615da2122d9fcfa4bc87dee0994ec9213330486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 5 Feb 2021 17:21:55 +0100 Subject: [PATCH] monitor: Add hash function Will be used to keep a monitor spec as a hash table key. Part-of: --- src/backends/meta-monitor.c | 11 +++++++++++ src/backends/meta-monitor.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/src/backends/meta-monitor.c b/src/backends/meta-monitor.c index 2d9ec5051..54a228e83 100644 --- a/src/backends/meta-monitor.c +++ b/src/backends/meta-monitor.c @@ -127,6 +127,17 @@ meta_monitor_spec_clone (MetaMonitorSpec *monitor_spec) return new_monitor_spec; } +guint +meta_monitor_spec_hash (gconstpointer key) +{ + const MetaMonitorSpec *monitor_spec = key; + + return (g_str_hash (monitor_spec->connector) + + g_str_hash (monitor_spec->vendor) + + g_str_hash (monitor_spec->product) + + g_str_hash (monitor_spec->serial)); +} + gboolean meta_monitor_spec_equals (MetaMonitorSpec *monitor_spec, MetaMonitorSpec *other_monitor_spec) diff --git a/src/backends/meta-monitor.h b/src/backends/meta-monitor.h index c1b62806e..4b3a527e3 100644 --- a/src/backends/meta-monitor.h +++ b/src/backends/meta-monitor.h @@ -262,6 +262,8 @@ gboolean meta_monitor_mode_should_be_advertised (MetaMonitorMode *monitor_mode); META_EXPORT_TEST MetaMonitorSpec * meta_monitor_spec_clone (MetaMonitorSpec *monitor_id); +guint meta_monitor_spec_hash (gconstpointer key); + META_EXPORT_TEST gboolean meta_monitor_spec_equals (MetaMonitorSpec *monitor_id, MetaMonitorSpec *other_monitor_id);