Commit d5f13b5e authored by Alberts Muktupāvels's avatar Alberts Muktupāvels

logical-monitor: add helper for iterating over active CRTCs

Based on mutter commit:
mutter@903537a2
parent 3cba0d8a
......@@ -59,6 +59,11 @@ struct _GfLogicalMonitor
GList *monitors;
};
typedef void (* GfLogicalMonitorCrtcFunc) (GfLogicalMonitor *logical_monitor,
GfCrtc *crtc,
gpointer user_data);
GfLogicalMonitor *gf_logical_monitor_new (GfMonitorManager *monitor_manager,
GfLogicalMonitorConfig *logical_monitor_config,
gint monitor_number);
......@@ -88,6 +93,11 @@ gboolean gf_logical_monitor_has_neighbor (GfLogicalMonitor *mo
GfLogicalMonitor *neighbor,
GfDirection direction);
void gf_logical_monitor_foreach_crtc (GfLogicalMonitor *logical_monitor,
GfLogicalMonitorCrtcFunc func,
gpointer user_data);
G_END_DECLS
#endif
......@@ -32,8 +32,31 @@ typedef struct
GfLogicalMonitor *logical_monitor;
} AddMonitorFromConfigData;
typedef struct
{
GfLogicalMonitor *logical_monitor;
GfLogicalMonitorCrtcFunc func;
gpointer user_data;
} ForeachCrtcData;
G_DEFINE_TYPE (GfLogicalMonitor, gf_logical_monitor, G_TYPE_OBJECT)
static gboolean
foreach_crtc (GfMonitor *monitor,
GfMonitorMode *mode,
GfMonitorCrtcMode *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;
}
static void
add_monitor_from_config (GfMonitorConfig *monitor_config,
AddMonitorFromConfigData *data)
......@@ -268,3 +291,27 @@ gf_logical_monitor_has_neighbor (GfLogicalMonitor *monitor,
return FALSE;
}
void
gf_logical_monitor_foreach_crtc (GfLogicalMonitor *logical_monitor,
GfLogicalMonitorCrtcFunc func,
gpointer user_data)
{
GList *l;
for (l = logical_monitor->monitors; l; l = l->next)
{
GfMonitor *monitor;
GfMonitorMode *mode;
ForeachCrtcData data;
monitor = l->data;
mode = gf_monitor_get_current_mode (monitor);
data.logical_monitor = logical_monitor;
data.func = func;
data.user_data = user_data;
gf_monitor_mode_foreach_crtc (monitor, mode, foreach_crtc, &data, NULL);
}
}
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