2020-03-15 15:19:28 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
2014-11-25 12:52:40 +00:00
|
|
|
|
2020-03-15 15:19:28 +00:00
|
|
|
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
|
|
|
*/
|
2014-11-25 12:52:40 +00:00
|
|
|
#include "pointer_interface.h"
|
2016-04-06 09:27:42 +00:00
|
|
|
#include "pointer_interface_p.h"
|
2016-11-08 13:17:15 +00:00
|
|
|
#include "pointerconstraints_interface.h"
|
2016-10-26 08:27:14 +00:00
|
|
|
#include "pointergestures_interface_p.h"
|
2014-11-26 10:03:32 +00:00
|
|
|
#include "resource_p.h"
|
2020-11-03 16:24:03 +00:00
|
|
|
#include "relativepointer_v1_interface_p.h"
|
2014-11-25 12:52:40 +00:00
|
|
|
#include "seat_interface.h"
|
|
|
|
#include "display.h"
|
2016-04-06 07:52:13 +00:00
|
|
|
#include "subcompositor_interface.h"
|
2014-11-25 12:52:40 +00:00
|
|
|
#include "surface_interface.h"
|
2019-02-06 08:26:43 +00:00
|
|
|
#include "datadevice_interface.h"
|
2014-11-25 12:52:40 +00:00
|
|
|
// Wayland
|
|
|
|
#include <wayland-server.h>
|
|
|
|
|
2020-04-29 14:56:38 +00:00
|
|
|
namespace KWaylandServer
|
2014-11-25 12:52:40 +00:00
|
|
|
{
|
|
|
|
|
2015-02-27 16:36:43 +00:00
|
|
|
class Cursor::Private
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Private(Cursor *q, PointerInterface *pointer);
|
|
|
|
PointerInterface *pointer;
|
|
|
|
quint32 enteredSerial = 0;
|
|
|
|
QPoint hotspot;
|
|
|
|
QPointer<SurfaceInterface> surface;
|
|
|
|
|
|
|
|
void update(const QPointer<SurfaceInterface> &surface, quint32 serial, const QPoint &hotspot);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Cursor *q;
|
|
|
|
};
|
|
|
|
|
2014-11-26 10:03:32 +00:00
|
|
|
PointerInterface::Private::Private(SeatInterface *parent, wl_resource *parentResource, PointerInterface *q)
|
|
|
|
: Resource::Private(q, parent, parentResource, &wl_pointer_interface, &s_interface)
|
|
|
|
, seat(parent)
|
2014-11-25 12:52:40 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-02-27 16:36:43 +00:00
|
|
|
void PointerInterface::Private::setCursor(quint32 serial, SurfaceInterface *surface, const QPoint &hotspot)
|
|
|
|
{
|
|
|
|
if (!cursor) {
|
|
|
|
Q_Q(PointerInterface);
|
|
|
|
cursor = new Cursor(q);
|
2016-02-24 15:46:21 +00:00
|
|
|
cursor->d->update(QPointer<SurfaceInterface>(surface), serial, hotspot);
|
2015-02-27 16:36:43 +00:00
|
|
|
QObject::connect(cursor, &Cursor::changed, q, &PointerInterface::cursorChanged);
|
|
|
|
emit q->cursorChanged();
|
|
|
|
} else {
|
|
|
|
cursor->d->update(QPointer<SurfaceInterface>(surface), serial, hotspot);
|
|
|
|
}
|
|
|
|
}
|
2014-11-25 12:52:40 +00:00
|
|
|
|
2016-04-06 07:52:13 +00:00
|
|
|
void PointerInterface::Private::sendLeave(SurfaceInterface *surface, quint32 serial)
|
|
|
|
{
|
|
|
|
if (!surface) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (resource && surface->resource()) {
|
|
|
|
wl_pointer_send_leave(resource, serial, surface->resource());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 16:24:03 +00:00
|
|
|
void PointerInterface::Private::registerRelativePointerV1(RelativePointerV1Interface *relativePointer)
|
2016-10-07 07:07:34 +00:00
|
|
|
{
|
2020-11-03 16:24:03 +00:00
|
|
|
Q_ASSERT(!relativePointersV1.contains(relativePointer));
|
|
|
|
relativePointersV1.append(relativePointer);
|
2016-10-07 07:07:34 +00:00
|
|
|
}
|
|
|
|
|
2020-11-03 16:24:03 +00:00
|
|
|
void PointerInterface::Private::unregisterRelativePointerV1(RelativePointerV1Interface *relativePointer)
|
|
|
|
{
|
|
|
|
Q_ASSERT(relativePointersV1.contains(relativePointer));
|
|
|
|
relativePointersV1.removeOne(relativePointer);
|
|
|
|
}
|
2016-10-26 08:27:14 +00:00
|
|
|
|
|
|
|
void PointerInterface::Private::registerSwipeGesture(PointerSwipeGestureInterface *gesture)
|
|
|
|
{
|
|
|
|
swipeGestures << gesture;
|
|
|
|
QObject::connect(gesture, &QObject::destroyed, q,
|
|
|
|
[this, gesture] {
|
|
|
|
swipeGestures.removeOne(gesture);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PointerInterface::Private::registerPinchGesture(PointerPinchGestureInterface *gesture)
|
|
|
|
{
|
|
|
|
pinchGestures << gesture;
|
|
|
|
QObject::connect(gesture, &QObject::destroyed, q,
|
|
|
|
[this, gesture] {
|
|
|
|
pinchGestures.removeOne(gesture);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-04-06 07:52:13 +00:00
|
|
|
namespace {
|
|
|
|
static QPointF surfacePosition(SurfaceInterface *surface) {
|
|
|
|
if (surface && surface->subSurface()) {
|
2020-10-31 14:03:30 +00:00
|
|
|
return surface->subSurface()->position() + surfacePosition(surface->subSurface()->parentSurface());
|
2016-04-06 07:52:13 +00:00
|
|
|
}
|
|
|
|
return QPointF();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PointerInterface::Private::sendEnter(SurfaceInterface *surface, const QPointF &parentSurfacePosition, quint32 serial)
|
|
|
|
{
|
2016-07-14 09:45:38 +00:00
|
|
|
if (!surface || !surface->resource()) {
|
2016-04-06 07:52:13 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
const QPointF adjustedPos = parentSurfacePosition - surfacePosition(surface);
|
|
|
|
wl_pointer_send_enter(resource, serial,
|
|
|
|
surface->resource(),
|
|
|
|
wl_fixed_from_double(adjustedPos.x()), wl_fixed_from_double(adjustedPos.y()));
|
|
|
|
}
|
|
|
|
|
2016-10-26 08:27:14 +00:00
|
|
|
void PointerInterface::Private::startSwipeGesture(quint32 serial, quint32 fingerCount)
|
|
|
|
{
|
|
|
|
if (swipeGestures.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (auto it = swipeGestures.constBegin(), end = swipeGestures.constEnd(); it != end; it++) {
|
|
|
|
(*it)->start(serial, fingerCount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PointerInterface::Private::updateSwipeGesture(const QSizeF &delta)
|
|
|
|
{
|
|
|
|
if (swipeGestures.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (auto it = swipeGestures.constBegin(), end = swipeGestures.constEnd(); it != end; it++) {
|
|
|
|
(*it)->update(delta);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PointerInterface::Private::endSwipeGesture(quint32 serial)
|
|
|
|
{
|
|
|
|
if (swipeGestures.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (auto it = swipeGestures.constBegin(), end = swipeGestures.constEnd(); it != end; it++) {
|
|
|
|
(*it)->end(serial);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PointerInterface::Private::cancelSwipeGesture(quint32 serial)
|
|
|
|
{
|
|
|
|
if (swipeGestures.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (auto it = swipeGestures.constBegin(), end = swipeGestures.constEnd(); it != end; it++) {
|
|
|
|
(*it)->cancel(serial);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PointerInterface::Private::startPinchGesture(quint32 serial, quint32 fingerCount)
|
|
|
|
{
|
|
|
|
if (pinchGestures.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (auto it = pinchGestures.constBegin(), end = pinchGestures.constEnd(); it != end; it++) {
|
|
|
|
(*it)->start(serial, fingerCount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PointerInterface::Private::updatePinchGesture(const QSizeF &delta, qreal scale, qreal rotation)
|
|
|
|
{
|
|
|
|
if (pinchGestures.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (auto it = pinchGestures.constBegin(), end = pinchGestures.constEnd(); it != end; it++) {
|
|
|
|
(*it)->update(delta, scale, rotation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PointerInterface::Private::endPinchGesture(quint32 serial)
|
|
|
|
{
|
|
|
|
if (pinchGestures.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (auto it = pinchGestures.constBegin(), end = pinchGestures.constEnd(); it != end; it++) {
|
|
|
|
(*it)->end(serial);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PointerInterface::Private::cancelPinchGesture(quint32 serial)
|
|
|
|
{
|
|
|
|
if (pinchGestures.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (auto it = pinchGestures.constBegin(), end = pinchGestures.constEnd(); it != end; it++) {
|
|
|
|
(*it)->cancel(serial);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-01 16:46:53 +00:00
|
|
|
void PointerInterface::Private::sendFrame()
|
|
|
|
{
|
|
|
|
if (!resource || wl_resource_get_version(resource) < WL_POINTER_FRAME_SINCE_VERSION) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
wl_pointer_send_frame(resource);
|
|
|
|
}
|
|
|
|
|
2020-01-23 11:20:45 +00:00
|
|
|
#ifndef K_DOXYGEN
|
2014-11-25 12:52:40 +00:00
|
|
|
const struct wl_pointer_interface PointerInterface::Private::s_interface = {
|
|
|
|
setCursorCallback,
|
2016-06-28 16:57:08 +00:00
|
|
|
resourceDestroyedCallback
|
2014-11-25 12:52:40 +00:00
|
|
|
};
|
2015-09-09 14:39:50 +00:00
|
|
|
#endif
|
2014-11-25 12:52:40 +00:00
|
|
|
|
2014-11-26 10:03:32 +00:00
|
|
|
PointerInterface::PointerInterface(SeatInterface *parent, wl_resource *parentResource)
|
2016-05-19 13:17:07 +00:00
|
|
|
: Resource(new Private(parent, parentResource, this))
|
2014-11-25 12:52:40 +00:00
|
|
|
{
|
2016-03-01 06:49:04 +00:00
|
|
|
// TODO: handle touch
|
2014-11-27 12:59:31 +00:00
|
|
|
connect(parent, &SeatInterface::pointerPosChanged, this, [this] {
|
2014-11-26 10:03:32 +00:00
|
|
|
Q_D();
|
2019-02-06 08:26:43 +00:00
|
|
|
if (!d->focusedSurface || !d->resource) {
|
2016-03-01 06:49:04 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-02-06 08:26:43 +00:00
|
|
|
if (d->seat->isDragPointer()) {
|
|
|
|
const auto *originSurface = d->seat->dragSource()->origin();
|
|
|
|
const bool proxyRemoteFocused = originSurface->dataProxy() && originSurface == d->focusedSurface;
|
|
|
|
if (!proxyRemoteFocused) {
|
|
|
|
// handled by DataDevice
|
2016-11-08 13:17:15 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-02-06 08:26:43 +00:00
|
|
|
}
|
|
|
|
if (!d->focusedSurface->lockedPointer().isNull() && d->focusedSurface->lockedPointer()->isLocked()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const QPointF pos = d->seat->focusedPointerSurfaceTransformation().map(d->seat->pointerPos());
|
|
|
|
auto targetSurface = d->focusedSurface->inputSurfaceAt(pos);
|
|
|
|
if (!targetSurface) {
|
|
|
|
targetSurface = d->focusedSurface;
|
|
|
|
}
|
|
|
|
if (targetSurface != d->focusedChildSurface.data()) {
|
|
|
|
const quint32 serial = d->seat->display()->nextSerial();
|
|
|
|
d->sendLeave(d->focusedChildSurface.data(), serial);
|
|
|
|
d->focusedChildSurface = QPointer<SurfaceInterface>(targetSurface);
|
|
|
|
d->sendEnter(targetSurface, pos, serial);
|
|
|
|
d->sendFrame();
|
|
|
|
d->client->flush();
|
|
|
|
} else {
|
|
|
|
const QPointF adjustedPos = pos - surfacePosition(d->focusedChildSurface);
|
|
|
|
wl_pointer_send_motion(d->resource, d->seat->timestamp(),
|
|
|
|
wl_fixed_from_double(adjustedPos.x()), wl_fixed_from_double(adjustedPos.y()));
|
|
|
|
d->sendFrame();
|
2014-11-25 13:24:52 +00:00
|
|
|
}
|
|
|
|
});
|
2014-11-25 12:52:40 +00:00
|
|
|
}
|
|
|
|
|
2014-11-26 10:03:32 +00:00
|
|
|
PointerInterface::~PointerInterface() = default;
|
2014-11-25 12:52:40 +00:00
|
|
|
|
2014-11-26 09:34:23 +00:00
|
|
|
void PointerInterface::setFocusedSurface(SurfaceInterface *surface, quint32 serial)
|
2014-11-25 12:52:40 +00:00
|
|
|
{
|
2014-11-26 10:03:32 +00:00
|
|
|
Q_D();
|
2016-04-06 07:52:13 +00:00
|
|
|
d->sendLeave(d->focusedChildSurface.data(), serial);
|
|
|
|
disconnect(d->destroyConnection);
|
2014-11-26 09:34:23 +00:00
|
|
|
if (!surface) {
|
|
|
|
d->focusedSurface = nullptr;
|
2016-04-06 07:52:13 +00:00
|
|
|
d->focusedChildSurface.clear();
|
2014-11-25 12:52:40 +00:00
|
|
|
return;
|
|
|
|
}
|
2014-11-26 09:34:23 +00:00
|
|
|
d->focusedSurface = surface;
|
2020-07-16 13:18:56 +00:00
|
|
|
d->destroyConnection = connect(d->focusedSurface, &SurfaceInterface::aboutToBeDestroyed, this,
|
2014-11-26 10:03:32 +00:00
|
|
|
[this] {
|
|
|
|
Q_D();
|
2017-07-17 15:00:57 +00:00
|
|
|
d->sendLeave(d->focusedChildSurface.data(), d->global->display()->nextSerial());
|
2018-02-01 16:46:53 +00:00
|
|
|
d->sendFrame();
|
2014-11-26 10:03:32 +00:00
|
|
|
d->focusedSurface = nullptr;
|
2016-04-06 07:52:13 +00:00
|
|
|
d->focusedChildSurface.clear();
|
2014-11-26 10:03:32 +00:00
|
|
|
}
|
|
|
|
);
|
2014-11-25 12:52:40 +00:00
|
|
|
|
2015-12-07 10:45:34 +00:00
|
|
|
const QPointF pos = d->seat->focusedPointerSurfaceTransformation().map(d->seat->pointerPos());
|
2018-10-02 16:11:52 +00:00
|
|
|
d->focusedChildSurface = QPointer<SurfaceInterface>(d->focusedSurface->inputSurfaceAt(pos));
|
2016-04-06 07:52:13 +00:00
|
|
|
if (!d->focusedChildSurface) {
|
|
|
|
d->focusedChildSurface = QPointer<SurfaceInterface>(d->focusedSurface);
|
|
|
|
}
|
|
|
|
d->sendEnter(d->focusedChildSurface.data(), pos, serial);
|
2015-04-21 06:56:19 +00:00
|
|
|
d->client->flush();
|
2014-11-25 12:52:40 +00:00
|
|
|
}
|
|
|
|
|
2014-11-26 10:50:52 +00:00
|
|
|
void PointerInterface::buttonPressed(quint32 button, quint32 serial)
|
2014-11-25 12:52:40 +00:00
|
|
|
{
|
2014-11-26 10:03:32 +00:00
|
|
|
Q_D();
|
2014-11-26 10:50:52 +00:00
|
|
|
Q_ASSERT(d->focusedSurface);
|
2015-04-20 07:09:23 +00:00
|
|
|
if (!d->resource) {
|
|
|
|
return;
|
|
|
|
}
|
2014-11-26 09:34:23 +00:00
|
|
|
wl_pointer_send_button(d->resource, serial, d->seat->timestamp(), button, WL_POINTER_BUTTON_STATE_PRESSED);
|
2018-02-01 16:46:53 +00:00
|
|
|
d->sendFrame();
|
2014-11-25 12:52:40 +00:00
|
|
|
}
|
|
|
|
|
2014-11-26 10:50:52 +00:00
|
|
|
void PointerInterface::buttonReleased(quint32 button, quint32 serial)
|
2014-11-25 12:52:40 +00:00
|
|
|
{
|
2014-11-26 10:03:32 +00:00
|
|
|
Q_D();
|
2014-11-26 10:50:52 +00:00
|
|
|
Q_ASSERT(d->focusedSurface);
|
2015-04-20 07:09:23 +00:00
|
|
|
if (!d->resource) {
|
|
|
|
return;
|
|
|
|
}
|
2014-11-26 09:34:23 +00:00
|
|
|
wl_pointer_send_button(d->resource, serial, d->seat->timestamp(), button, WL_POINTER_BUTTON_STATE_RELEASED);
|
2018-02-01 16:46:53 +00:00
|
|
|
d->sendFrame();
|
2014-11-25 12:52:40 +00:00
|
|
|
}
|
|
|
|
|
2019-02-11 16:35:23 +00:00
|
|
|
void PointerInterface::axis(Qt::Orientation orientation, qreal delta, qint32 discreteDelta, PointerAxisSource source)
|
|
|
|
{
|
|
|
|
Q_D();
|
|
|
|
Q_ASSERT(d->focusedSurface);
|
|
|
|
if (!d->resource) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const quint32 version = wl_resource_get_version(d->resource);
|
|
|
|
|
|
|
|
const auto wlOrientation = (orientation == Qt::Vertical)
|
|
|
|
? WL_POINTER_AXIS_VERTICAL_SCROLL
|
|
|
|
: WL_POINTER_AXIS_HORIZONTAL_SCROLL;
|
|
|
|
|
|
|
|
if (source != PointerAxisSource::Unknown && version >= WL_POINTER_AXIS_SOURCE_SINCE_VERSION) {
|
|
|
|
wl_pointer_axis_source wlSource;
|
|
|
|
switch (source) {
|
|
|
|
case PointerAxisSource::Wheel:
|
|
|
|
wlSource = WL_POINTER_AXIS_SOURCE_WHEEL;
|
|
|
|
break;
|
|
|
|
case PointerAxisSource::Finger:
|
|
|
|
wlSource = WL_POINTER_AXIS_SOURCE_FINGER;
|
|
|
|
break;
|
|
|
|
case PointerAxisSource::Continuous:
|
|
|
|
wlSource = WL_POINTER_AXIS_SOURCE_CONTINUOUS;
|
|
|
|
break;
|
|
|
|
case PointerAxisSource::WheelTilt:
|
|
|
|
wlSource = WL_POINTER_AXIS_SOURCE_WHEEL_TILT;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Q_UNREACHABLE();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
wl_pointer_send_axis_source(d->resource, wlSource);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (delta != 0.0) {
|
|
|
|
if (discreteDelta && version >= WL_POINTER_AXIS_DISCRETE_SINCE_VERSION) {
|
|
|
|
wl_pointer_send_axis_discrete(d->resource, wlOrientation, discreteDelta);
|
|
|
|
}
|
|
|
|
wl_pointer_send_axis(d->resource, d->seat->timestamp(), wlOrientation, wl_fixed_from_double(delta));
|
|
|
|
} else if (version >= WL_POINTER_AXIS_STOP_SINCE_VERSION) {
|
|
|
|
wl_pointer_send_axis_stop(d->resource, d->seat->timestamp(), wlOrientation);
|
|
|
|
}
|
|
|
|
|
|
|
|
d->sendFrame();
|
|
|
|
}
|
|
|
|
|
2014-11-25 12:52:40 +00:00
|
|
|
void PointerInterface::axis(Qt::Orientation orientation, quint32 delta)
|
|
|
|
{
|
2014-11-26 10:03:32 +00:00
|
|
|
Q_D();
|
2014-11-26 10:50:52 +00:00
|
|
|
Q_ASSERT(d->focusedSurface);
|
2015-04-20 07:09:23 +00:00
|
|
|
if (!d->resource) {
|
|
|
|
return;
|
|
|
|
}
|
2014-11-26 09:34:23 +00:00
|
|
|
wl_pointer_send_axis(d->resource, d->seat->timestamp(),
|
2014-11-25 12:52:40 +00:00
|
|
|
(orientation == Qt::Vertical) ? WL_POINTER_AXIS_VERTICAL_SCROLL : WL_POINTER_AXIS_HORIZONTAL_SCROLL,
|
|
|
|
wl_fixed_from_int(delta));
|
2018-02-01 16:46:53 +00:00
|
|
|
d->sendFrame();
|
2014-11-25 12:52:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PointerInterface::Private::setCursorCallback(wl_client *client, wl_resource *resource, uint32_t serial,
|
|
|
|
wl_resource *surface, int32_t hotspot_x, int32_t hotspot_y)
|
|
|
|
{
|
2015-02-27 16:36:43 +00:00
|
|
|
auto p = cast<Private>(resource);
|
|
|
|
Q_ASSERT(p->client->client() == client);
|
|
|
|
p->setCursor(serial, SurfaceInterface::get(surface), QPoint(hotspot_x, hotspot_y));
|
2014-11-25 12:52:40 +00:00
|
|
|
}
|
|
|
|
|
2015-02-27 16:36:43 +00:00
|
|
|
Cursor *PointerInterface::cursor() const
|
|
|
|
{
|
|
|
|
Q_D();
|
|
|
|
return d->cursor;
|
|
|
|
}
|
|
|
|
|
2016-10-07 07:07:34 +00:00
|
|
|
void PointerInterface::relativeMotion(const QSizeF &delta, const QSizeF &deltaNonAccelerated, quint64 microseconds)
|
|
|
|
{
|
|
|
|
Q_D();
|
2020-11-03 16:24:03 +00:00
|
|
|
if (d->relativePointersV1.isEmpty()) {
|
2016-10-07 07:07:34 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-11-03 16:24:03 +00:00
|
|
|
for (RelativePointerV1Interface *relativePointer : qAsConst(d->relativePointersV1)) {
|
|
|
|
relativePointer->send_relative_motion(microseconds >> 32, microseconds & 0xffffffff,
|
|
|
|
wl_fixed_from_double(delta.width()),
|
|
|
|
wl_fixed_from_double(delta.height()),
|
|
|
|
wl_fixed_from_double(deltaNonAccelerated.width()),
|
|
|
|
wl_fixed_from_double(deltaNonAccelerated.height()));
|
2016-10-07 07:07:34 +00:00
|
|
|
}
|
2018-05-31 22:28:13 +00:00
|
|
|
d->sendFrame();
|
2016-10-07 07:07:34 +00:00
|
|
|
}
|
|
|
|
|
2014-11-26 10:03:32 +00:00
|
|
|
PointerInterface::Private *PointerInterface::d_func() const
|
2014-11-25 12:52:40 +00:00
|
|
|
{
|
2014-11-26 10:03:32 +00:00
|
|
|
return reinterpret_cast<Private*>(d.data());
|
2014-11-25 12:52:40 +00:00
|
|
|
}
|
|
|
|
|
2016-10-07 07:07:34 +00:00
|
|
|
PointerInterface *PointerInterface::get(wl_resource *native)
|
|
|
|
{
|
|
|
|
return Private::get<PointerInterface>(native);
|
|
|
|
}
|
|
|
|
|
2015-02-27 16:36:43 +00:00
|
|
|
Cursor::Private::Private(Cursor *q, PointerInterface *pointer)
|
|
|
|
: pointer(pointer)
|
|
|
|
, q(q)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void Cursor::Private::update(const QPointer< SurfaceInterface > &s, quint32 serial, const QPoint &p)
|
|
|
|
{
|
|
|
|
bool emitChanged = false;
|
|
|
|
if (enteredSerial != serial) {
|
|
|
|
enteredSerial = serial;
|
|
|
|
emitChanged = true;
|
|
|
|
emit q->enteredSerialChanged();
|
|
|
|
}
|
|
|
|
if (hotspot != p) {
|
|
|
|
hotspot = p;
|
|
|
|
emitChanged = true;
|
|
|
|
emit q->hotspotChanged();
|
|
|
|
}
|
|
|
|
if (surface != s) {
|
|
|
|
if (!surface.isNull()) {
|
|
|
|
QObject::disconnect(surface.data(), &SurfaceInterface::damaged, q, &Cursor::changed);
|
|
|
|
}
|
|
|
|
surface = s;
|
|
|
|
if (!surface.isNull()) {
|
|
|
|
QObject::connect(surface.data(), &SurfaceInterface::damaged, q, &Cursor::changed);
|
|
|
|
}
|
|
|
|
emitChanged = true;
|
|
|
|
emit q->surfaceChanged();
|
|
|
|
}
|
|
|
|
if (emitChanged) {
|
|
|
|
emit q->changed();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Cursor::Cursor(PointerInterface *parent)
|
|
|
|
: QObject(parent)
|
|
|
|
, d(new Private(this, parent))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Cursor::~Cursor() = default;
|
|
|
|
|
|
|
|
quint32 Cursor::enteredSerial() const
|
|
|
|
{
|
|
|
|
return d->enteredSerial;
|
|
|
|
}
|
|
|
|
|
|
|
|
QPoint Cursor::hotspot() const
|
|
|
|
{
|
|
|
|
return d->hotspot;
|
|
|
|
}
|
|
|
|
|
|
|
|
PointerInterface *Cursor::pointer() const
|
|
|
|
{
|
|
|
|
return d->pointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
QPointer< SurfaceInterface > Cursor::surface() const
|
|
|
|
{
|
|
|
|
return d->surface;
|
|
|
|
}
|
|
|
|
|
2014-11-25 12:52:40 +00:00
|
|
|
}
|