[mutter] clutter: Add source field to crossing events



commit 4fce0b974b923ec1c272456c5360bb5c35428b8e
Author: Jonas Dreßler <verdre v0yd nl>
Date:   Wed Aug 3 19:24:45 2022 +0200

    clutter: Add source field to crossing events
    
    The source field was removed from ClutterEvent with commit
    b644ea1bcebfef2fb3ed4b6b7de602000cece33b 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>

 clutter/clutter/clutter-event.c | 4 ++++
 clutter/clutter/clutter-event.h | 1 +
 clutter/clutter/clutter-stage.c | 1 +
 3 files changed, 6 insertions(+)
---
diff --git a/clutter/clutter/clutter-event.c b/clutter/clutter/clutter-event.c
index 6d2c19ff29..667fe8c968 100644
--- a/clutter/clutter/clutter-event.c
+++ b/clutter/clutter/clutter-event.c
@@ -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);
 }
diff --git a/clutter/clutter/clutter-event.h b/clutter/clutter/clutter-event.h
index 1220ef21d3..132f968203 100644
--- a/clutter/clutter/clutter-event.h
+++ b/clutter/clutter/clutter-event.h
@@ -242,6 +242,7 @@ struct _ClutterCrossingEvent
   gfloat y;
   ClutterInputDevice *device;
   ClutterEventSequence *sequence;
+  ClutterActor *source;
   ClutterActor *related;
 };
 
diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c
index 714883d3a3..56919c827a 100644
--- a/clutter/clutter/clutter-stage.c
+++ b/clutter/clutter/clutter-stage.c
@@ -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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]