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
This commit is contained in:
Jonas Ådahl 2020-10-01 15:05:17 +02:00 committed by Georges Basile Stavracas Neto
parent 24c374ffb2
commit b1ffd14d62
2 changed files with 38 additions and 5 deletions

View File

@ -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)
{

View File

@ -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