[gnome-flashback] monitor-spec: add hash function
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback] monitor-spec: add hash function
- Date: Sat, 23 Oct 2021 18:48:44 +0000 (UTC)
commit ca854a80b60df04ce84b3dde7a5d481faad2beb1
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Sun Sep 12 23:23:27 2021 +0300
monitor-spec: add hash function
Based on mutter commit:
https://gitlab.gnome.org/GNOME/mutter/-/commit/4615da2122d9
backends/gf-monitor-spec-private.h | 2 ++
backends/gf-monitor-spec.c | 11 +++++++++++
2 files changed, 13 insertions(+)
---
diff --git a/backends/gf-monitor-spec-private.h b/backends/gf-monitor-spec-private.h
index 7dd1dd4..2c3bd70 100644
--- a/backends/gf-monitor-spec-private.h
+++ b/backends/gf-monitor-spec-private.h
@@ -36,6 +36,8 @@ struct _GfMonitorSpec
GfMonitorSpec *gf_monitor_spec_clone (GfMonitorSpec *spec);
+guint gf_monitor_spec_hash (gconstpointer key);
+
gboolean gf_monitor_spec_equals (GfMonitorSpec *spec,
GfMonitorSpec *other_spec);
diff --git a/backends/gf-monitor-spec.c b/backends/gf-monitor-spec.c
index 41e3f51..67e8d1d 100644
--- a/backends/gf-monitor-spec.c
+++ b/backends/gf-monitor-spec.c
@@ -41,6 +41,17 @@ gf_monitor_spec_clone (GfMonitorSpec *spec)
return new_spec;
}
+guint
+gf_monitor_spec_hash (gconstpointer key)
+{
+ const GfMonitorSpec *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
gf_monitor_spec_equals (GfMonitorSpec *spec,
GfMonitorSpec *other_spec)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]