diff options
Diffstat (limited to 'src/compositor/compositor_api/qwaylandsurface.cpp')
-rw-r--r-- | src/compositor/compositor_api/qwaylandsurface.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp index 2265b41c0..0d4cae642 100644 --- a/src/compositor/compositor_api/qwaylandsurface.cpp +++ b/src/compositor/compositor_api/qwaylandsurface.cpp @@ -67,6 +67,7 @@ #include <QtGui/QScreen> #include <QtCore/QDebug> +#include <QtCore/QtMath> QT_BEGIN_NAMESPACE @@ -708,6 +709,24 @@ bool QWaylandSurface::inputRegionContains(const QPoint &p) const } /*! + * Returns \c true if the QWaylandSurface's input region contains the point \a position. + * Otherwise returns \c false. + * + * \since 5.14 + */ +bool QWaylandSurface::inputRegionContains(const QPointF &position) const +{ + Q_D(const QWaylandSurface); + // QRegion::contains operates in integers. If a region has a rect (0,0,10,10), (0,0) is + // inside while (10,10) is outside. Therefore, we can't use QPoint::toPoint(), which will + // round upwards, meaning the point (-0.25,-0.25) would be rounded to (0,0) and count as + // being inside the region, and similarly, a point (9.75,9.75) inside the region would be + // rounded upwards and count as being outside the region. + const QPoint floored(qFloor(position.x()), qFloor(position.y())); + return d->inputRegion.contains(floored); +} + +/*! * \qmlmethod void QtWaylandCompositor::WaylandSurface::destroy() * * Destroys the WaylandSurface. @@ -766,6 +785,7 @@ bool QWaylandSurface::isCursorSurface() const /*! * \qmlproperty bool QtWaylandCompositor::WaylandSurface::inhibitsIdle + * \since 5.14 * * This property holds whether this surface is intended to inhibit the idle * behavior of the compositor such as screen blanking, locking and screen saving. @@ -775,6 +795,7 @@ bool QWaylandSurface::isCursorSurface() const /*! * \property QWaylandSurface::inhibitsIdle + * \since 5.14 * * This property holds whether this surface is intended to inhibit the idle * behavior of the compositor such as screen blanking, locking and screen saving. |