Commit 903537a2 authored by Jonas Ådahl's avatar Jonas Ådahl

logical-monitor: Add helper for iterating over active CRTCs

Add meta_logical_monitor_foreach_crtc() helper to iterate over all the
active CRTCs driving the monitors associated with the specified logical
monitor.

https://bugzilla.gnome.org/show_bug.cgi?id=785381
parent 1db93782
......@@ -201,6 +201,51 @@ meta_logical_monitor_get_monitors (MetaLogicalMonitor *logical_monitor)
return logical_monitor->monitors;
}
typedef struct _ForeachCrtcData
{
MetaLogicalMonitor *logical_monitor;
MetaLogicalMonitorCrtcFunc func;
gpointer user_data;
} ForeachCrtcData;
static gboolean
foreach_crtc (MetaMonitor *monitor,
MetaMonitorMode *mode,
MetaMonitorCrtcMode *monitor_crtc_mode,
gpointer user_data,
GError **error)
{
ForeachCrtcData *data = user_data;
data->func (data->logical_monitor,
monitor_crtc_mode->output->crtc,
data->user_data);
return TRUE;
}
void
meta_logical_monitor_foreach_crtc (MetaLogicalMonitor *logical_monitor,
MetaLogicalMonitorCrtcFunc func,
gpointer user_data)
{
GList *l;
for (l = logical_monitor->monitors; l; l = l->next)
{
MetaMonitor *monitor = l->data;
MetaMonitorMode *mode;
ForeachCrtcData data = {
.logical_monitor = logical_monitor,
.func = func,
.user_data = user_data
};
mode = meta_monitor_get_current_mode (monitor);
meta_monitor_mode_foreach_crtc (monitor, mode, foreach_crtc, &data, NULL);
}
}
static void
meta_logical_monitor_init (MetaLogicalMonitor *logical_monitor)
{
......
......@@ -61,6 +61,10 @@ G_DECLARE_FINAL_TYPE (MetaLogicalMonitor, meta_logical_monitor,
META, LOGICAL_MONITOR,
GObject)
typedef void (* MetaLogicalMonitorCrtcFunc) (MetaLogicalMonitor *logical_monitor,
MetaCrtc *crtc,
gpointer user_data);
MetaLogicalMonitor * meta_logical_monitor_new (MetaMonitorManager *monitor_manager,
MetaLogicalMonitorConfig *logical_monitor_config,
int monitor_number);
......@@ -90,4 +94,8 @@ gboolean meta_logical_monitor_has_neighbor (MetaLogicalMonitor *logical_monitor
MetaLogicalMonitor *neighbor,
MetaScreenDirection neighbor_dir);
void meta_logical_monitor_foreach_crtc (MetaLogicalMonitor *logical_monitor,
MetaLogicalMonitorCrtcFunc func,
gpointer user_data);
#endif /* META_LOGICAL_MONITOR_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment