lx_emul: emit TOUCH_RELEASE events with proper ID

When emitting TOUCH_RELEASE events, we have to make sure that the
release events refer to the corresponding ID of the preceding TOUCH
event(s).

Fixes #5446
This commit is contained in:
Johannes Schlatow 2025-02-05 10:49:55 +01:00 committed by Christian Helmuth
parent b6cd11abc8
commit 7a158e1e40

View File

@ -117,10 +117,11 @@ enum evdev_motion evdev_motion(struct input_dev const *dev)
struct evdev_mt_slot
{
int id; /* -1 means unused */
int x, y, ox, oy;
bool touch;
int finger;
int x, y, ox, oy;
};
#define INIT_MT_SLOT (struct evdev_mt_slot){ -1, -1, -1, -1, -1 }
#define INIT_MT_SLOT (struct evdev_mt_slot){ false, -1, -1, -1, -1, -1 }
/*
@ -298,7 +299,8 @@ static bool record_mt(struct evdev_mt *mt, struct input_value const *v)
case ABS_MT_TRACKING_ID:
if (mt->cur_slot < mt->num_slots) {
mt->slots[mt->cur_slot].id = v->value >= 0 ? mt->cur_slot : -1;
mt->slots[mt->cur_slot].touch = v->value >= 0;
mt->slots[mt->cur_slot].finger = mt->cur_slot;
mt->pending = true;
}
break;
@ -541,7 +543,7 @@ static void submit_touchpad(struct evdev *evdev, struct genode_event_submit *sub
if (mt->pending) {
for_each_mt_slot(slot, mt) {
if (slot->id == -1) {
if (!slot->touch) {
*slot = INIT_MT_SLOT;
continue;
}
@ -573,8 +575,8 @@ static void submit_touchscreen(struct evdev *evdev, struct genode_event_submit *
if (mt->pending) {
for_each_mt_slot(slot, mt) {
if (slot->id == -1 && slot->ox != -1 && slot->oy != -1) {
submit->touch_release(submit, slot->id);
if (!slot->touch && slot->ox != -1 && slot->oy != -1) {
submit->touch_release(submit, slot->finger);
*slot = INIT_MT_SLOT;
continue;
@ -586,7 +588,7 @@ static void submit_touchscreen(struct evdev *evdev, struct genode_event_submit *
if (slot->x != -1 && slot->y != -1) {
struct genode_event_touch_args args = {
.finger = slot->id,
.finger = slot->finger,
.xpos = slot->x,
.ypos = slot->y,
.width = 1