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 Graesslin <mgraesslin@kde.org>
This commit is contained in:
parent
42a1e1e99e
commit
7fd15ea066
1 changed files with 30 additions and 1 deletions
|
@ -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,6 +884,15 @@ 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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue