diff options
Diffstat (limited to 'src/compositor/compositor_api/qwaylandquickitem.cpp')
-rw-r--r-- | src/compositor/compositor_api/qwaylandquickitem.cpp | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp index 5414d06ae..74ce326e5 100644 --- a/src/compositor/compositor_api/qwaylandquickitem.cpp +++ b/src/compositor/compositor_api/qwaylandquickitem.cpp @@ -384,7 +384,7 @@ QWaylandQuickItem::~QWaylandQuickItem() QWaylandCompositor *QWaylandQuickItem::compositor() const { Q_D(const QWaylandQuickItem); - return d->view->surface() ? d->view->surface()->compositor() : Q_NULLPTR; + return d->view->surface() ? d->view->surface()->compositor() : nullptr; } /*! @@ -587,7 +587,7 @@ void QWaylandQuickItem::hoverLeaveEvent(QHoverEvent *event) Q_D(QWaylandQuickItem); if (d->shouldSendInputEvents()) { QWaylandSeat *seat = compositor()->seatFor(event); - seat->setMouseFocus(Q_NULLPTR); + seat->setMouseFocus(nullptr); } else { event->ignore(); } @@ -949,9 +949,14 @@ void QWaylandQuickItem::parentChanged(QWaylandSurface *newParent, QWaylandSurfac void QWaylandQuickItem::updateSize() { Q_D(QWaylandQuickItem); - if (d->sizeFollowsSurface && surface()) { - setSize(surface()->size() * (d->scaleFactor() / surface()->bufferScale())); - } + + QSize size(0, 0); + if (surface()) + size = surface()->size() * (d->scaleFactor() / surface()->bufferScale()); + + setImplicitSize(size.width(), size.height()); + if (d->sizeFollowsSurface) + setSize(size); } /*! @@ -1006,7 +1011,13 @@ bool QWaylandQuickItem::inputRegionContains(const QPointF &localPosition) QPointF QWaylandQuickItem::mapToSurface(const QPointF &point) const { Q_D(const QWaylandQuickItem); - return point / d->scaleFactor(); + if (!surface() || surface()->size().isEmpty()) + return point / d->scaleFactor(); + + qreal xScale = width() / surface()->size().width(); + qreal yScale = height() / surface()->size().height(); + + return QPointF(point.x() / xScale, point.y() / yScale); } /*! @@ -1032,6 +1043,9 @@ bool QWaylandQuickItem::sizeFollowsSurface() const return d->sizeFollowsSurface; } +//TODO: sizeFollowsSurface became obsolete when we added an implementation for +//implicit size. The property is here for compatibility reasons only and should +//be removed or at least default to false in Qt 6. void QWaylandQuickItem::setSizeFollowsSurface(bool sizeFollowsSurface) { Q_D(QWaylandQuickItem); @@ -1066,14 +1080,14 @@ QVariant QWaylandQuickItem::inputMethodQuery(Qt::InputMethodQuery query, QVarian Returns true if the item is hidden, though the texture is still updated. As opposed to hiding the item by - setting \l{Item::visible}{visible} to \c false, setting this property to \c true + setting \l{Item::visible}{visible} to \c false, setting this property to \c false will not prevent mouse or keyboard input from reaching item. */ /*! Returns true if the item is hidden, though the texture is still updated. As opposed to hiding the item by - setting \l{Item::visible}{visible} to \c false, setting this property to \c true + setting \l{Item::visible}{visible} to \c false, setting this property to \c false will not prevent mouse or keyboard input from reaching item. */ bool QWaylandQuickItem::paintEnabled() const @@ -1176,9 +1190,10 @@ void QWaylandQuickItem::updateInputMethod(Qt::InputMethodQueries queries) * \sa QWaylandQuickkItem::bufferLocked */ -QSGNode *QWaylandQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) +QSGNode *QWaylandQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) { Q_D(QWaylandQuickItem); + d->lastMatrix = data->transformNode->combinedMatrix(); const bool bufferHasContent = d->view->currentBuffer().hasContent(); if (d->view->isBufferLocked() && !bufferHasContent && d->paintEnabled) @@ -1186,7 +1201,7 @@ QSGNode *QWaylandQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDat if (!bufferHasContent || !d->paintEnabled) { delete oldNode; - return 0; + return nullptr; } QWaylandBufferRef ref = d->view->currentBuffer(); |