[server] Introduce SurfaceInterface::boundingRect()

Summary:
The new method provides a convenient way for determining the rectangle
that bounds the given surface and all of its sub-surfaces. This can be
very handy when determining the effective window geometry.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: apol, kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D27828
This commit is contained in:
Vlad Zahorodnii 2020-02-21 12:16:38 +02:00
parent 9267f146fd
commit f073c773da
2 changed files with 21 additions and 0 deletions

View file

@ -772,6 +772,19 @@ QSize SurfaceInterface::size() const
return QSize();
}
QRect SurfaceInterface::boundingRect() const
{
QRect rect(QPoint(0, 0), size());
const QList<QPointer<SubSurfaceInterface>> 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();

View file

@ -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.