diff options
author | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2019-09-16 08:16:21 +0200 |
---|---|---|
committer | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2019-09-16 08:17:12 +0200 |
commit | b4233b2f606617542c594e411640ef2867152d29 (patch) | |
tree | fc1fc95fa2df4ab21478e120feba8b34c1585db5 /src | |
parent | 92768cf8d48d6fb62e1a0d124ea9cdec447df4d1 (diff) | |
parent | 382e3292aa0eb6addac84ddefeedc98c7f3b41b2 (diff) | |
download | qtwayland-b4233b2f606617542c594e411640ef2867152d29.tar.gz |
Merge remote-tracking branch 'origin/5.13' into 5.14
Conflicts:
src/client/qwaylanddatadevice.cpp
src/client/qwaylandinputcontext.cpp
src/client/qwaylandinputdevice.cpp
src/client/qwaylandwindow.cpp
src/compositor/compositor_api/compositor_api.pri
src/compositor/compositor_api/qwaylandquickitem.cpp
Change-Id: Ice0d8c7d869c9c46113d6ee6ba3adf895a71d58f
Diffstat (limited to 'src')
31 files changed, 172 insertions, 131 deletions
diff --git a/src/client/configure.json b/src/client/configure.json index 403a2edc..e9e16324 100644 --- a/src/client/configure.json +++ b/src/client/configure.json @@ -140,7 +140,7 @@ }, "xcomposite-egl": { "label": "XComposite EGL", - "condition": "features.wayland-client && features.opengl && features.egl && features.xlib && libs.xcomposite", + "condition": "features.wayland-client && features.opengl && features.egl && features.xlib && libs.xcomposite && features.egl_x11", "output": [ "privateFeature" ] }, "xcomposite-glx": { diff --git a/src/client/qwaylanddatadevice.cpp b/src/client/qwaylanddatadevice.cpp index e7afc3ca..fc3c7077 100644 --- a/src/client/qwaylanddatadevice.cpp +++ b/src/client/qwaylanddatadevice.cpp @@ -103,20 +103,23 @@ QWaylandDataOffer *QWaylandDataDevice::dragOffer() const return m_dragOffer.data(); } -void QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon) +bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon) { - m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData)); - connect(m_dragSource.data(), &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::dragSourceCancelled); - auto *seat = m_display->currentInputDevice(); auto *origin = seat->pointerFocus(); if (!origin) origin = seat->touchFocus(); - if (origin) - start_drag(m_dragSource->object(), origin->wlSurface(), icon->wlSurface(), m_display->currentInputDevice()->serial()); - else + if (!origin) { qCDebug(lcQpaWayland) << "Couldn't start a drag because the origin window could not be found."; + return false; + } + + m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData)); + connect(m_dragSource.data(), &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::dragSourceCancelled); + + start_drag(m_dragSource->object(), origin->wlSurface(), icon->wlSurface(), m_display->currentInputDevice()->serial()); + return true; } void QWaylandDataDevice::cancelDrag() diff --git a/src/client/qwaylanddatadevice_p.h b/src/client/qwaylanddatadevice_p.h index 0a7f4253..16c3ad28 100644 --- a/src/client/qwaylanddatadevice_p.h +++ b/src/client/qwaylanddatadevice_p.h @@ -89,7 +89,7 @@ public: #if QT_CONFIG(draganddrop) QWaylandDataOffer *dragOffer() const; - void startDrag(QMimeData *mimeData, QWaylandWindow *icon); + bool startDrag(QMimeData *mimeData, QWaylandWindow *icon); void cancelDrag(); #endif diff --git a/src/client/qwaylanddnd.cpp b/src/client/qwaylanddnd.cpp index b01a9db3..6535aa16 100644 --- a/src/client/qwaylanddnd.cpp +++ b/src/client/qwaylanddnd.cpp @@ -66,8 +66,13 @@ void QWaylandDrag::startDrag() { QBasicDrag::startDrag(); QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle()); - m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon); - icon->addAttachOffset(-drag()->hotSpot()); + if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon)) { + icon->addAttachOffset(-drag()->hotSpot()); + } else { + // Cancelling immediately does not work, since the event loop for QDrag::exec is started + // after this function returns. + QMetaObject::invokeMethod(this, [this](){ cancelDrag(); }, Qt::QueuedConnection); + } } void QWaylandDrag::cancel() diff --git a/src/client/qwaylandinputcontext.cpp b/src/client/qwaylandinputcontext.cpp index 068c058e..e9afe05e 100644 --- a/src/client/qwaylandinputcontext.cpp +++ b/src/client/qwaylandinputcontext.cpp @@ -119,7 +119,8 @@ void QWaylandTextInput::updateState(Qt::InputMethodQueries queries, uint32_t fla if (!QGuiApplication::focusWindow() || !QGuiApplication::focusWindow()->handle()) return; - auto *surface = static_cast<QWaylandWindow *>(QGuiApplication::focusWindow()->handle())->wlSurface(); + auto *window = static_cast<QWaylandWindow *>(QGuiApplication::focusWindow()->handle()); + auto *surface = window->wlSurface(); if (!surface || (surface != m_surface)) return; @@ -157,8 +158,10 @@ void QWaylandTextInput::updateState(Qt::InputMethodQueries queries, uint32_t fla if (queries & Qt::ImCursorRectangle) { const QRect &cRect = event.value(Qt::ImCursorRectangle).toRect(); - const QRect &tRect = QGuiApplication::inputMethod()->inputItemTransform().mapRect(cRect); - set_cursor_rectangle(tRect.x(), tRect.y(), tRect.width(), tRect.height()); + const QRect &windowRect = QGuiApplication::inputMethod()->inputItemTransform().mapRect(cRect); + const QMargins margins = window->frameMargins(); + const QRect &surfaceRect = windowRect.translated(margins.left(), margins.top()); + set_cursor_rectangle(surfaceRect.x(), surfaceRect.y(), surfaceRect.width(), surfaceRect.height()); } if (queries & Qt::ImPreferredLanguage) { diff --git a/src/client/qwaylandinputdevice.cpp b/src/client/qwaylandinputdevice.cpp index f2dee75e..e39ccf25 100644 --- a/src/client/qwaylandinputdevice.cpp +++ b/src/client/qwaylandinputdevice.cpp @@ -1200,7 +1200,7 @@ void QWaylandInputDevice::Keyboard::keyboard_key(uint32_t serial, uint32_t time, QEvent::Type type = isDown ? QEvent::KeyPress : QEvent::KeyRelease; handleKey(time, type, qtkey, modifiers, code, sym, mNativeModifiers, text); - if (state == WL_KEYBOARD_KEY_STATE_PRESSED && xkb_keymap_key_repeats(mXkbKeymap.get(), code)) { + if (state == WL_KEYBOARD_KEY_STATE_PRESSED && xkb_keymap_key_repeats(mXkbKeymap.get(), code) && mRepeatRate > 0) { mRepeatKey.key = qtkey; mRepeatKey.code = code; mRepeatKey.time = time; @@ -1295,34 +1295,40 @@ void QWaylandInputDevice::Touch::touch_down(uint32_t serial, mParent->mSerial = serial; mFocus = window; mParent->mQDisplay->setLastInputDevice(mParent, serial, mFocus); - mParent->handleTouchPoint(id, wl_fixed_to_double(x), wl_fixed_to_double(y), Qt::TouchPointPressed); + QPointF position(wl_fixed_to_double(x), wl_fixed_to_double(y)); + mParent->handleTouchPoint(id, Qt::TouchPointPressed, position); } void QWaylandInputDevice::Touch::touch_up(uint32_t serial, uint32_t time, int32_t id) { Q_UNUSED(serial); Q_UNUSED(time); - mFocus = nullptr; - mParent->handleTouchPoint(id, 0, 0, Qt::TouchPointReleased); + mParent->handleTouchPoint(id, Qt::TouchPointReleased); + + if (allTouchPointsReleased()) { + mFocus = nullptr; - // As of Weston 1.5.90 there is no touch_frame after the last touch_up - // (i.e. when the last finger is released). To accommodate for this, issue a - // touch_frame. This cannot hurt since it is safe to call the touch_frame - // handler multiple times when there are no points left. - if (allTouchPointsReleased()) + // As of Weston 7.0.0 there is no touch_frame after the last touch_up + // (i.e. when the last finger is released). To accommodate for this, issue a + // touch_frame. This cannot hurt since it is safe to call the touch_frame + // handler multiple times when there are no points left. + // See: https://gitlab.freedesktop.org/wayland/weston/issues/44 + // TODO: change logging category to lcQpaWaylandInput in newer versions. + qCDebug(lcQpaWayland, "Generating fake frame event to work around Weston bug"); touch_frame(); + } } void QWaylandInputDevice::Touch::touch_motion(uint32_t time, int32_t id, wl_fixed_t x, wl_fixed_t y) { Q_UNUSED(time); - mParent->handleTouchPoint(id, wl_fixed_to_double(x), wl_fixed_to_double(y), Qt::TouchPointMoved); + QPointF position(wl_fixed_to_double(x), wl_fixed_to_double(y)); + mParent->handleTouchPoint(id, Qt::TouchPointMoved, position); } void QWaylandInputDevice::Touch::touch_cancel() { - mPrevTouchPoints.clear(); - mTouchPoints.clear(); + mPendingTouchPoints.clear(); QWaylandTouchExtension *touchExt = mParent->mQDisplay->touchExtension(); if (touchExt) @@ -1331,22 +1337,18 @@ void QWaylandInputDevice::Touch::touch_cancel() QWindowSystemInterface::handleTouchCancelEvent(nullptr, mParent->mTouchDevice); } -void QWaylandInputDevice::handleTouchPoint(int id, double x, double y, Qt::TouchPointState state) +void QWaylandInputDevice::handleTouchPoint(int id, Qt::TouchPointState state, const QPointF &surfacePosition) { - QWindowSystemInterface::TouchPoint tp; - - // Find out the coordinates for Released events. - bool coordsOk = false; - if (state == Qt::TouchPointReleased) - for (int i = 0; i < mTouch->mPrevTouchPoints.count(); ++i) - if (mTouch->mPrevTouchPoints.at(i).id == id) { - tp.area = mTouch->mPrevTouchPoints.at(i).area; - coordsOk = true; - break; - } + auto end = mTouch->mPendingTouchPoints.end(); + auto it = std::find_if(mTouch->mPendingTouchPoints.begin(), end, [id](auto tp){ return tp.id == id; }); + if (it == end) { + it = mTouch->mPendingTouchPoints.insert(end, QWindowSystemInterface::TouchPoint()); + it->id = id; + } + QWindowSystemInterface::TouchPoint &tp = *it; - if (!coordsOk) { - // x and y are surface relative. + // Only moved and pressed needs to update/set position + if (state == Qt::TouchPointMoved || state == Qt::TouchPointPressed) { // We need a global (screen) position. QWaylandWindow *win = mTouch->mFocus; @@ -1360,63 +1362,46 @@ void QWaylandInputDevice::handleTouchPoint(int id, double x, double y, Qt::Touch tp.area = QRectF(0, 0, 8, 8); QMargins margins = win->frameMargins(); - tp.area.moveCenter(win->window()->mapToGlobal(QPoint(x - margins.left(), y - margins.top()))); + QPointF localPosition = surfacePosition - QPointF(margins.left(), margins.top()); + // TODO: This doesn't account for high dpi scaling for the delta, but at least it matches + // what we have for mouse input. + QPointF delta = localPosition - localPosition.toPoint(); + QPointF globalPosition = win->window()->mapToGlobal(localPosition.toPoint()) + delta; + tp.area.moveCenter(globalPosition); } tp.state = state; - tp.id = id; tp.pressure = tp.state == Qt::TouchPointReleased ? 0 : 1; - mTouch->mTouchPoints.append(tp); } bool QWaylandInputDevice::Touch::allTouchPointsReleased() { - for (int i = 0; i < mTouchPoints.count(); ++i) - if (mTouchPoints.at(i).state != Qt::TouchPointReleased) + for (const auto &tp : qAsConst(mPendingTouchPoints)) { + if (tp.state != Qt::TouchPointReleased) return false; - + } return true; } void QWaylandInputDevice::Touch::releasePoints() { - for (const QWindowSystemInterface::TouchPoint &previousPoint : qAsConst(mPrevTouchPoints)) { - QWindowSystemInterface::TouchPoint tp = previousPoint; + if (mPendingTouchPoints.empty()) + return; + + for (QWindowSystemInterface::TouchPoint &tp : mPendingTouchPoints) tp.state = Qt::TouchPointReleased; - mTouchPoints.append(tp); - } + touch_frame(); } void QWaylandInputDevice::Touch::touch_frame() { - // Copy all points, that are in the previous but not in the current list, as stationary. - for (int i = 0; i < mPrevTouchPoints.count(); ++i) { - const QWindowSystemInterface::TouchPoint &prevPoint(mPrevTouchPoints.at(i)); - if (prevPoint.state == Qt::TouchPointReleased) - continue; - bool found = false; - for (int j = 0; j < mTouchPoints.count(); ++j) - if (mTouchPoints.at(j).id == prevPoint.id) { - found = true; - break; - } - if (!found) { - QWindowSystemInterface::TouchPoint p = prevPoint; - p.state = Qt::TouchPointStationary; - mTouchPoints.append(p); - } - } - - if (mTouchPoints.isEmpty()) { - mPrevTouchPoints.clear(); - return; - } + // TODO: early return if no events? QWindow *window = mFocus ? mFocus->window() : nullptr; if (mFocus) { - const QWindowSystemInterface::TouchPoint &tp = mTouchPoints.last(); + const QWindowSystemInterface::TouchPoint &tp = mPendingTouchPoints.last(); // When the touch event is received, the global pos is calculated with the margins // in mind. Now we need to adjust again to get the correct local pos back. QMargins margins = window->frameMargins(); @@ -1425,14 +1410,21 @@ void QWaylandInputDevice::Touch::touch_frame() if (mFocus->touchDragDecoration(mParent, localPos, tp.area.center(), tp.state, mParent->modifiers())) return; } - QWindowSystemInterface::handleTouchEvent(window, mParent->mTouchDevice, mTouchPoints); - if (allTouchPointsReleased()) - mPrevTouchPoints.clear(); - else - mPrevTouchPoints = mTouchPoints; + QWindowSystemInterface::handleTouchEvent(window, mParent->mTouchDevice, mPendingTouchPoints); + + // Prepare state for next frame + const auto prevTouchPoints = mPendingTouchPoints; + mPendingTouchPoints.clear(); + for (const auto &prevPoint: prevTouchPoints) { + // All non-released touch points should be part of the next touch event + if (prevPoint.state != Qt::TouchPointReleased) { + QWindowSystemInterface::TouchPoint tp = prevPoint; + tp.state = Qt::TouchPointStationary; // ... as stationary (unless proven otherwise) + mPendingTouchPoints.append(tp); + } + } - mTouchPoints.clear(); } } diff --git a/src/client/qwaylandinputdevice_p.h b/src/client/qwaylandinputdevice_p.h index 7fbb5667..60d6f2c1 100644 --- a/src/client/qwaylandinputdevice_p.h +++ b/src/client/qwaylandinputdevice_p.h @@ -188,7 +188,7 @@ private: uint32_t mSerial = 0; void seat_capabilities(uint32_t caps) override; - void handleTouchPoint(int id, double x, double y, Qt::TouchPointState state); + void handleTouchPoint(int id, Qt::TouchPointState state, const QPointF &surfacePosition = QPoint()); QTouchDevice *mTouchDevice = nullptr; @@ -389,8 +389,7 @@ public: QWaylandInputDevice *mParent = nullptr; QPointer<QWaylandWindow> mFocus; - QList<QWindowSystemInterface::TouchPoint> mTouchPoints; - QList<QWindowSystemInterface::TouchPoint> mPrevTouchPoints; + QList<QWindowSystemInterface::TouchPoint> mPendingTouchPoints; }; class QWaylandPointerEvent diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index 60317cda..ccf4f8da 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -201,10 +201,13 @@ void QWaylandWindow::initWindow() void QWaylandWindow::initializeWlSurface() { Q_ASSERT(!mSurface); - mSurface.reset(new QWaylandSurface(mDisplay)); - connect(mSurface.data(), &QWaylandSurface::screensChanged, - this, &QWaylandWindow::handleScreensChanged); - mSurface->m_window = this; + { + QWriteLocker lock(&mSurfaceLock); + mSurface.reset(new QWaylandSurface(mDisplay)); + connect(mSurface.data(), &QWaylandSurface::screensChanged, + this, &QWaylandWindow::handleScreensChanged); + mSurface->m_window = this; + } emit wlSurfaceCreated(); } @@ -242,6 +245,7 @@ void QWaylandWindow::reset(bool sendDestroyEvent) mSubSurfaceWindow = nullptr; if (mSurface) { emit wlSurfaceDestroyed(); + QWriteLocker lock(&mSurfaceLock); mSurface.reset(); } @@ -617,10 +621,11 @@ QMutex QWaylandWindow::mFrameSyncMutex; bool QWaylandWindow::waitForFrameSync(int timeout) { - QMutexLocker locker(&mFrameSyncMutex); if (!mWaitingForFrameCallback) return true; + QMutexLocker locker(&mFrameSyncMutex); + wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(mFrameCallback), mFrameQueue); mDisplay->dispatchQueueWhile(mFrameQueue, [&]() { return mWaitingForFrameCallback; }, timeout); @@ -1135,6 +1140,9 @@ void QWaylandWindow::requestUpdate() void QWaylandWindow::handleUpdate() { // TODO: Should sync subsurfaces avoid requesting frame callbacks? + QReadLocker lock(&mSurfaceLock); + if (!mSurface) + return; if (mFrameCallback) { wl_callback_destroy(mFrameCallback); diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h index 471ace4c..52e57c72 100644 --- a/src/client/qwaylandwindow_p.h +++ b/src/client/qwaylandwindow_p.h @@ -53,6 +53,8 @@ #include <QtCore/QWaitCondition> #include <QtCore/QMutex> +#include <QtCore/QReadWriteLock> + #include <QtGui/QIcon> #include <QtCore/QVariant> #include <QtCore/QLoggingCategory> @@ -274,6 +276,8 @@ private: static QMutex mFrameSyncMutex; static QWaylandWindow *mMouseGrab; + QReadWriteLock mSurfaceLock; + friend class QWaylandSubSurface; }; diff --git a/src/compositor/compositor_api/compositor_api.pri b/src/compositor/compositor_api/compositor_api.pri index 9c44d0ec..bbc3a03e 100644 --- a/src/compositor/compositor_api/compositor_api.pri +++ b/src/compositor/compositor_api/compositor_api.pri @@ -64,9 +64,7 @@ qtConfig(draganddrop) { compositor_api/qwaylanddrag.cpp } -qtHaveModule(quick) { - DEFINES += QT_WAYLAND_COMPOSITOR_QUICK - +qtConfig(wayland-compositor-quick) { SOURCES += \ compositor_api/qwaylandquickcompositor.cpp \ compositor_api/qwaylandquicksurface.cpp \ diff --git a/src/compositor/compositor_api/qwaylandquickchildren.h b/src/compositor/compositor_api/qwaylandquickchildren.h index 7d821ab5..cee7a67e 100644 --- a/src/compositor/compositor_api/qwaylandquickchildren.h +++ b/src/compositor/compositor_api/qwaylandquickchildren.h @@ -51,16 +51,15 @@ // We mean it. // -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#include <QtWaylandCompositor/qtwaylandcompositorglobal.h> +#if QT_CONFIG(wayland_compositor_quick) #include <QtQml/QQmlListProperty> #include <QtCore/QVector> #endif -#include <QtCore/qglobal.h> - QT_BEGIN_NAMESPACE -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) #define Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(className) \ Q_PROPERTY(QQmlListProperty<QObject> data READ data DESIGNABLE false) \ Q_CLASSINFO("DefaultProperty", "data") \ diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp index ee15a087..ecea8125 100644 --- a/src/compositor/compositor_api/qwaylandquickitem.cpp +++ b/src/compositor/compositor_api/qwaylandquickitem.cpp @@ -477,7 +477,7 @@ void QWaylandQuickItem::mousePressEvent(QMouseEvent *event) return; } - if (!inputRegionContains(event->pos())) { + if (!inputRegionContains(event->localPos())) { event->ignore(); return; } @@ -489,7 +489,7 @@ void QWaylandQuickItem::mousePressEvent(QMouseEvent *event) seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->localPos()), event->windowPos()); seat->sendMousePressEvent(event->button()); - d->hoverPos = event->pos(); + d->hoverPos = event->localPos(); } /*! @@ -515,7 +515,7 @@ void QWaylandQuickItem::mouseMoveEvent(QMouseEvent *event) #endif // QT_CONFIG(draganddrop) { seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->localPos()), event->windowPos()); - d->hoverPos = event->pos(); + d->hoverPos = event->localPos(); } } else { emit mouseMove(event->windowPos()); @@ -552,14 +552,14 @@ void QWaylandQuickItem::mouseReleaseEvent(QMouseEvent *event) void QWaylandQuickItem::hoverEnterEvent(QHoverEvent *event) { Q_D(QWaylandQuickItem); - if (!inputRegionContains(event->pos())) { + if (!inputRegionContains(event->posF())) { event->ignore(); return; } if (d->shouldSendInputEvents()) { QWaylandSeat *seat = compositor()->seatFor(event); - seat->sendMouseMoveEvent(d->view.data(), event->pos(), mapToScene(event->pos())); - d->hoverPos = event->pos(); + seat->sendMouseMoveEvent(d->view.data(), event->posF(), mapToScene(event->posF())); + d->hoverPos = event->posF(); } else { event->ignore(); } @@ -572,16 +572,16 @@ void QWaylandQuickItem::hoverMoveEvent(QHoverEvent *event) { Q_D(QWaylandQuickItem); if (surface()) { - if (!inputRegionContains(event->pos())) { + if (!inputRegionContains(event->posF())) { event->ignore(); return; } } if (d->shouldSendInputEvents()) { QWaylandSeat *seat = compositor()->seatFor(event); - if (event->pos() != d->hoverPos) { - seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->pos()), mapToScene(event->pos())); - d->hoverPos = event->pos(); + if (event->posF() != d->hoverPos) { + seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->posF()), mapToScene(event->posF())); + d->hoverPos = event->posF(); } } else { event->ignore(); @@ -667,10 +667,10 @@ void QWaylandQuickItem::touchEvent(QTouchEvent *event) if (d->shouldSendInputEvents() && d->touchEventsEnabled) { QWaylandSeat *seat = compositor()->seatFor(event); - QPoint pointPos; + QPointF pointPos; const QList<QTouchEvent::TouchPoint> &points = event->touchPoints(); if (!points.isEmpty()) - pointPos = points.at(0).pos().toPoint(); + pointPos = points.at(0).pos(); if (event->type() == QEvent::TouchBegin && !inputRegionContains(pointPos)) { event->ignore(); @@ -1063,7 +1063,7 @@ void QWaylandQuickItem::setFocusOnClick(bool focus) bool QWaylandQuickItem::inputRegionContains(const QPointF &localPosition) const { if (QWaylandSurface *s = surface()) - return s->inputRegionContains(mapToSurface(localPosition).toPoint()); + return s->inputRegionContains(mapToSurface(localPosition)); return false; } diff --git a/src/compositor/compositor_api/qwaylandquickitem_p.h b/src/compositor/compositor_api/qwaylandquickitem_p.h index 2ec02ca6..832272a3 100644 --- a/src/compositor/compositor_api/qwaylandquickitem_p.h +++ b/src/compositor/compositor_api/qwaylandquickitem_p.h @@ -173,7 +173,7 @@ public: bool focusOnClick = true; bool sizeFollowsSurface = true; bool belowParent = false; - QPoint hoverPos; + QPointF hoverPos; QMatrix4x4 lastMatrix; QQuickWindow *connectedWindow = nullptr; diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp index ae697e91..c5462839 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 @@ -707,6 +708,23 @@ bool QWaylandSurface::inputRegionContains(const QPoint &p) const return d->inputRegion.contains(p); } +//TODO: Add appropriate \since version when this is made public. +/*! + * Returns \c true if the QWaylandSurface's input region contains the point \a position. + * Otherwise returns \c false. + */ +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() * diff --git a/src/compositor/compositor_api/qwaylandsurface.h b/src/compositor/compositor_api/qwaylandsurface.h index a762074b..f1a8bad2 100644 --- a/src/compositor/compositor_api/qwaylandsurface.h +++ b/src/compositor/compositor_api/qwaylandsurface.h @@ -131,6 +131,13 @@ public: QWaylandCompositor *compositor() const; bool inputRegionContains(const QPoint &p) const; +private: + // TODO: Making this private now since it's added in a patch release, and we want to ensure + // compatibility with older patch releases. + // This should simply be made public (and the friend removed) in the next minor release. + friend class QWaylandQuickItem; + bool inputRegionContains(const QPointF &position) const; +public: Q_INVOKABLE void destroy(); Q_INVOKABLE bool isDestroyed() const; diff --git a/src/compositor/configure.json b/src/compositor/configure.json index db80543f..46caceff 100644 --- a/src/compositor/configure.json +++ b/src/compositor/configure.json @@ -28,6 +28,7 @@ "test": { "tail": [ "extern \"C\" {", + "#include <math.h> /* may fail because of 'private:' in c++ type_traits.h */", "#define private priv", "#include <wayland-kms.h>", "#undef private", @@ -158,6 +159,12 @@ "label": "VSP2 hardware layer integration", "condition": "features.wayland-server && features.eglfs_vsp2 && libs.wayland-kms", "output": [ "privateFeature" ] + }, + "wayland-compositor-quick": { + "label": "QtQuick integration for wayland compositor", + "purpose": "Allows QtWayland compositor types to be used with QtQuick", + "condition": "features.wayland-server && module.quick && features.opengl", + "output": [ "publicFeature" ] } }, diff --git a/src/compositor/extensions/qwaylandivisurface.cpp b/src/compositor/extensions/qwaylandivisurface.cpp index 0ae488de..f1d58f73 100644 --- a/src/compositor/extensions/qwaylandivisurface.cpp +++ b/src/compositor/extensions/qwaylandivisurface.cpp @@ -40,7 +40,7 @@ #include "qwaylandivisurface.h" #include "qwaylandivisurface_p.h" #include "qwaylandiviapplication_p.h" -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) #include "qwaylandivisurfaceintegration_p.h" #endif @@ -208,7 +208,7 @@ void QWaylandIviSurface::sendConfigure(const QSize &size) d->send_configure(size.width(), size.height()); } -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) QWaylandQuickShellIntegration *QWaylandIviSurface::createIntegration(QWaylandQuickShellSurfaceItem *item) { return new QtWayland::IviSurfaceIntegration(item); diff --git a/src/compositor/extensions/qwaylandivisurface.h b/src/compositor/extensions/qwaylandivisurface.h index 65d5bbc8..525ad957 100644 --- a/src/compositor/extensions/qwaylandivisurface.h +++ b/src/compositor/extensions/qwaylandivisurface.h @@ -78,7 +78,7 @@ public: Q_INVOKABLE void sendConfigure(const QSize &size); -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) override; #endif diff --git a/src/compositor/extensions/qwaylandshellsurface.cpp b/src/compositor/extensions/qwaylandshellsurface.cpp index cb6d0364..7b59801e 100644 --- a/src/compositor/extensions/qwaylandshellsurface.cpp +++ b/src/compositor/extensions/qwaylandshellsurface.cpp @@ -69,7 +69,7 @@ * \sa QWaylandSurface, QWaylandWlShellSurface, QWaylandXdgSurfaceV5, QWaylandIviSurface */ -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) /*! * \fn QWaylandQuickShellIntegration *QWaylandShellSurface::createIntegration(QWaylandQuickShellSurfaceItem *item) * diff --git a/src/compositor/extensions/qwaylandshellsurface.h b/src/compositor/extensions/qwaylandshellsurface.h index aca02e2f..6b943f36 100644 --- a/src/compositor/extensions/qwaylandshellsurface.h +++ b/src/compositor/extensions/qwaylandshellsurface.h @@ -54,7 +54,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandShellSurface : public QWaylandComposit Q_OBJECT Q_PROPERTY(Qt::WindowType windowType READ windowType NOTIFY windowTypeChanged) public: -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) virtual QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) = 0; #endif QWaylandShellSurface(QWaylandObject *waylandObject) : QWaylandCompositorExtension(waylandObject) {} diff --git a/src/compositor/extensions/qwaylandwlshell.cpp b/src/compositor/extensions/qwaylandwlshell.cpp index 8cd2c731..ea228cab 100644 --- a/src/compositor/extensions/qwaylandwlshell.cpp +++ b/src/compositor/extensions/qwaylandwlshell.cpp @@ -41,7 +41,7 @@ #include "qwaylandwlshell.h" #include "qwaylandwlshell_p.h" -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) #include "qwaylandwlshellintegration_p.h" #endif #include <QtWaylandCompositor/private/qwaylandutils_p.h> @@ -587,7 +587,7 @@ void QWaylandWlShellSurface::sendPopupDone() d->send_popup_done(); } -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) QWaylandQuickShellIntegration *QWaylandWlShellSurface::createIntegration(QWaylandQuickShellSurfaceItem *item) { return new QtWayland::WlShellIntegration(item); diff --git a/src/compositor/extensions/qwaylandwlshell.h b/src/compositor/extensions/qwaylandwlshell.h index 42188800..b37773e2 100644 --- a/src/compositor/extensions/qwaylandwlshell.h +++ b/src/compositor/extensions/qwaylandwlshell.h @@ -140,7 +140,7 @@ public: Q_INVOKABLE void sendConfigure(const QSize &size, ResizeEdge edges); Q_INVOKABLE void sendPopupDone(); -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) override; #endif diff --git a/src/compositor/extensions/qwaylandxdgshell.cpp b/src/compositor/extensions/qwaylandxdgshell.cpp index eece3f3d..1b8a3c2e 100644 --- a/src/compositor/extensions/qwaylandxdgshell.cpp +++ b/src/compositor/extensions/qwaylandxdgshell.cpp @@ -37,7 +37,7 @@ #include "qwaylandxdgshell.h" #include "qwaylandxdgshell_p.h" -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) #include "qwaylandxdgshellintegration_p.h" #endif #include <QtWaylandCompositor/private/qwaylandutils_p.h> @@ -693,7 +693,7 @@ QWaylandXdgSurface *QWaylandXdgSurface::fromResource(wl_resource *resource) return nullptr; } -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) QWaylandQuickShellIntegration *QWaylandXdgSurface::createIntegration(QWaylandQuickShellSurfaceItem *item) { Q_D(const QWaylandXdgSurface); diff --git a/src/compositor/extensions/qwaylandxdgshell.h b/src/compositor/extensions/qwaylandxdgshell.h index f45038eb..2e3e2818 100644 --- a/src/compositor/extensions/qwaylandxdgshell.h +++ b/src/compositor/extensions/qwaylandxdgshell.h @@ -119,7 +119,7 @@ public: static QByteArray interfaceName(); static QWaylandXdgSurface *fromResource(::wl_resource *resource); -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) override; #endif diff --git a/src/compositor/extensions/qwaylandxdgshellv5.cpp b/src/compositor/extensions/qwaylandxdgshellv5.cpp index a40c2168..e38e68eb 100644 --- a/src/compositor/extensions/qwaylandxdgshellv5.cpp +++ b/src/compositor/extensions/qwaylandxdgshellv5.cpp @@ -40,7 +40,7 @@ #include "qwaylandxdgshellv5.h" #include "qwaylandxdgshellv5_p.h" -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) #include "qwaylandxdgshellv5integration_p.h" #endif #include <QtWaylandCompositor/private/qwaylandutils_p.h> @@ -1317,7 +1317,7 @@ uint QWaylandXdgSurfaceV5::sendResizing(const QSize &maxSize) return sendConfigure(maxSize, conf.states); } -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) QWaylandQuickShellIntegration *QWaylandXdgSurfaceV5::createIntegration(QWaylandQuickShellSurfaceItem *item) { return new QtWayland::XdgShellV5Integration(item); @@ -1517,7 +1517,7 @@ void QWaylandXdgPopupV5::sendPopupDone() d->send_popup_done(); } -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) QWaylandQuickShellIntegration *QWaylandXdgPopupV5::createIntegration(QWaylandQuickShellSurfaceItem *item) { return new QtWayland::XdgPopupV5Integration(item); diff --git a/src/compositor/extensions/qwaylandxdgshellv5.h b/src/compositor/extensions/qwaylandxdgshellv5.h index f989d04c..66e9ceb0 100644 --- a/src/compositor/extensions/qwaylandxdgshellv5.h +++ b/src/compositor/extensions/qwaylandxdgshellv5.h @@ -171,7 +171,7 @@ public: Q_INVOKABLE uint sendFullscreen(const QSize &size); Q_INVOKABLE uint sendResizing(const QSize &maxSize); -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) override; #endif @@ -243,7 +243,7 @@ public: Q_INVOKABLE void sendPopupDone(); -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) override; #endif diff --git a/src/compositor/extensions/qwaylandxdgshellv6.cpp b/src/compositor/extensions/qwaylandxdgshellv6.cpp index 96d6f550..934dccb0 100644 --- a/src/compositor/extensions/qwaylandxdgshellv6.cpp +++ b/src/compositor/extensions/qwaylandxdgshellv6.cpp @@ -37,7 +37,7 @@ #include "qwaylandxdgshellv6.h" #include "qwaylandxdgshellv6_p.h" -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) #include "qwaylandxdgshellv6integration_p.h" #endif #include <QtWaylandCompositor/private/qwaylandutils_p.h> @@ -698,7 +698,7 @@ QWaylandXdgSurfaceV6 *QWaylandXdgSurfaceV6::fromResource(wl_resource *resource) return nullptr; } -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) QWaylandQuickShellIntegration *QWaylandXdgSurfaceV6::createIntegration(QWaylandQuickShellSurfaceItem *item) { Q_D(const QWaylandXdgSurfaceV6); diff --git a/src/compositor/extensions/qwaylandxdgshellv6.h b/src/compositor/extensions/qwaylandxdgshellv6.h index 64c82306..71f82521 100644 --- a/src/compositor/extensions/qwaylandxdgshellv6.h +++ b/src/compositor/extensions/qwaylandxdgshellv6.h @@ -119,7 +119,7 @@ public: static QByteArray interfaceName(); static QWaylandXdgSurfaceV6 *fromResource(::wl_resource *resource); -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) override; #endif diff --git a/src/imports/compositor/compositor.pro b/src/imports/compositor/compositor.pro index f5c7567a..59dd7824 100644 --- a/src/imports/compositor/compositor.pro +++ b/src/imports/compositor/compositor.pro @@ -14,8 +14,6 @@ COMPOSITOR_QML_FILES += \ WaylandOutputWindow.qml \ WaylandCursorItem.qml -DEFINES += QT_WAYLAND_COMPOSITOR_QUICK - # Create the resource file GENERATED_RESOURCE_FILE = $$OUT_PWD/compositor.qrc diff --git a/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp index e81aa903..dc3cfdbf 100644 --- a/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp +++ b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp @@ -342,7 +342,7 @@ void QWaylandXdgSurfaceV6::requestWindowStates(Qt::WindowStates states) if (m_toplevel) m_toplevel->requestWindowStates(states); else - qCWarning(lcQpaWayland) << "Non-toplevel surfaces can't request window states"; + qCDebug(lcQpaWayland) << "Ignoring window states requested by non-toplevel."; } void QWaylandXdgSurfaceV6::setToplevel() diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp index ca8da80b..bd1f5a21 100644 --- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp +++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp @@ -377,7 +377,7 @@ void QWaylandXdgSurface::requestWindowStates(Qt::WindowStates states) if (m_toplevel) m_toplevel->requestWindowStates(states); else - qCWarning(lcQpaWayland) << "Non-toplevel surfaces can't request window states"; + qCDebug(lcQpaWayland) << "Ignoring window states requested by non-toplevel zxdg_surface_v6."; } void QWaylandXdgSurface::setToplevel() |