From d956f63d6715a029613088e65f890fa2e62de447 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 2 Feb 2021 23:44:08 +0100 Subject: [PATCH] x11/events: Trace X11 event handling Traces the type of event, and how much time was spent processing it. Part-of: --- 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 e2297767e..8882baac4 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; }