[mutter] x11/events: Trace X11 event handling



commit d956f63d6715a029613088e65f890fa2e62de447
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Tue Feb 2 23:44:08 2021 +0100

    x11/events: Trace X11 event handling
    
    Traces the type of event, and how much time was spent processing it.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1700>

 src/x11/events.c | 34 ++++++++++++++++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)
---
diff --git a/src/x11/events.c b/src/x11/events.c
index e2297767ed..8882baac4e 100644
--- a/src/x11/events.c
+++ b/src/x11/events.c
@@ -518,6 +518,31 @@ get_extension_event_name (MetaX11Display *x11_display,
   return NULL;
 }
 
+static const char *
+get_event_name (MetaX11Display *x11_display,
+                XEvent         *event)
+{
+  const char *name;
+  XIEvent *input_event;
+
+  if (event->type < GenericEvent)
+    return get_core_event_name (event);
+
+  name = get_extension_event_name (x11_display, event);
+  if (name)
+    return name;
+
+  input_event = get_input_event (x11_display, event);
+  if (input_event)
+    {
+      name = get_xi2_event_name (input_event);
+      if (name)
+        return name;
+    }
+
+  return "Unknown event";
+}
+
 static void
 meta_spew_core_event (MetaX11Display *x11_display,
                       XEvent         *event,
@@ -1850,8 +1875,8 @@ meta_x11_display_handle_xevent (MetaX11Display *x11_display,
   XIEvent *input_event;
   MetaCursorTracker *cursor_tracker;
 
-  COGL_TRACE_BEGIN_SCOPED (MetaX11DisplayHandleXevent,
-                           "X11Display (handle X11 event)");
+  COGL_TRACE_BEGIN (MetaX11DisplayHandleXevent,
+                    "X11Display (handle X11 event)");
 
 #if 0
   meta_spew_event_print (x11_display, event);
@@ -1974,6 +1999,11 @@ meta_x11_display_handle_xevent (MetaX11Display *x11_display,
     }
 
   display->current_time = META_CURRENT_TIME;
+
+  COGL_TRACE_DESCRIBE (MetaX11DisplayHandleXevent,
+                       get_event_name (x11_display, event));
+  COGL_TRACE_END (MetaX11DisplayHandleXevent);
+
   return bypass_gtk;
 }
 


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