From a6d406d7bf2476bd311c044bcc666b0d2aacdfe4 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 18 Aug 2021 10:41:33 +1000 Subject: [PATCH] backends/eis: Hook eis into the debug system To be enabled with MUTTER_DEBUG=eis Part-of: --- src/backends/meta-eis.c | 28 ++++++++++++++++++++++++++++ src/core/util.c | 3 +++ src/meta/util.h | 2 ++ 3 files changed, 33 insertions(+) diff --git a/src/backends/meta-eis.c b/src/backends/meta-eis.c index b51c9ceab..15c91a1f5 100644 --- a/src/backends/meta-eis.c +++ b/src/backends/meta-eis.c @@ -27,6 +27,7 @@ #include "backends/meta-eis.h" #include "backends/meta-eis-client.h" #include "clutter/clutter-mutter.h" +#include "meta/util.h" typedef struct _MetaEventSource MetaEventSource; @@ -214,6 +215,30 @@ static GSourceFuncs eis_event_funcs = { NULL }; +static void +eis_logger (struct eis *eis, + enum eis_log_priority priority, + const char *message, + struct eis_log_context *ctx) +{ + switch (priority) + { + case EIS_LOG_PRIORITY_DEBUG: + meta_topic (META_DEBUG_EIS, "%s", message); + break; + case EIS_LOG_PRIORITY_WARNING: + g_warning ("%s", message); + break; + case EIS_LOG_PRIORITY_ERROR: + g_error ("%s", message); + break; + case EIS_LOG_PRIORITY_INFO: + default: + g_info ("%s", message); + break; + } +} + static int try_and_find_free_eis_socket (MetaEis *meta_eis) { @@ -254,6 +279,9 @@ meta_eis_new (MetaBackend *backend) return NULL; } + eis_log_set_handler (meta_eis->eis, eis_logger); + eis_log_set_priority (meta_eis->eis, EIS_LOG_PRIORITY_DEBUG); + fd = eis_get_fd (meta_eis->eis); meta_eis->event_source = meta_event_source_new (meta_eis, fd, &eis_event_funcs); diff --git a/src/core/util.c b/src/core/util.c index 2da997234..05a0dea39 100644 --- a/src/core/util.c +++ b/src/core/util.c @@ -68,6 +68,7 @@ static const GDebugKey meta_debug_keys[] = { { "render", META_DEBUG_RENDER }, { "color", META_DEBUG_COLOR }, { "input-events", META_DEBUG_INPUT_EVENTS }, + { "eis", META_DEBUG_EIS }, }; static gint verbose_topics = 0; @@ -323,6 +324,8 @@ meta_topic_to_string (MetaDebugTopic topic) return "VERBOSE"; case META_DEBUG_INPUT_EVENTS: return "INPUT_EVENTS"; + case META_DEBUG_EIS: + return "EIS"; } return "WM"; diff --git a/src/meta/util.h b/src/meta/util.h index a61b71c88..150f68c2a 100644 --- a/src/meta/util.h +++ b/src/meta/util.h @@ -76,6 +76,7 @@ void meta_fatal (const char *format, * @META_DEBUG_RENDER: native backend rendering * @META_DEBUG_COLOR: color management * @META_DEBUG_INPUT_EVENTS: input events + * @META_DEBUG_EIS: eis state */ typedef enum { @@ -108,6 +109,7 @@ typedef enum META_DEBUG_RENDER = 1 << 25, META_DEBUG_COLOR = 1 << 26, META_DEBUG_INPUT_EVENTS = 1 << 27, + META_DEBUG_EIS = 1 << 28, } MetaDebugTopic; /**