Commit 2b855f6b authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

Introduce SurfaceInterface::mapToChild()

The new method provides a convenient way to map a point from the
parent's coordinate system to a child's coordinate system.
parent 87fa37a1
......@@ -999,4 +999,26 @@ void SurfaceInterface::handleBufferRemoved(BufferInterface *buffer)
}
}
QPointF SurfaceInterface::mapToChild(SurfaceInterface *child, const QPointF &point) const
{
QPointF local = point;
SurfaceInterface *surface = child;
while (true) {
if (surface == this) {
return local;
}
SubSurfaceInterface *subsurface = surface->subSurface();
if (Q_UNLIKELY(!subsurface)) {
return QPointF();
}
local -= subsurface->position();
surface = subsurface->parentSurface();
}
return QPointF();
}
} // namespace KWaylandServer
......@@ -158,6 +158,14 @@ public:
*/
QMatrix4x4 surfaceToBufferMatrix() const;
/**
* Maps the specified @a point in this surface's coordinate system to the equivalent point
* within the @a child's coordinate system, and returns the mapped point.
*
* If this surface is not an ancestor of the @a child, a null point is returned.
*/
QPointF mapToChild(SurfaceInterface *child, const QPointF &point) const;
void frameRendered(quint32 msec);
bool hasFrameCallbacks() const;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment