From 730da1dbe19b1e84c36751c21a39bccfda9e66b8 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 6 Jun 2020 12:35:47 +0200 Subject: [PATCH] clutter: Pass base event to clutter_input_device_update() So we may fetch coordinates without necessarily querying the device state. Part-of: --- .../clutter/clutter-input-device-private.h | 2 +- clutter/clutter/clutter-input-device.c | 30 ++++++++++++++----- clutter/clutter/clutter-main.c | 8 ++--- clutter/clutter/clutter-stage.c | 3 +- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/clutter/clutter/clutter-input-device-private.h b/clutter/clutter/clutter-input-device-private.h index 0c566a967..7e0055fe9 100644 --- a/clutter/clutter/clutter-input-device-private.h +++ b/clutter/clutter/clutter-input-device-private.h @@ -180,7 +180,7 @@ ClutterActor * clutter_input_device_update (ClutterInputDevice *device, ClutterEventSequence *sequence, ClutterStage *stage, gboolean emit_crossing, - uint32_t time_ms); + ClutterEvent *for_event); CLUTTER_EXPORT void _clutter_input_device_add_event_sequence (ClutterInputDevice *device, ClutterEvent *event); diff --git a/clutter/clutter/clutter-input-device.c b/clutter/clutter/clutter-input-device.c index 6a716002e..1b20a33a8 100644 --- a/clutter/clutter/clutter-input-device.c +++ b/clutter/clutter/clutter-input-device.c @@ -689,6 +689,7 @@ _clutter_input_device_set_actor (ClutterInputDevice *device, ClutterStage *stage, ClutterActor *actor, gboolean emit_crossing, + graphene_point_t coords, uint32_t time_ms) { ClutterActor *old_actor = clutter_input_device_get_actor (device, sequence); @@ -709,8 +710,8 @@ _clutter_input_device_set_actor (ClutterInputDevice *device, event->crossing.flags = 0; event->crossing.stage = stage; event->crossing.source = old_actor; - event->crossing.x = device->current_x; - event->crossing.y = device->current_y; + event->crossing.x = coords.x; + event->crossing.y = coords.y; event->crossing.related = actor; event->crossing.sequence = sequence; clutter_event_set_device (event, device); @@ -745,8 +746,8 @@ _clutter_input_device_set_actor (ClutterInputDevice *device, event->crossing.time = time_ms; event->crossing.flags = 0; event->crossing.stage = stage; - event->crossing.x = device->current_x; - event->crossing.y = device->current_y; + event->crossing.x = coords.x; + event->crossing.y = coords.y; event->crossing.source = actor; event->crossing.related = old_actor; event->crossing.sequence = sequence; @@ -879,17 +880,27 @@ clutter_input_device_update (ClutterInputDevice *device, ClutterEventSequence *sequence, ClutterStage *stage, gboolean emit_crossing, - uint32_t time_ms) + ClutterEvent *for_event) { ClutterActor *new_cursor_actor; ClutterActor *old_cursor_actor; graphene_point_t point = GRAPHENE_POINT_INIT (-1.0f, -1.0f); ClutterInputDeviceType device_type = device->device_type; + uint32_t time_ms; g_assert (device_type != CLUTTER_KEYBOARD_DEVICE && device_type != CLUTTER_PAD_DEVICE); - clutter_input_device_get_coords (device, sequence, &point); + if (for_event) + { + clutter_event_get_coords (for_event, &point.x, &point.y); + time_ms = clutter_event_get_time (for_event); + } + else + { + clutter_input_device_get_coords (device, sequence, &point); + time_ms = CLUTTER_CURRENT_TIME; + } old_cursor_actor = clutter_input_device_get_actor (device, sequence); new_cursor_actor = @@ -918,7 +929,7 @@ clutter_input_device_update (ClutterInputDevice *device, stage, new_cursor_actor, emit_crossing, - time_ms); + point, time_ms); return new_cursor_actor; } @@ -1512,12 +1523,15 @@ _clutter_input_device_remove_event_sequence (ClutterInputDevice *device, g_hash_table_lookup (device->inv_touch_sequence_actors, info->actor); ClutterStage *stage = CLUTTER_STAGE (clutter_actor_get_stage (info->actor)); + graphene_point_t point; sequences = g_list_remove (sequences, sequence); g_hash_table_replace (device->inv_touch_sequence_actors, info->actor, sequences); - _clutter_input_device_set_actor (device, sequence, stage, NULL, TRUE, + clutter_event_get_coords (event, &point.x, &point.y); + _clutter_input_device_set_actor (device, sequence, stage, + NULL, TRUE, point, clutter_event_get_time (event)); } diff --git a/clutter/clutter/clutter-main.c b/clutter/clutter/clutter-main.c index 0606d2e4a..eac636e1c 100644 --- a/clutter/clutter/clutter-main.c +++ b/clutter/clutter/clutter-main.c @@ -1626,7 +1626,7 @@ _clutter_process_event_details (ClutterActor *stage, actor = clutter_input_device_update (device, NULL, CLUTTER_STAGE (stage), FALSE, - clutter_event_get_time (event)); + event); if (actor != stage) { ClutterEvent *crossing; @@ -1777,8 +1777,7 @@ _clutter_process_event_details (ClutterActor *stage, actor = clutter_input_device_update (device, NULL, CLUTTER_STAGE (stage), - TRUE, - clutter_event_get_time (event)); + TRUE, event); if (actor == NULL) break; @@ -1888,8 +1887,7 @@ _clutter_process_event_details (ClutterActor *stage, actor = clutter_input_device_update (device, sequence, CLUTTER_STAGE (stage), - TRUE, - clutter_event_get_time (event)); + TRUE, event); if (actor == NULL) break; diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c index f42778032..a0f9eddca 100644 --- a/clutter/clutter/clutter-stage.c +++ b/clutter/clutter/clutter-stage.c @@ -996,8 +996,7 @@ clutter_stage_update_devices (ClutterStage *stage, for (l = devices; l; l = l->next) { ClutterInputDevice *device = l->data; - clutter_input_device_update (device, NULL, stage, TRUE, - CLUTTER_CURRENT_TIME); + clutter_input_device_update (device, NULL, stage, TRUE, NULL); } }