diff options
Diffstat (limited to 'src/compositor/compositor_api/qwaylandquickitem.cpp')
-rw-r--r-- | src/compositor/compositor_api/qwaylandquickitem.cpp | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp index 77a9247a9..f848a0169 100644 --- a/src/compositor/compositor_api/qwaylandquickitem.cpp +++ b/src/compositor/compositor_api/qwaylandquickitem.cpp @@ -64,7 +64,7 @@ #include <QtCore/QMutexLocker> #include <QtCore/QMutex> -#include <wayland-server.h> +#include <wayland-server-core.h> #include <QThread> #ifndef GL_TEXTURE_EXTERNAL_OES @@ -886,7 +886,7 @@ void QWaylandQuickItem::handleSurfaceChanged() if (d->oldSurface) { disconnect(d->oldSurface.data(), &QWaylandSurface::hasContentChanged, this, &QWaylandQuickItem::surfaceMappedChanged); disconnect(d->oldSurface.data(), &QWaylandSurface::parentChanged, this, &QWaylandQuickItem::parentChanged); - disconnect(d->oldSurface.data(), &QWaylandSurface::sizeChanged, this, &QWaylandQuickItem::updateSize); + disconnect(d->oldSurface.data(), &QWaylandSurface::destinationSizeChanged, this, &QWaylandQuickItem::updateSize); disconnect(d->oldSurface.data(), &QWaylandSurface::bufferScaleChanged, this, &QWaylandQuickItem::updateSize); disconnect(d->oldSurface.data(), &QWaylandSurface::configure, this, &QWaylandQuickItem::updateBuffer); disconnect(d->oldSurface.data(), &QWaylandSurface::redraw, this, &QQuickItem::update); @@ -903,7 +903,7 @@ void QWaylandQuickItem::handleSurfaceChanged() if (QWaylandSurface *newSurface = d->view->surface()) { connect(newSurface, &QWaylandSurface::hasContentChanged, this, &QWaylandQuickItem::surfaceMappedChanged); connect(newSurface, &QWaylandSurface::parentChanged, this, &QWaylandQuickItem::parentChanged); - connect(newSurface, &QWaylandSurface::sizeChanged, this, &QWaylandQuickItem::updateSize); + connect(newSurface, &QWaylandSurface::destinationSizeChanged, this, &QWaylandQuickItem::updateSize); connect(newSurface, &QWaylandSurface::bufferScaleChanged, this, &QWaylandQuickItem::updateSize); connect(newSurface, &QWaylandSurface::configure, this, &QWaylandQuickItem::updateBuffer); connect(newSurface, &QWaylandSurface::redraw, this, &QQuickItem::update); @@ -992,7 +992,7 @@ void QWaylandQuickItem::updateSize() QSize size(0, 0); if (surface()) - size = surface()->size() * (d->scaleFactor() / surface()->bufferScale()); + size = surface()->destinationSize() * d->scaleFactor(); setImplicitSize(size.width(), size.height()); if (d->sizeFollowsSurface) @@ -1061,16 +1061,32 @@ bool QWaylandQuickItem::inputRegionContains(const QPointF &localPosition) QPointF QWaylandQuickItem::mapToSurface(const QPointF &point) const { Q_D(const QWaylandQuickItem); - if (!surface() || surface()->size().isEmpty()) + if (!surface() || surface()->destinationSize().isEmpty()) return point / d->scaleFactor(); - qreal xScale = width() / surface()->size().width() * surface()->bufferScale(); - qreal yScale = height() / surface()->size().height() * surface()->bufferScale(); + qreal xScale = width() / surface()->destinationSize().width(); + qreal yScale = height() / surface()->destinationSize().height(); return QPointF(point.x() / xScale, point.y() / yScale); } /*! + * Maps the given \a point in the Wayland surfaces's coordinate system to the equivalent + * point within this item's coordinate system, and returns the mapped coordinate. + */ +QPointF QWaylandQuickItem::mapFromSurface(const QPointF &point) const +{ + Q_D(const QWaylandQuickItem); + if (!surface() || surface()->destinationSize().isEmpty()) + return point * d->scaleFactor(); + + qreal xScale = width() / surface()->destinationSize().width(); + qreal yScale = height() / surface()->destinationSize().height(); + + return QPointF(point.x() * xScale, point.y() * yScale); +} + +/*! * \qmlproperty bool QtWaylandCompositor::WaylandQuickItem::sizeFollowsSurface * * This property specifies whether the size of the item should always match @@ -1301,6 +1317,10 @@ QSGNode *QWaylandQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDat d->provider->setSmooth(smooth()); node->setRect(rect); + qreal scale = surface()->bufferScale(); + QRectF source = surface()->sourceGeometry(); + node->setSourceRect(QRectF(source.topLeft() * scale, source.size() * scale)); + return node; } else { Q_ASSERT(!d->provider); |