add cancelable property to the TouchEvent (#35713)

* add `cancelable` property to the `TouchEvent`
set cancellable = false when sending move events to script, if the first touch_move event did not cancel it

Signed-off-by: kongbai1996 <1782765876@qq.com>

* modified review commentss

Signed-off-by: kongbai1996 <1782765876@qq.com>

---------

Signed-off-by: kongbai1996 <1782765876@qq.com>
This commit is contained in:
Bi Fuguo 2025-03-02 16:12:26 +08:00 committed by GitHub
parent 67bd557f30
commit 929f87f598
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 2 deletions

View file

@ -1396,7 +1396,7 @@ impl IOCompositor {
self.send_touch_event(event);
}
fn on_touch_move(&mut self, event: TouchEvent) {
fn on_touch_move(&mut self, mut event: TouchEvent) {
let action: TouchMoveAction = self.touch_handler.on_touch_move(event.id, event.point);
if TouchMoveAction::NoAction != action {
// if first move processed and allowed, we directly process the move event,
@ -1405,6 +1405,8 @@ impl IOCompositor {
.touch_handler
.move_allowed(self.touch_handler.current_sequence_id)
{
// https://w3c.github.io/touch-events/#cancelability
event.disable_cancelable();
match action {
TouchMoveAction::Scroll(delta, point) => self.on_scroll_window_event(
ScrollLocation::Delta(LayoutVector2D::from_untyped(delta.to_untyped())),