Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exposes monitor names #706

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/core/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like if we were to set G_DISABLE_CHECKS the build would break (n_logical_monitors)... it's the same in surrounding methods.


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
Expand Down
4 changes: 4 additions & 0 deletions src/meta/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading