[mutter] renderer: Add API to get a view list for a monitor
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] renderer: Add API to get a view list for a monitor
- Date: Thu, 2 Jul 2020 20:51:33 +0000 (UTC)
commit feb444402eb3e4e2ae6ed35015448ce17d534e8a
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Wed Apr 1 11:14:46 2020 +0200
renderer: Add API to get a view list for a monitor
Where renderer views correspond to CRTCs, this will result in a list of
those views; otherwise (i.e. X11 CM), it'll result in a list containing
the global view.
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
src/backends/meta-renderer.c | 70 ++++++++++++++++++++++++++++++
src/backends/meta-renderer.h | 5 +++
src/backends/x11/cm/meta-renderer-x11-cm.c | 9 ++++
3 files changed, 84 insertions(+)
---
diff --git a/src/backends/meta-renderer.c b/src/backends/meta-renderer.c
index e0107ec9d6..919354d44c 100644
--- a/src/backends/meta-renderer.c
+++ b/src/backends/meta-renderer.c
@@ -172,6 +172,75 @@ meta_renderer_real_rebuild_views (MetaRenderer *renderer)
}
}
+static MetaRendererView *
+meta_renderer_get_view_for_crtc (MetaRenderer *renderer,
+ MetaCrtc *crtc)
+{
+ MetaRendererPrivate *priv = meta_renderer_get_instance_private (renderer);
+ GList *l;
+
+ for (l = priv->views; l; l = l->next)
+ {
+ MetaRendererView *view = l->data;
+
+ if (meta_renderer_view_get_crtc (view) == crtc)
+ return view;
+ }
+
+ return NULL;
+}
+
+typedef struct _CollectViewsData
+{
+ MetaRenderer *renderer;
+ GList *out_views;
+} CollectViewsData;
+
+static gboolean
+collect_views (MetaMonitor *monitor,
+ MetaMonitorMode *mode,
+ MetaMonitorCrtcMode *monitor_crtc_mode,
+ gpointer user_data,
+ GError **error)
+{
+ CollectViewsData *data = user_data;
+ MetaCrtc *crtc;
+ MetaRendererView *view;
+
+ crtc = meta_output_get_assigned_crtc (monitor_crtc_mode->output);
+ view = meta_renderer_get_view_for_crtc (data->renderer, crtc);
+ if (!g_list_find (data->out_views, view))
+ data->out_views = g_list_prepend (data->out_views, view);
+
+ return TRUE;
+}
+
+static GList *
+meta_renderer_real_get_views_for_monitor (MetaRenderer *renderer,
+ MetaMonitor *monitor)
+{
+ CollectViewsData data = { 0 };
+ MetaMonitorMode *monitor_mode;
+
+ data.renderer = renderer;
+
+ monitor_mode = meta_monitor_get_current_mode (monitor);
+ meta_monitor_mode_foreach_crtc (monitor, monitor_mode,
+ collect_views,
+ &data,
+ NULL);
+
+ return data.out_views;
+}
+
+GList *
+meta_renderer_get_views_for_monitor (MetaRenderer *renderer,
+ MetaMonitor *monitor)
+{
+ return META_RENDERER_GET_CLASS (renderer)->get_views_for_monitor (renderer,
+ monitor);
+}
+
void
meta_renderer_add_view (MetaRenderer *renderer,
MetaRendererView *view)
@@ -278,6 +347,7 @@ meta_renderer_class_init (MetaRendererClass *klass)
object_class->finalize = meta_renderer_finalize;
klass->rebuild_views = meta_renderer_real_rebuild_views;
+ klass->get_views_for_monitor = meta_renderer_real_get_views_for_monitor;
obj_props[PROP_BACKEND] =
g_param_spec_object ("backend",
diff --git a/src/backends/meta-renderer.h b/src/backends/meta-renderer.h
index 247d2c2aae..278e645820 100644
--- a/src/backends/meta-renderer.h
+++ b/src/backends/meta-renderer.h
@@ -46,6 +46,8 @@ struct _MetaRendererClass
MetaOutput *output,
MetaCrtc *crtc);
void (* rebuild_views) (MetaRenderer *renderer);
+ GList * (* get_views_for_monitor) (MetaRenderer *renderer,
+ MetaMonitor *monitor);
};
MetaBackend * meta_renderer_get_backend (MetaRenderer *renderer);
@@ -57,6 +59,9 @@ void meta_renderer_rebuild_views (MetaRenderer *renderer);
void meta_renderer_add_view (MetaRenderer *renderer,
MetaRendererView *view);
+GList * meta_renderer_get_views_for_monitor (MetaRenderer *renderer,
+ MetaMonitor *monitor);
+
META_EXPORT_TEST
GList * meta_renderer_get_views (MetaRenderer *renderer);
diff --git a/src/backends/x11/cm/meta-renderer-x11-cm.c b/src/backends/x11/cm/meta-renderer-x11-cm.c
index a288fe61f6..18ad5eb5d1 100644
--- a/src/backends/x11/cm/meta-renderer-x11-cm.c
+++ b/src/backends/x11/cm/meta-renderer-x11-cm.c
@@ -94,6 +94,13 @@ meta_renderer_x11_cm_rebuild_views (MetaRenderer *renderer)
meta_renderer_add_view (renderer, renderer_x11_cm->screen_view);
}
+static GList *
+meta_renderer_x11_cm_get_views_for_monitor (MetaRenderer *renderer,
+ MetaMonitor *monitor)
+{
+ return g_list_prepend (NULL, meta_renderer_get_views (renderer)->data);
+}
+
static void
meta_renderer_x11_cm_init (MetaRendererX11Cm *renderer_x11_cm)
{
@@ -105,4 +112,6 @@ meta_renderer_x11_cm_class_init (MetaRendererX11CmClass *klass)
MetaRendererClass *renderer_class = META_RENDERER_CLASS (klass);
renderer_class->rebuild_views = meta_renderer_x11_cm_rebuild_views;
+ renderer_class->get_views_for_monitor =
+ meta_renderer_x11_cm_get_views_for_monitor;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]