Skip to content

Commit cc584a7

Browse files
authored
Exposes monitor names (#706)
This exposes monitor names to gobject introspection via MetaDisplay.
1 parent 02fce99 commit cc584a7

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

src/core/display.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3718,6 +3718,50 @@ meta_display_get_primary_monitor (MetaDisplay *display)
37183718
return 0;
37193719
}
37203720

3721+
/**
3722+
* meta_display_get_monitor_name:
3723+
* @display: a #MetaDisplay
3724+
* @monitor: the monitor number
3725+
*
3726+
* Return value: (transfer none): the monitor vendor name
3727+
*/
3728+
const gchar*
3729+
meta_display_get_monitor_name (MetaDisplay *display,
3730+
int monitor)
3731+
{
3732+
MetaBackend *backend = meta_get_backend ();
3733+
MetaMonitorManager *monitor_manager =
3734+
meta_backend_get_monitor_manager (backend);
3735+
#ifndef G_DISABLE_CHECKS
3736+
int n_logical_monitors =
3737+
meta_monitor_manager_get_num_logical_monitors (monitor_manager);
3738+
#endif
3739+
3740+
g_return_val_if_fail (META_IS_DISPLAY (display), NULL);
3741+
g_return_val_if_fail (monitor >= 0 && monitor < n_logical_monitors, NULL);
3742+
3743+
GList *l;
3744+
3745+
for (l = monitor_manager->logical_monitors; l; l = l->next) {
3746+
MetaLogicalMonitor *other = l->data;
3747+
3748+
if (other->number != monitor) {
3749+
continue;
3750+
}
3751+
3752+
GList *m;
3753+
for (m = other->monitors; m; m = m->next)
3754+
{
3755+
MetaMonitor *monitor = m->data;
3756+
const char* name = meta_monitor_get_display_name (monitor);
3757+
if (name != NULL) {
3758+
return name;
3759+
}
3760+
}
3761+
}
3762+
return NULL;
3763+
}
3764+
37213765
/**
37223766
* meta_display_get_monitor_geometry:
37233767
* @display: a #MetaDisplay

src/meta/display.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ int meta_display_get_primary_monitor (MetaDisplay *display);
263263
META_EXPORT
264264
int meta_display_get_current_monitor (MetaDisplay *display);
265265

266+
META_EXPORT
267+
const gchar* meta_display_get_monitor_name (MetaDisplay *display,
268+
int monitor);
269+
266270
META_EXPORT
267271
void meta_display_get_monitor_geometry (MetaDisplay *display,
268272
int monitor,

0 commit comments

Comments
 (0)