Implement drag surface transformation for touch events
Reusing the pointer transformation causes drag with touch to send completely incorrect coordinates. So implement the "TODO" item about surface transformation for touch, so we send correct drag events for touch.
This commit is contained in:
parent
1bd496f42b
commit
8af2a010c7
2 changed files with 6 additions and 4 deletions
|
@ -1027,7 +1027,8 @@ void SeatInterface::setFocusedTouchSurface(SurfaceInterface *surface, const QPoi
|
||||||
}
|
}
|
||||||
d->globalTouch.focus = SeatInterfacePrivate::Touch::Focus();
|
d->globalTouch.focus = SeatInterfacePrivate::Touch::Focus();
|
||||||
d->globalTouch.focus.surface = surface;
|
d->globalTouch.focus.surface = surface;
|
||||||
d->globalTouch.focus.offset = surfacePosition;
|
setFocusedTouchSurfacePosition(surfacePosition);
|
||||||
|
|
||||||
if (d->globalTouch.focus.surface) {
|
if (d->globalTouch.focus.surface) {
|
||||||
d->globalTouch.focus.destroyConnection = connect(surface, &QObject::destroyed, this, [this]() {
|
d->globalTouch.focus.destroyConnection = connect(surface, &QObject::destroyed, this, [this]() {
|
||||||
if (isTouchSequence()) {
|
if (isTouchSequence()) {
|
||||||
|
@ -1043,6 +1044,8 @@ void SeatInterface::setFocusedTouchSurface(SurfaceInterface *surface, const QPoi
|
||||||
void SeatInterface::setFocusedTouchSurfacePosition(const QPointF &surfacePosition)
|
void SeatInterface::setFocusedTouchSurfacePosition(const QPointF &surfacePosition)
|
||||||
{
|
{
|
||||||
d->globalTouch.focus.offset = surfacePosition;
|
d->globalTouch.focus.offset = surfacePosition;
|
||||||
|
d->globalTouch.focus.transformation = QMatrix4x4();
|
||||||
|
d->globalTouch.focus.transformation.translate(-surfacePosition.x(), -surfacePosition.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SeatInterface::notifyTouchDown(qint32 id, const QPointF &globalPosition)
|
void SeatInterface::notifyTouchDown(qint32 id, const QPointF &globalPosition)
|
||||||
|
@ -1322,7 +1325,7 @@ void SeatInterface::startDrag(AbstractDataSource *dragSource, SurfaceInterface *
|
||||||
d->drag.transformation = d->globalPointer.focus.transformation;
|
d->drag.transformation = d->globalPointer.focus.transformation;
|
||||||
} else if (hasImplicitTouchGrab(dragSerial)) {
|
} else if (hasImplicitTouchGrab(dragSerial)) {
|
||||||
d->drag.mode = SeatInterfacePrivate::Drag::Mode::Touch;
|
d->drag.mode = SeatInterfacePrivate::Drag::Mode::Touch;
|
||||||
// TODO: touch transformation
|
d->drag.transformation = d->globalTouch.focus.transformation;
|
||||||
} else {
|
} else {
|
||||||
// no implicit grab, abort drag
|
// no implicit grab, abort drag
|
||||||
return;
|
return;
|
||||||
|
@ -1331,8 +1334,6 @@ void SeatInterface::startDrag(AbstractDataSource *dragSource, SurfaceInterface *
|
||||||
|
|
||||||
// set initial drag target to ourself
|
// set initial drag target to ourself
|
||||||
d->drag.surface = originSurface;
|
d->drag.surface = originSurface;
|
||||||
// TODO: transformation needs to be either pointer or touch
|
|
||||||
d->drag.transformation = d->globalPointer.focus.transformation;
|
|
||||||
|
|
||||||
d->drag.source = dragSource;
|
d->drag.source = dragSource;
|
||||||
if (dragSource) {
|
if (dragSource) {
|
||||||
|
|
|
@ -108,6 +108,7 @@ public:
|
||||||
QMetaObject::Connection destroyConnection;
|
QMetaObject::Connection destroyConnection;
|
||||||
QPointF offset = QPointF();
|
QPointF offset = QPointF();
|
||||||
QPointF firstTouchPos;
|
QPointF firstTouchPos;
|
||||||
|
QMatrix4x4 transformation;
|
||||||
};
|
};
|
||||||
Focus focus;
|
Focus focus;
|
||||||
QMap<qint32, quint32> ids;
|
QMap<qint32, quint32> ids;
|
||||||
|
|
Loading…
Reference in a new issue