[mutter/wip/carlosg/ignore-device-events: 2/4] backends: Do not use stack-allocated ClutterEvents




commit 78c2ad93d7f62623776180dee6ee6ceb77b7a3b2
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Sep 24 17:22:55 2020 +0200

    backends: Do not use stack-allocated ClutterEvents
    
    Use ClutterEvent* and clutter_event_new() to always allocate events.
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1460

 src/backends/meta-stage.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/src/backends/meta-stage.c b/src/backends/meta-stage.c
index 75244de03b..277e25fd91 100644
--- a/src/backends/meta-stage.c
+++ b/src/backends/meta-stage.c
@@ -434,7 +434,7 @@ void
 meta_stage_set_active (MetaStage *stage,
                        gboolean   is_active)
 {
-  ClutterEvent event = { 0 };
+  ClutterEvent *event;
 
   /* Used by the native backend to inform accessibility technologies
    * about when the stage loses and gains input focus.
@@ -446,12 +446,12 @@ meta_stage_set_active (MetaStage *stage,
   if (stage->is_active == is_active)
     return;
 
-  event.type = CLUTTER_STAGE_STATE;
-  clutter_event_set_stage (&event, CLUTTER_STAGE (stage));
-  event.stage_state.changed_mask = CLUTTER_STAGE_STATE_ACTIVATED;
+  event = clutter_event_new (CLUTTER_STAGE_STATE);
+  clutter_event_set_stage (event, CLUTTER_STAGE (stage));
+  event->stage_state.changed_mask = CLUTTER_STAGE_STATE_ACTIVATED;
 
   if (is_active)
-    event.stage_state.new_state = CLUTTER_STAGE_STATE_ACTIVATED;
+    event->stage_state.new_state = CLUTTER_STAGE_STATE_ACTIVATED;
 
   /* Emitting this StageState event will result in the stage getting
    * activated or deactivated (with the activated or deactivated signal
@@ -466,7 +466,8 @@ meta_stage_set_active (MetaStage *stage,
    *
    * See http://bugzilla.gnome.org/746670
    */
-  clutter_stage_event (CLUTTER_STAGE (stage), &event);
+  clutter_stage_event (CLUTTER_STAGE (stage), event);
+  clutter_event_free (event);
 }
 
 MetaStageWatch *


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