[mutter] clutter/stage: Add private method to get the stage-views of a rectangle



commit e27d2702a8aa446eb63ca29518564ebefad49f77
Author: Jonas Dreßler <verdre v0yd nl>
Date:   Fri Apr 10 00:39:07 2020 +0200

    clutter/stage: Add private method to get the stage-views of a rectangle
    
    We'll need this method for implementing a new stage-views-on API for
    ClutterActor which lists the stage views an actor is on.
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1196

 clutter/clutter/clutter-stage-private.h |  3 +++
 clutter/clutter/clutter-stage.c         | 24 ++++++++++++++++++++++++
 2 files changed, 27 insertions(+)
---
diff --git a/clutter/clutter/clutter-stage-private.h b/clutter/clutter/clutter-stage-private.h
index 9f018ab84d..ba4a77b733 100644
--- a/clutter/clutter/clutter-stage-private.h
+++ b/clutter/clutter/clutter-stage-private.h
@@ -136,6 +136,9 @@ void            _clutter_stage_presented                (ClutterStage      *stag
 void            clutter_stage_queue_actor_relayout      (ClutterStage *stage,
                                                          ClutterActor *actor);
 
+GList * clutter_stage_get_views_for_rect (ClutterStage          *stage,
+                                          const graphene_rect_t *rect);
+
 G_END_DECLS
 
 #endif /* __CLUTTER_STAGE_PRIVATE_H__ */
diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c
index 61737abd4b..fed84e9b00 100644
--- a/clutter/clutter/clutter-stage.c
+++ b/clutter/clutter/clutter-stage.c
@@ -4404,3 +4404,27 @@ _clutter_stage_get_max_view_scale_factor_for_rect (ClutterStage    *stage,
   *view_scale = scale;
   return TRUE;
 }
+
+GList *
+clutter_stage_get_views_for_rect (ClutterStage          *stage,
+                                  const graphene_rect_t *rect)
+{
+  ClutterStagePrivate *priv = stage->priv;
+  GList *views_for_rect = NULL;
+  GList *l;
+
+  for (l = _clutter_stage_window_get_views (priv->impl); l; l = l->next)
+    {
+      ClutterStageView *view = l->data;
+      cairo_rectangle_int_t view_layout;
+      graphene_rect_t view_rect;
+
+      clutter_stage_view_get_layout (view, &view_layout);
+      _clutter_util_rect_from_rectangle (&view_layout, &view_rect);
+
+      if (graphene_rect_intersection (&view_rect, rect, NULL))
+        views_for_rect = g_list_prepend (views_for_rect, view);
+    }
+
+  return views_for_rect;
+}


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