[mutter] events: Only get MetaWaylandCompositor once



commit 8a11069dcaa97027ccfbd053e804dd2968fddd82
Author: Jonas Dreßler <verdre v0yd nl>
Date:   Wed Feb 23 16:13:17 2022 +0100

    events: Only get MetaWaylandCompositor once
    
    We get the MetaWaylandCompositor a bunch of times, but we can do with
    getting it only once and then also replace the is_wayland_compositor()
    checks with a if (wayland_compositor).
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2308>

 src/core/events.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
---
diff --git a/src/core/events.c b/src/core/events.c
index 81911fd07c..853c86f772 100644
--- a/src/core/events.c
+++ b/src/core/events.c
@@ -220,6 +220,12 @@ meta_display_handle_event (MetaDisplay        *display,
   ClutterEventSequence *sequence;
   gboolean has_grab;
 
+#ifdef HAVE_WAYLAND
+  MetaWaylandCompositor *wayland_compositor = NULL;
+  if (meta_is_wayland_compositor ())
+    wayland_compositor = meta_wayland_compositor_get_default ();
+#endif
+
   has_grab = stage_has_grab (display);
 
   if (display->grabbed_in_clutter != has_grab)
@@ -227,7 +233,7 @@ meta_display_handle_event (MetaDisplay        *display,
       MetaCompositor *compositor = meta_display_get_compositor (display);
 
 #ifdef HAVE_WAYLAND
-      if (meta_is_wayland_compositor ())
+      if (wayland_compositor)
         meta_display_sync_wayland_input_focus (display);
 #endif
 
@@ -268,12 +274,8 @@ meta_display_handle_event (MetaDisplay        *display,
     }
 
 #ifdef HAVE_WAYLAND
-  MetaWaylandCompositor *compositor = NULL;
-  if (meta_is_wayland_compositor ())
-    {
-      compositor = meta_wayland_compositor_get_default ();
-      meta_wayland_compositor_update (compositor, event);
-    }
+  if (wayland_compositor)
+    meta_wayland_compositor_update (wayland_compositor, event);
 #endif
 
   if (event->type == CLUTTER_PAD_BUTTON_PRESS ||
@@ -312,7 +314,7 @@ meta_display_handle_event (MetaDisplay        *display,
     handle_idletime_for_event (event);
 
 #ifdef HAVE_WAYLAND
-  if (meta_is_wayland_compositor () && event->type == CLUTTER_MOTION)
+  if (wayland_compositor && event->type == CLUTTER_MOTION)
     {
       MetaCursorRenderer *cursor_renderer;
       ClutterInputDevice *device;
@@ -513,13 +515,13 @@ meta_display_handle_event (MetaDisplay        *display,
     bypass_clutter = !bypass_wayland;
 
 #ifdef HAVE_WAYLAND
-  if (compositor && !bypass_wayland)
+  if (wayland_compositor && !bypass_wayland)
     {
       if (window && event->type == CLUTTER_MOTION &&
           event->any.time != CLUTTER_CURRENT_TIME)
         meta_window_check_alive_on_event (window, event->any.time);
 
-      if (meta_wayland_compositor_handle_event (compositor, event))
+      if (meta_wayland_compositor_handle_event (wayland_compositor, event))
         bypass_clutter = TRUE;
     }
 #endif


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