From e27d2702a8aa446eb63ca29518564ebefad49f77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Fri, 10 Apr 2020 00:39:07 +0200 Subject: [PATCH] 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 9f018ab84..ba4a77b73 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 61737abd4..fed84e9b0 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; +}