diff --git a/src/core/display.c b/src/core/display.c index 8f3c5c3aa..d7f515273 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -3718,6 +3718,50 @@ meta_display_get_primary_monitor (MetaDisplay *display) return 0; } +/** + * meta_display_get_monitor_name: + * @display: a #MetaDisplay + * @monitor: the monitor number + * + * Return value: (transfer none): the monitor vendor name + */ +const gchar* +meta_display_get_monitor_name (MetaDisplay *display, + int monitor) +{ + MetaBackend *backend = meta_get_backend (); + MetaMonitorManager *monitor_manager = + meta_backend_get_monitor_manager (backend); + #ifndef G_DISABLE_CHECKS + int n_logical_monitors = + meta_monitor_manager_get_num_logical_monitors (monitor_manager); +#endif + + g_return_val_if_fail (META_IS_DISPLAY (display), NULL); + g_return_val_if_fail (monitor >= 0 && monitor < n_logical_monitors, NULL); + + GList *l; + + for (l = monitor_manager->logical_monitors; l; l = l->next) { + MetaLogicalMonitor *other = l->data; + + if (other->number != monitor) { + continue; + } + + GList *m; + for (m = other->monitors; m; m = m->next) + { + MetaMonitor *monitor = m->data; + const char* name = meta_monitor_get_display_name (monitor); + if (name != NULL) { + return name; + } + } + } + return NULL; +} + /** * meta_display_get_monitor_geometry: * @display: a #MetaDisplay diff --git a/src/meta/display.h b/src/meta/display.h index c18d3ec47..556240312 100644 --- a/src/meta/display.h +++ b/src/meta/display.h @@ -263,6 +263,10 @@ int meta_display_get_primary_monitor (MetaDisplay *display); META_EXPORT int meta_display_get_current_monitor (MetaDisplay *display); +META_EXPORT +const gchar* meta_display_get_monitor_name (MetaDisplay *display, + int monitor); + META_EXPORT void meta_display_get_monitor_geometry (MetaDisplay *display, int monitor,