Commit 8af2a010 authored by Arjen Hiemstra's avatar Arjen Hiemstra
Browse files

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.
parent 1bd496f4
......@@ -1027,7 +1027,8 @@ void SeatInterface::setFocusedTouchSurface(SurfaceInterface *surface, const QPoi
}
d->globalTouch.focus = SeatInterfacePrivate::Touch::Focus();
d->globalTouch.focus.surface = surface;
d->globalTouch.focus.offset = surfacePosition;
setFocusedTouchSurfacePosition(surfacePosition);
if (d->globalTouch.focus.surface) {
d->globalTouch.focus.destroyConnection = connect(surface, &QObject::destroyed, this, [this]() {
if (isTouchSequence()) {
......@@ -1043,6 +1044,8 @@ void SeatInterface::setFocusedTouchSurface(SurfaceInterface *surface, const QPoi
void SeatInterface::setFocusedTouchSurfacePosition(const QPointF &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)
......@@ -1322,7 +1325,7 @@ void SeatInterface::startDrag(AbstractDataSource *dragSource, SurfaceInterface *
d->drag.transformation = d->globalPointer.focus.transformation;
} else if (hasImplicitTouchGrab(dragSerial)) {
d->drag.mode = SeatInterfacePrivate::Drag::Mode::Touch;
// TODO: touch transformation
d->drag.transformation = d->globalTouch.focus.transformation;
} else {
// no implicit grab, abort drag
return;
......@@ -1331,8 +1334,6 @@ void SeatInterface::startDrag(AbstractDataSource *dragSource, SurfaceInterface *
// set initial drag target to ourself
d->drag.surface = originSurface;
// TODO: transformation needs to be either pointer or touch
d->drag.transformation = d->globalPointer.focus.transformation;
d->drag.source = dragSource;
if (dragSource) {
......
......@@ -108,6 +108,7 @@ public:
QMetaObject::Connection destroyConnection;
QPointF offset = QPointF();
QPointF firstTouchPos;
QMatrix4x4 transformation;
};
Focus focus;
QMap<qint32, quint32> ids;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment