Commit 7fd15ea0 authored by Marco Martin's avatar Marco Martin
Browse files

generate fake mouseevents on touch for xwayland



on xwayland clients, send mouse press, move and release
corresponding to touchDown, move and release
this gives a very basic touchscreen support on
xwayland clients

reviewed-by: Martin Flöser's avatarMartin Graesslin <mgraesslin@kde.org>
parent 42a1e1e9
......@@ -862,7 +862,19 @@ qint32 SeatInterface::touchDown(const QPointF &globalPosition)
const quint32 serial = display()->nextSerial();
if (d->touchInterface.focus.touch && d->touchInterface.focus.surface) {
d->touchInterface.focus.touch->down(id, serial, globalPosition - d->touchInterface.focus.offset);
} else if (id == 0 && focusedTouchSurface()) {
auto p = d->pointerForSurface(focusedTouchSurface());
if (!p) {
return id;
}
const QPointF pos = globalPosition - d->touchInterface.focus.offset;
wl_pointer_send_enter(p->resource(), serial,
focusedTouchSurface()->resource(),
wl_fixed_from_double(pos.x()), wl_fixed_from_double(pos.y()));
wl_pointer_send_button(p->resource(), serial, timestamp(), BTN_LEFT, WL_POINTER_BUTTON_STATE_PRESSED);
}
d->touchInterface.ids << id;
return id;
}
......@@ -872,7 +884,16 @@ void SeatInterface::touchMove(qint32 id, const QPointF &globalPosition)
Q_D();
if (d->touchInterface.focus.touch && d->touchInterface.focus.surface) {
d->touchInterface.focus.touch->move(id, globalPosition - d->touchInterface.focus.offset);
}
} else if (id == 0 && focusedTouchSurface()) {
auto p = d->pointerForSurface(focusedTouchSurface());
if (!p) {
return;
}
const QPointF pos = globalPosition - d->touchInterface.focus.offset;
wl_pointer_send_motion(p->resource(), timestamp(),
wl_fixed_from_double(pos.x()), wl_fixed_from_double(pos.y()));
}
}
void SeatInterface::touchUp(qint32 id)
......@@ -881,6 +902,14 @@ void SeatInterface::touchUp(qint32 id)
Q_ASSERT(d->touchInterface.ids.contains(id));
if (d->touchInterface.focus.touch && d->touchInterface.focus.surface) {
d->touchInterface.focus.touch->up(id, display()->nextSerial());
} else if (id == 0 && focusedTouchSurface()) {
const quint32 serial = display()->nextSerial();
auto p = d->pointerForSurface(focusedTouchSurface());
if (!p) {
return;
}
wl_pointer_send_button(p->resource(), serial, timestamp(), BTN_LEFT, WL_POINTER_BUTTON_STATE_RELEASED);
}
d->touchInterface.ids.removeAll(id);
}
......
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