[mutter] monitor-manager: Expose a method to get a monitor from an output
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] monitor-manager: Expose a method to get a monitor from an output
- Date: Fri, 30 Jan 2015 18:14:09 +0000 (UTC)
commit 7f19db1f7b4b148e6771c97038cd55c8d43e043e
Author: Rui Matos <tiagomatos gmail com>
Date: Fri Jan 30 14:54:09 2015 +0100
monitor-manager: Expose a method to get a monitor from an output
This method will be used by gnome-shell to resolve an output ID
(exposed from the org.gnome.Mutter.DisplayConfig DBus API) to a
logical monitor.
https://bugzilla.gnome.org/show_bug.cgi?id=743745
src/backends/meta-monitor-manager.c | 30 ++++++++++++++++++++++++++++++
src/meta/meta-monitor-manager.h | 3 +++
2 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c
index d955af7..0276ba5 100644
--- a/src/backends/meta-monitor-manager.c
+++ b/src/backends/meta-monitor-manager.c
@@ -1338,3 +1338,33 @@ meta_monitor_manager_get_monitor_matrix (MetaMonitorManager *manager,
matrix);
return TRUE;
}
+
+/**
+ * meta_monitor_manager_get_output_geometry:
+ * @manager: A #MetaMonitorManager
+ * @id: A valid #MetaOutput id
+ *
+ * Returns: The monitor index or -1 if @id isn't valid or the output
+ * isn't associated with a logical monitor.
+ */
+gint
+meta_monitor_manager_get_monitor_for_output (MetaMonitorManager *manager,
+ guint id)
+{
+ MetaOutput *output;
+ guint i;
+
+ g_return_val_if_fail (META_IS_MONITOR_MANAGER (manager), -1);
+ g_return_val_if_fail (id < manager->n_outputs, -1);
+
+ output = &manager->outputs[id];
+ if (!output || !output->crtc)
+ return -1;
+
+ for (i = 0; i < manager->n_monitor_infos; i++)
+ if (meta_rectangle_contains_rect (&manager->monitor_infos[i].rect,
+ &output->crtc->rect))
+ return i;
+
+ return -1;
+}
diff --git a/src/meta/meta-monitor-manager.h b/src/meta/meta-monitor-manager.h
index 84f77fb..5a6604c 100644
--- a/src/meta/meta-monitor-manager.h
+++ b/src/meta/meta-monitor-manager.h
@@ -31,4 +31,7 @@ GType meta_monitor_manager_get_type (void);
MetaMonitorManager *meta_monitor_manager_get (void);
+gint meta_monitor_manager_get_monitor_for_output (MetaMonitorManager *manager,
+ guint id);
+
#endif /* META_MONITOR_MANAGER_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]