clutter: Pass base event to clutter_input_device_update()

So we may fetch coordinates without necessarily querying the device
state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
This commit is contained in:
Carlos Garnacho 2020-06-06 12:35:47 +02:00 committed by Marge Bot
parent 932a5cab09
commit 730da1dbe1
4 changed files with 27 additions and 16 deletions

View File

@ -180,7 +180,7 @@ ClutterActor * clutter_input_device_update (ClutterInputDevice *device,
ClutterEventSequence *sequence, ClutterEventSequence *sequence,
ClutterStage *stage, ClutterStage *stage,
gboolean emit_crossing, gboolean emit_crossing,
uint32_t time_ms); ClutterEvent *for_event);
CLUTTER_EXPORT CLUTTER_EXPORT
void _clutter_input_device_add_event_sequence (ClutterInputDevice *device, void _clutter_input_device_add_event_sequence (ClutterInputDevice *device,
ClutterEvent *event); ClutterEvent *event);

View File

@ -689,6 +689,7 @@ _clutter_input_device_set_actor (ClutterInputDevice *device,
ClutterStage *stage, ClutterStage *stage,
ClutterActor *actor, ClutterActor *actor,
gboolean emit_crossing, gboolean emit_crossing,
graphene_point_t coords,
uint32_t time_ms) uint32_t time_ms)
{ {
ClutterActor *old_actor = clutter_input_device_get_actor (device, sequence); 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.flags = 0;
event->crossing.stage = stage; event->crossing.stage = stage;
event->crossing.source = old_actor; event->crossing.source = old_actor;
event->crossing.x = device->current_x; event->crossing.x = coords.x;
event->crossing.y = device->current_y; event->crossing.y = coords.y;
event->crossing.related = actor; event->crossing.related = actor;
event->crossing.sequence = sequence; event->crossing.sequence = sequence;
clutter_event_set_device (event, device); clutter_event_set_device (event, device);
@ -745,8 +746,8 @@ _clutter_input_device_set_actor (ClutterInputDevice *device,
event->crossing.time = time_ms; event->crossing.time = time_ms;
event->crossing.flags = 0; event->crossing.flags = 0;
event->crossing.stage = stage; event->crossing.stage = stage;
event->crossing.x = device->current_x; event->crossing.x = coords.x;
event->crossing.y = device->current_y; event->crossing.y = coords.y;
event->crossing.source = actor; event->crossing.source = actor;
event->crossing.related = old_actor; event->crossing.related = old_actor;
event->crossing.sequence = sequence; event->crossing.sequence = sequence;
@ -879,17 +880,27 @@ clutter_input_device_update (ClutterInputDevice *device,
ClutterEventSequence *sequence, ClutterEventSequence *sequence,
ClutterStage *stage, ClutterStage *stage,
gboolean emit_crossing, gboolean emit_crossing,
uint32_t time_ms) ClutterEvent *for_event)
{ {
ClutterActor *new_cursor_actor; ClutterActor *new_cursor_actor;
ClutterActor *old_cursor_actor; ClutterActor *old_cursor_actor;
graphene_point_t point = GRAPHENE_POINT_INIT (-1.0f, -1.0f); graphene_point_t point = GRAPHENE_POINT_INIT (-1.0f, -1.0f);
ClutterInputDeviceType device_type = device->device_type; ClutterInputDeviceType device_type = device->device_type;
uint32_t time_ms;
g_assert (device_type != CLUTTER_KEYBOARD_DEVICE && g_assert (device_type != CLUTTER_KEYBOARD_DEVICE &&
device_type != CLUTTER_PAD_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); old_cursor_actor = clutter_input_device_get_actor (device, sequence);
new_cursor_actor = new_cursor_actor =
@ -918,7 +929,7 @@ clutter_input_device_update (ClutterInputDevice *device,
stage, stage,
new_cursor_actor, new_cursor_actor,
emit_crossing, emit_crossing,
time_ms); point, time_ms);
return new_cursor_actor; 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); g_hash_table_lookup (device->inv_touch_sequence_actors, info->actor);
ClutterStage *stage = ClutterStage *stage =
CLUTTER_STAGE (clutter_actor_get_stage (info->actor)); CLUTTER_STAGE (clutter_actor_get_stage (info->actor));
graphene_point_t point;
sequences = g_list_remove (sequences, sequence); sequences = g_list_remove (sequences, sequence);
g_hash_table_replace (device->inv_touch_sequence_actors, g_hash_table_replace (device->inv_touch_sequence_actors,
info->actor, sequences); 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)); clutter_event_get_time (event));
} }

View File

@ -1626,7 +1626,7 @@ _clutter_process_event_details (ClutterActor *stage,
actor = clutter_input_device_update (device, NULL, actor = clutter_input_device_update (device, NULL,
CLUTTER_STAGE (stage), FALSE, CLUTTER_STAGE (stage), FALSE,
clutter_event_get_time (event)); event);
if (actor != stage) if (actor != stage)
{ {
ClutterEvent *crossing; ClutterEvent *crossing;
@ -1777,8 +1777,7 @@ _clutter_process_event_details (ClutterActor *stage,
actor = clutter_input_device_update (device, NULL, actor = clutter_input_device_update (device, NULL,
CLUTTER_STAGE (stage), CLUTTER_STAGE (stage),
TRUE, TRUE, event);
clutter_event_get_time (event));
if (actor == NULL) if (actor == NULL)
break; break;
@ -1888,8 +1887,7 @@ _clutter_process_event_details (ClutterActor *stage,
actor = clutter_input_device_update (device, sequence, actor = clutter_input_device_update (device, sequence,
CLUTTER_STAGE (stage), CLUTTER_STAGE (stage),
TRUE, TRUE, event);
clutter_event_get_time (event));
if (actor == NULL) if (actor == NULL)
break; break;

View File

@ -996,8 +996,7 @@ clutter_stage_update_devices (ClutterStage *stage,
for (l = devices; l; l = l->next) for (l = devices; l; l = l->next)
{ {
ClutterInputDevice *device = l->data; ClutterInputDevice *device = l->data;
clutter_input_device_update (device, NULL, stage, TRUE, clutter_input_device_update (device, NULL, stage, TRUE, NULL);
CLUTTER_CURRENT_TIME);
} }
} }