diff --git a/src/wayland/surface_interface.cpp b/src/wayland/surface_interface.cpp index 0690b19749..baa7c85441 100644 --- a/src/wayland/surface_interface.cpp +++ b/src/wayland/surface_interface.cpp @@ -772,6 +772,19 @@ QSize SurfaceInterface::size() const return QSize(); } +QRect SurfaceInterface::boundingRect() const +{ + QRect rect(QPoint(0, 0), size()); + + const QList> subSurfaces = childSubSurfaces(); + for (const SubSurfaceInterface *subSurface : subSurfaces) { + const SurfaceInterface *childSurface = subSurface->surface(); + rect |= childSurface->boundingRect().translated(subSurface->position()); + } + + return rect; +} + QPointer< ShadowInterface > SurfaceInterface::shadow() const { Q_D(); diff --git a/src/wayland/surface_interface.h b/src/wayland/surface_interface.h index 632bbc8a5c..fb61978fda 100644 --- a/src/wayland/surface_interface.h +++ b/src/wayland/surface_interface.h @@ -112,6 +112,14 @@ public: * @since 5.3 **/ QSize size() const; + /** + * Returns the rectangle that bounds this surface and all of its sub-surfaces. + * + * QPoint(0, 0) corresponds to the upper left corner of this surface. + * + * @since 5.69 + */ + QRect boundingRect() const; /** * @returns The SubSurface for this Surface in case there is one.