From 78534443f5fbf29c5835811ba19a2bd8b9e4e3c4 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Thu, 26 Jul 2007 21:09:50 +0200 Subject: [PATCH] ToggleDebug action which toggles --debug while running. --- Makefile.am | 1 + openbox/actions/all.c | 1 + openbox/actions/all.h | 1 + openbox/actions/toggledebug.c | 23 +++++++++++++++++++++++ openbox/debug.c | 8 ++++---- 5 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 openbox/actions/toggledebug.c diff --git a/Makefile.am b/Makefile.am index 34ee07e4..4252b4e5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -185,6 +185,7 @@ openbox_openbox_SOURCES = \ openbox/actions/shade.c \ openbox/actions/showdesktop.c \ openbox/actions/showmenu.c \ + openbox/actions/toggledebug.c \ openbox/actions/unfocus.c \ openbox/actions.c \ openbox/actions.h \ diff --git a/openbox/actions/all.c b/openbox/actions/all.c index 06858c05..db37840b 100644 --- a/openbox/actions/all.c +++ b/openbox/actions/all.c @@ -38,4 +38,5 @@ void action_all_startup() action_growtoedge_startup(); action_if_startup(); action_focustobottom_startup(); + action_toggledebug_startup(); } diff --git a/openbox/actions/all.h b/openbox/actions/all.h index 5f3f573f..95b69e1f 100644 --- a/openbox/actions/all.h +++ b/openbox/actions/all.h @@ -39,5 +39,6 @@ void action_movetoedge_startup(); void action_growtoedge_startup(); void action_if_startup(); void action_focustobottom_startup(); +void action_toggledebug_startup(); #endif diff --git a/openbox/actions/toggledebug.c b/openbox/actions/toggledebug.c new file mode 100644 index 00000000..e7ad5953 --- /dev/null +++ b/openbox/actions/toggledebug.c @@ -0,0 +1,23 @@ +#include "openbox/actions.h" +#include "openbox/stacking.h" + +static gboolean run_func(ObActionsData *data, gpointer options); +extern gboolean debug_show; + +void action_toggledebug_startup() +{ + actions_register("toggledebug", + NULL, NULL, + run_func, + NULL, NULL); +} + +/* Always return FALSE because its not interactive */ +static gboolean run_func(ObActionsData *data, gpointer options) +{ + if (debug_show) ob_debug("Debug output turned %s\n", "off"); + ob_debug_show_output(!debug_show); + if (debug_show) ob_debug("Debug output turned %s\n", "on"); + + return FALSE; +} diff --git a/openbox/debug.c b/openbox/debug.c index 0fceba48..faabc63c 100644 --- a/openbox/debug.c +++ b/openbox/debug.c @@ -23,18 +23,18 @@ #include #include -static gboolean show; +gboolean debug_show; void ob_debug_show_output(gboolean enable) { - show = enable; + debug_show = enable; } void ob_debug(const gchar *a, ...) { va_list vl; - if (show) { + if (debug_show) { fprintf(stderr, "DEBUG: "); va_start(vl, a); vfprintf(stderr, a, vl); @@ -56,7 +56,7 @@ void ob_debug_type(ObDebugType type, const gchar *a, ...) g_assert(type < OB_DEBUG_TYPE_NUM); - if (show && enabled_types[type]) { + if (debug_show && enabled_types[type]) { switch (type) { case OB_DEBUG_FOCUS: fprintf(stderr, "FOCUS: "); -- 2.34.1