diff --git a/src/server/pointerconstraints_interface.h b/src/server/pointerconstraints_interface.h --- a/src/server/pointerconstraints_interface.h +++ b/src/server/pointerconstraints_interface.h @@ -153,6 +153,20 @@ void regionChanged(); /** + * Emitted whenever the pointer hint changes. + * This happens when the parent SurfaceInterface gets committed. + * + * Indicates where the mouse cursor should be positioned after it has been unlocked again. + * Compositor might warp the cursor at this moment to the hint position. For that it + * will not emit any relative motion events. The hint is relative to the top-left + * corner of the surface the lock was applied to. Only non-negative x and y values + * are allowed. Otherwise the hint is invalid and this hint and all previously sent ones + * should be ignored by the compositor. + * + **/ + void hintChanged(const QPointF &hint); + + /** * Emitted whenever the {@link isLocked} state changes. * @see isLocked * @see setLocked diff --git a/src/server/pointerconstraints_interface.cpp b/src/server/pointerconstraints_interface.cpp --- a/src/server/pointerconstraints_interface.cpp +++ b/src/server/pointerconstraints_interface.cpp @@ -67,13 +67,16 @@ void LockedPointerInterface::Private::commit() { - if (!regionIsSet) { - return; + if (regionIsSet) { + region = pendingRegion; + pendingRegion = QRegion(); + regionIsSet = false; + emit q_func()->regionChanged(); + } + if (hintIsSet) { + hintIsSet = false; + emit q_func()->hintChanged(pendingHint); } - region = pendingRegion; - pendingRegion = QRegion(); - regionIsSet = false; - emit q_func()->regionChanged(); } LockedPointerInterface::LockedPointerInterface(Private *p, QObject *parent) diff --git a/src/server/pointerconstraints_interface_p.h b/src/server/pointerconstraints_interface_p.h --- a/src/server/pointerconstraints_interface_p.h +++ b/src/server/pointerconstraints_interface_p.h @@ -71,6 +71,9 @@ QRegion pendingRegion; bool regionIsSet = false; + QPointF pendingHint; + bool hintIsSet = false; + private: LockedPointerInterface *q_func() { return reinterpret_cast(q); diff --git a/src/server/pointerconstraints_interface_v1.cpp b/src/server/pointerconstraints_interface_v1.cpp --- a/src/server/pointerconstraints_interface_v1.cpp +++ b/src/server/pointerconstraints_interface_v1.cpp @@ -171,11 +171,9 @@ void LockedPointerUnstableV1Interface::Private::setCursorPositionHintCallback(wl_client *client, wl_resource *resource, wl_fixed_t surface_x, wl_fixed_t surface_y) { Q_UNUSED(client) - Q_UNUSED(resource) - Q_UNUSED(surface_x) - Q_UNUSED(surface_y) - // double buffered - // TODO: implement + auto p = cast(resource); + p->pendingHint = QPointF(wl_fixed_to_double(surface_x), wl_fixed_to_double(surface_y)); + p->hintIsSet = true; } void LockedPointerUnstableV1Interface::Private::setRegionCallback(wl_client *client, wl_resource *resource, wl_resource * region)