clutter: Add source field to crossing events

The source field was removed from ClutterEvent with commit
b644ea1bce because the preferred way of
getting the event actor is now to use the device/sequence actor from the
stage directly.

With crossing events it's not that easy though, as crossing events
explicitly have a source and related actor that doesn't have to be the
same actor as the device actor. Since we kept around the "related" field
there anyway, let's also introduce a "source" field in
ClutterCrossingEvent and return that actor when get_source() is called
on a crossing event.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2551>
This commit is contained in:
Jonas Dreßler 2022-08-03 19:24:45 +02:00 committed by Marge Bot
parent e5784bf885
commit 4fce0b974b
3 changed files with 6 additions and 0 deletions

View File

@ -509,6 +509,10 @@ clutter_event_get_source (const ClutterEvent *event)
{
g_return_val_if_fail (event != NULL, NULL);
if (event->type == CLUTTER_ENTER ||
event->type == CLUTTER_LEAVE)
return event->crossing.source;
return clutter_stage_get_event_actor (clutter_event_get_stage (event),
event);
}

View File

@ -242,6 +242,7 @@ struct _ClutterCrossingEvent
gfloat y;
ClutterInputDevice *device;
ClutterEventSequence *sequence;
ClutterActor *source;
ClutterActor *related;
};

View File

@ -3400,6 +3400,7 @@ create_crossing_event (ClutterStage *stage,
event->crossing.stage = stage;
event->crossing.x = coords.x;
event->crossing.y = coords.y;
event->crossing.source = source;
event->crossing.related = related;
event->crossing.sequence = sequence;
clutter_event_set_device (event, device);