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
This commit is contained in:
Rui Matos 2015-01-30 14:54:09 +01:00 committed by Jasper St. Pierre
parent 3f2d658f20
commit 7f19db1f7b
2 changed files with 33 additions and 0 deletions

View File

@ -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;
}

View File

@ -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 */