[mutter/wip/carlosg/input-thread: 39/90] backends: Add method to get extents from viewport info
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/input-thread: 39/90] backends: Add method to get extents from viewport info
- Date: Mon, 23 Nov 2020 16:22:02 +0000 (UTC)
commit f951ccbbf95646a65a51fb8fdc6b9f46e31cb0b8
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Jul 31 19:10:53 2020 +0200
backends: Add method to get extents from viewport info
This way we know the stage extents without poking the stage.
src/backends/meta-viewport-info.c | 23 +++++++++++++++++++++++
src/backends/meta-viewport-info.h | 4 ++++
2 files changed, 27 insertions(+)
---
diff --git a/src/backends/meta-viewport-info.c b/src/backends/meta-viewport-info.c
index 922475c994..a41d15ef26 100644
--- a/src/backends/meta-viewport-info.c
+++ b/src/backends/meta-viewport-info.c
@@ -187,3 +187,26 @@ meta_viewport_info_get_num_views (MetaViewportInfo *info)
{
return info->views->len;
}
+
+void
+meta_viewport_info_get_extents (MetaViewportInfo *viewport_info,
+ float *width,
+ float *height)
+{
+ int min_x = G_MAXINT, min_y = G_MAXINT, max_x = G_MININT, max_y = G_MININT, i;
+
+ for (i = 0; i < viewport_info->views->len; i++)
+ {
+ ViewInfo *info = &g_array_index (viewport_info->views, ViewInfo, i);
+
+ min_x = MIN (min_x, info->rect.x);
+ max_x = MAX (max_x, info->rect.x + info->rect.width);
+ min_y = MIN (min_y, info->rect.y);
+ max_y = MAX (max_y, info->rect.y + info->rect.height);
+ }
+
+ if (width)
+ *width = (float) max_x - min_x;
+ if (height)
+ *height = (float) max_y - min_y;
+}
diff --git a/src/backends/meta-viewport-info.h b/src/backends/meta-viewport-info.h
index 0701c432aa..ea9b8af80c 100644
--- a/src/backends/meta-viewport-info.h
+++ b/src/backends/meta-viewport-info.h
@@ -51,4 +51,8 @@ int meta_viewport_info_get_neighbor (MetaViewportInfo *info,
int meta_viewport_info_get_num_views (MetaViewportInfo *info);
+void meta_viewport_info_get_extents (MetaViewportInfo *info,
+ float *width,
+ float *height);
+
#endif /* META_VIEWPORT_INFO_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]