[mutter] monitor: Add API to get monitor mode from spec
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] monitor: Add API to get monitor mode from spec
- Date: Wed, 25 Jan 2017 08:36:40 +0000 (UTC)
commit 4c1b48d0ccad527c067a2d4e3f3da6939ceca8d2
Author: Jonas Ådahl <jadahl gmail com>
Date: Wed Dec 21 13:03:35 2016 +0800
monitor: Add API to get monitor mode from spec
https://bugzilla.gnome.org/show_bug.cgi?id=777732
src/backends/meta-monitor.c | 29 +++++++++++++++++++++++++++++
src/backends/meta-monitor.h | 3 +++
2 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/src/backends/meta-monitor.c b/src/backends/meta-monitor.c
index 11c0faf..ed1f661 100644
--- a/src/backends/meta-monitor.c
+++ b/src/backends/meta-monitor.c
@@ -539,6 +539,35 @@ meta_monitor_get_spec (MetaMonitor *monitor)
return priv->spec;
}
+static gboolean
+meta_monitor_mode_spec_equals (MetaMonitorModeSpec *monitor_mode_spec,
+ MetaMonitorModeSpec *other_monitor_mode_spec)
+{
+ return (monitor_mode_spec->width == other_monitor_mode_spec->width &&
+ monitor_mode_spec->height == other_monitor_mode_spec->height &&
+ (monitor_mode_spec->refresh_rate ==
+ other_monitor_mode_spec->refresh_rate));
+}
+
+MetaMonitorMode *
+meta_monitor_get_mode_from_spec (MetaMonitor *monitor,
+ MetaMonitorModeSpec *monitor_mode_spec)
+{
+ MetaMonitorPrivate *priv = meta_monitor_get_instance_private (monitor);
+ GList *l;
+
+ for (l = priv->modes; l; l = l->next)
+ {
+ MetaMonitorMode *monitor_mode = l->data;
+
+ if (meta_monitor_mode_spec_equals (monitor_mode_spec,
+ &monitor_mode->spec))
+ return monitor_mode;
+ }
+
+ return NULL;
+}
+
MetaMonitorMode *
meta_monitor_get_preferred_mode (MetaMonitor *monitor)
{
diff --git a/src/backends/meta-monitor.h b/src/backends/meta-monitor.h
index f39b3f4..9c6211e 100644
--- a/src/backends/meta-monitor.h
+++ b/src/backends/meta-monitor.h
@@ -109,6 +109,9 @@ const char * meta_monitor_get_product (MetaMonitor *monitor);
uint32_t meta_monitor_tiled_get_tile_group_id (MetaMonitorTiled *monitor_tiled);
+MetaMonitorMode * meta_monitor_get_mode_from_spec (MetaMonitor *monitor,
+ MetaMonitorModeSpec *monitor_mode_spec);
+
MetaMonitorMode * meta_monitor_get_preferred_mode (MetaMonitor *monitor);
GList * meta_monitor_get_modes (MetaMonitor *monitor);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]