From b1ffd14d623c70057abf99aeff4e6a4ccfd6b90b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 1 Oct 2020 15:05:17 +0200 Subject: [PATCH] main: Parse MUTTER_DEBUG as debug string This makes it possible to run e.g. env MUTTER_DEBUG=input:geometry gnome-shell which will enable the 'META_DEBUG_INPUT' and 'META_DEBUG_GEOMETRY' topics. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1465 --- src/core/main.c | 37 +++++++++++++++++++++++++++++++++++-- src/core/util.c | 6 +++--- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/core/main.c b/src/core/main.c index 06605c5e2..5a20cd6a7 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -98,6 +98,29 @@ #include "backends/native/meta-backend-native.h" #endif +static const GDebugKey meta_debug_keys[] = { + { "focus", META_DEBUG_FOCUS }, + { "workarea", META_DEBUG_WORKAREA }, + { "stack", META_DEBUG_STACK }, + { "sm", META_DEBUG_SM }, + { "events", META_DEBUG_EVENTS }, + { "window-state", META_DEBUG_WINDOW_STATE }, + { "window-ops", META_DEBUG_WINDOW_OPS }, + { "geometry", META_DEBUG_GEOMETRY }, + { "placement", META_DEBUG_PLACEMENT }, + { "ping", META_DEBUG_PING }, + { "keybindings", META_DEBUG_KEYBINDINGS }, + { "sync", META_DEBUG_SYNC }, + { "startup", META_DEBUG_STARTUP }, + { "prefs", META_DEBUG_PREFS }, + { "groups", META_DEBUG_GROUPS }, + { "resizing", META_DEBUG_RESIZING }, + { "shapes", META_DEBUG_SHAPES }, + { "edge-resistance", META_DEBUG_EDGE_RESISTANCE }, + { "dbus", META_DEBUG_DBUS }, + { "input", META_DEBUG_INPUT }, +}; + /* * The exit code we'll return to our parent process when we eventually die. */ @@ -535,6 +558,7 @@ meta_init (void) { struct sigaction act; sigset_t empty_mask; + const char *debug_env; MetaCompositorType compositor_type; GType backend_gtype; @@ -559,8 +583,17 @@ meta_init (void) if (g_getenv ("MUTTER_VERBOSE")) meta_set_verbose (TRUE); - if (g_getenv ("MUTTER_DEBUG")) - meta_set_debugging (TRUE); + + debug_env = g_getenv ("MUTTER_DEBUG"); + if (debug_env) + { + MetaDebugTopic topics; + + topics = g_parse_debug_string (debug_env, + meta_debug_keys, + G_N_ELEMENTS (meta_debug_keys)); + meta_add_verbose_topic (topics); + } if (_compositor_configuration_overridden) { diff --git a/src/core/util.c b/src/core/util.c index 2b3dc286c..4d9d8acb3 100644 --- a/src/core/util.c +++ b/src/core/util.c @@ -116,9 +116,6 @@ meta_set_verbose (gboolean setting) #ifndef WITH_VERBOSE_MODE if (setting) meta_fatal (_("Mutter was compiled without support for verbose mode\n")); -#else - if (setting) - ensure_logfile (); #endif if (setting) @@ -139,6 +136,9 @@ meta_add_verbose_topic (MetaDebugTopic topic) { if (verbose_topics == META_DEBUG_VERBOSE) return; + + ensure_logfile (); + if (topic == META_DEBUG_VERBOSE) verbose_topics = META_DEBUG_VERBOSE; else