[mutter] logical-monitor: Add helper for iterating over active CRTCs



commit 903537a2a0cb3ccf1f45dcdef4d9006fe191b51c
Author: Jonas Ådahl <jadahl gmail com>
Date:   Mon Mar 27 23:45:28 2017 +0800

    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

 src/backends/meta-logical-monitor.c |   45 +++++++++++++++++++++++++++++++++++
 src/backends/meta-logical-monitor.h |    8 ++++++
 2 files changed, 53 insertions(+), 0 deletions(-)
---
diff --git a/src/backends/meta-logical-monitor.c b/src/backends/meta-logical-monitor.c
index 2c11044..0b68868 100644
--- a/src/backends/meta-logical-monitor.c
+++ b/src/backends/meta-logical-monitor.c
@@ -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)
 {
diff --git a/src/backends/meta-logical-monitor.h b/src/backends/meta-logical-monitor.h
index 6068700..705ebfe 100644
--- a/src/backends/meta-logical-monitor.h
+++ b/src/backends/meta-logical-monitor.h
@@ -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 */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]