From 24b3467584a7a779fd22eab009169a9f24a30952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Thu, 28 Mar 2019 10:30:43 +0100 Subject: [PATCH] clutter: Send touch crossing events only to grab actor When the pointer is grabbed, we send the crossing events that are initiated by this pointer only to the actor that has the grab. For grabbed touch sequences, we always capture and bubble the crossing events right now. Fix this and make grabbed pointers and touch sequences behave the same by sending touch crossing events only to the grab actor. https://gitlab.gnome.org/GNOME/mutter/merge_requests/422 --- clutter/clutter/clutter-event.c | 3 ++ clutter/clutter/clutter-event.h | 1 + clutter/clutter/clutter-input-device.c | 2 ++ clutter/clutter/clutter-main.c | 40 ++++++++++++++++++++++---- 4 files changed, 41 insertions(+), 5 deletions(-) diff --git a/clutter/clutter/clutter-event.c b/clutter/clutter/clutter-event.c index 8e7782df3..8ccf0e8da 100644 --- a/clutter/clutter/clutter-event.c +++ b/clutter/clutter/clutter-event.c @@ -1021,6 +1021,9 @@ clutter_event_get_event_sequence (const ClutterEvent *event) event->type == CLUTTER_TOUCH_END || event->type == CLUTTER_TOUCH_CANCEL) return event->touch.sequence; + else if (event->type == CLUTTER_ENTER || + event->type == CLUTTER_LEAVE) + return event->crossing.sequence; return NULL; } diff --git a/clutter/clutter/clutter-event.h b/clutter/clutter/clutter-event.h index 15596d909..54155cd3d 100644 --- a/clutter/clutter/clutter-event.h +++ b/clutter/clutter/clutter-event.h @@ -269,6 +269,7 @@ struct _ClutterCrossingEvent gfloat x; gfloat y; ClutterInputDevice *device; + ClutterEventSequence *sequence; ClutterActor *related; }; diff --git a/clutter/clutter/clutter-input-device.c b/clutter/clutter/clutter-input-device.c index 0697e3a1a..1375e5a4d 100644 --- a/clutter/clutter/clutter-input-device.c +++ b/clutter/clutter/clutter-input-device.c @@ -834,6 +834,7 @@ _clutter_input_device_set_actor (ClutterInputDevice *device, event->crossing.x = device->current_x; event->crossing.y = device->current_y; event->crossing.related = actor; + event->crossing.sequence = sequence; clutter_event_set_device (event, device); /* we need to make sure that this event is processed @@ -870,6 +871,7 @@ _clutter_input_device_set_actor (ClutterInputDevice *device, event->crossing.y = device->current_y; event->crossing.source = actor; event->crossing.related = old_actor; + event->crossing.sequence = sequence; clutter_event_set_device (event, device); /* see above */ diff --git a/clutter/clutter/clutter-main.c b/clutter/clutter/clutter-main.c index 71ec0d80c..fbae4d995 100644 --- a/clutter/clutter/clutter-main.c +++ b/clutter/clutter/clutter-main.c @@ -2004,6 +2004,36 @@ emit_pointer_event (ClutterEvent *event, } } +static inline void +emit_crossing_event (ClutterEvent *event, + ClutterInputDevice *device) +{ + ClutterMainContext *context = _clutter_context_get_default (); + ClutterEventSequence *sequence = clutter_event_get_event_sequence (event); + ClutterActor *grab_actor = NULL; + + if (_clutter_event_process_filters (event)) + return; + + if (sequence) + { + if (device->sequence_grab_actors != NULL) + grab_actor = g_hash_table_lookup (device->sequence_grab_actors, sequence); + } + else + { + if (context->pointer_grab_actor != NULL) + grab_actor = context->pointer_grab_actor; + else if (device != NULL && device->pointer_grab_actor != NULL) + grab_actor = device->pointer_grab_actor; + } + + if (grab_actor != NULL) + clutter_actor_event (grab_actor, event, FALSE); + else + emit_event_chain (event); +} + static inline void emit_touch_event (ClutterEvent *event, ClutterInputDevice *device) @@ -2177,7 +2207,7 @@ _clutter_process_event_details (ClutterActor *stage, { ClutterActor *actor = NULL; - emit_pointer_event (event, device); + emit_crossing_event (event, device); actor = _clutter_input_device_update (device, NULL, FALSE); if (actor != stage) @@ -2189,12 +2219,12 @@ _clutter_process_event_details (ClutterActor *stage, crossing->crossing.related = stage; crossing->crossing.source = actor; - emit_pointer_event (crossing, device); + emit_crossing_event (crossing, device); clutter_event_free (crossing); } } else - emit_pointer_event (event, device); + emit_crossing_event (event, device); break; case CLUTTER_LEAVE: @@ -2213,10 +2243,10 @@ _clutter_process_event_details (ClutterActor *stage, crossing->crossing.related = stage; crossing->crossing.source = device->cursor_actor; - emit_pointer_event (crossing, device); + emit_crossing_event (crossing, device); clutter_event_free (crossing); } - emit_pointer_event (event, device); + emit_crossing_event (event, device); break; case CLUTTER_DESTROY_NOTIFY: