From ce0b41c8472135898a553d6d649d852beb80cffb Mon Sep 17 00:00:00 2001 From: Henrik Kinnunen Date: Wed, 17 Mar 2010 16:35:07 +0100 Subject: Changed #ifdef DEBUG ... cerr << to using fbdbg. This will reduce the number of #ifdef DEBUG for simple debug messages. include "Debug.hh" and use fbdbg instead of cerr for debug. --- src/Debug.hh | 13 +++++ src/Ewmh.cc | 37 ++++++------ src/FocusControl.cc | 15 +++-- src/Gnome.cc | 99 +++++++++++-------------------- src/IconbarTool.cc | 16 ++--- src/Keys.cc | 6 +- src/Makefile.am | 1 + src/Remember.cc | 21 +++---- src/RootTheme.cc | 2 - src/Screen.cc | 46 +++++++-------- src/Slit.cc | 17 ++---- src/SystemTray.cc | 43 ++++++-------- src/WinClient.cc | 42 +++++-------- src/Window.cc | 165 ++++++++++++++++++++-------------------------------- src/Workspace.cc | 6 -- src/Xutil.cc | 15 ++--- src/fluxbox.cc | 38 +++++------- 17 files changed, 235 insertions(+), 347 deletions(-) create mode 100644 src/Debug.hh diff --git a/src/Debug.hh b/src/Debug.hh new file mode 100644 index 0000000..3688b52 --- /dev/null +++ b/src/Debug.hh @@ -0,0 +1,13 @@ +#ifndef DEBUG_HH +#define DEBUG_HH + +#include "config.h" +#include + +#ifdef DEBUG +#define fbdbg std::cerr<<__FILE__<<"("<<__LINE__<< "): " +#else +#define fbdbg if (false) std::cerr +#endif // DEBUG + +#endif // DEBUG_HH diff --git a/src/Ewmh.cc b/src/Ewmh.cc index fb1b832..b4fafc3 100644 --- a/src/Ewmh.cc +++ b/src/Ewmh.cc @@ -29,6 +29,7 @@ #include "fluxbox.hh" #include "FbWinFrameTheme.hh" #include "FocusControl.hh" +#include "Debug.hh" #include "FbTk/App.hh" #include "FbTk/FbWindow.hh" @@ -129,10 +130,10 @@ void extractNetWmIcon(Atom net_wm_icon, WinClient& winclient) { // actually there is some data in _NET_WM_ICON nr_icon_data = nr_bytes_left / sizeof(CARD32); -#ifdef DEBUG - std::cerr << "extractNetWmIcon: " << winclient.title() << "\n"; - std::cerr << "nr_icon_data: " << nr_icon_data << "\n"; -#endif + + fbdbg << "extractNetWmIcon: " << winclient.title() << "\n"; + fbdbg << "nr_icon_data: " << nr_icon_data << "\n"; + // read all the icons stored in _NET_WM_ICON if (raw_data) XFree(raw_data); @@ -144,9 +145,9 @@ void extractNetWmIcon(Atom net_wm_icon, WinClient& winclient) { return; } -#ifdef DEBUG - std::cerr << "nr_read: " << nr_read << "|" << nr_bytes_left << "\n"; -#endif + + fbdbg << "nr_read: " << nr_read << "|" << nr_bytes_left << "\n"; + } IconContainer icon_data; // stores all available data, sorted by size (width x height) @@ -161,28 +162,26 @@ void extractNetWmIcon(Atom net_wm_icon, WinClient& winclient) { width = raw_data[i++]; if (width >= nr_icon_data) { -#ifdef DEBUG - std::cerr << "Ewmh.cc extractNetWmIcon found strange _NET_WM_ICON width (" + + fbdbg << "Ewmh.cc extractNetWmIcon found strange _NET_WM_ICON width (" << width << ") for " << winclient.title() << "\n"; -#endif break; } height = raw_data[i++]; if (height >= nr_icon_data) { -#ifdef DEBUG - std::cerr << "Ewmh.cc extractNetWmIcon found strange _NET_WM_ICON height (" + + fbdbg << "Ewmh.cc extractNetWmIcon found strange _NET_WM_ICON height (" << height << ") for " << winclient.title() << "\n"; -#endif + break; } // strange values stored in the NETWM_ICON if (i + width * height > nr_icon_data) { -#ifdef DEBUG - std::cerr << "Ewmh.cc extractNetWmIcon found strange _NET_WM_ICON dimensions (" + fbdbg << "Ewmh.cc extractNetWmIcon found strange _NET_WM_ICON dimensions (" << width << "x" << height << ")for " << winclient.title() << "\n"; -#endif + break; } @@ -1190,9 +1189,9 @@ bool Ewmh::checkClientMessage(const XClientMessageEvent &ce, win_gravity, winclient->old_bw); return true; } else if (ce.message_type == m_net->restack_window) { -#ifndef DEBUG - cerr << "Ewmh: restack window" << endl; -#endif // DEBUG + + fbdbg << "Ewmh: restack window" << endl; + if (winclient == 0 || winclient->fbwindow() == 0) return true; diff --git a/src/FocusControl.cc b/src/FocusControl.cc index bf79d3e..3ba9dc6 100644 --- a/src/FocusControl.cc +++ b/src/FocusControl.cc @@ -28,6 +28,7 @@ #include "Workspace.hh" #include "fluxbox.hh" #include "FbWinFrameTheme.hh" +#include "Debug.hh" #include "FbTk/EventManager.hh" @@ -39,7 +40,6 @@ #include #endif -using std::cerr; using std::endl; using std::string; @@ -551,14 +551,13 @@ void FocusControl::setFocusedWindow(WinClient *client) { FocusControl::focusedWindow() ? &FocusControl::focusedWindow()->screen() : 0; -#ifdef DEBUG - cerr<<"------------------"<title()<title()< #ifdef HAVE_CSTRING @@ -39,11 +40,8 @@ using std::cerr; using std::endl; using std::list; - -#ifdef DEBUG using std::hex; using std::dec; -#endif // DEBUG Gnome::Gnome() { createAtoms(); @@ -142,14 +140,10 @@ void Gnome::setupFrame(FluxboxWindow &win) { bool Gnome::propertyNotify(WinClient &winclient, Atom the_property) { if (the_property == m_gnome_wm_win_state) { -#ifdef DEBUG - cerr<<__FILE__<<"("<<__FUNCTION__<<"): _WIN_STATE"<fbwindow()) { //get new states @@ -357,15 +349,9 @@ bool Gnome::checkClientMessage(const XClientMessageEvent &ce, BScreen * screen, enableUpdate(); } } else if (ce.message_type == m_gnome_wm_win_hints) { -#ifdef DEBUG - cerr<<__FILE__<<"("<<__LINE__<<"): _WIN_HINTS"<fbwindow()) setLayer(winclient->fbwindow(), ce.data.l[0]); } else @@ -375,32 +361,29 @@ bool Gnome::checkClientMessage(const XClientMessageEvent &ce, BScreen * screen, } void Gnome::setState(FluxboxWindow *win, int state) { -#ifdef DEBUG - cerr<<"Gnome: state=0x"<isStuck()) win->stick(); } else if (win->isStuck()) win->stick(); if (state & WIN_STATE_MINIMIZED) { -#ifdef DEBUG - cerr<<"Gnome state: Minimized"<isIconic()) win->iconify(); } else if (win->isIconic()) win->deiconify(true); if (state & WIN_STATE_SHADED) { -#ifdef DEBUG - cerr<<"Gnome state: Shade"<isShaded()) win->shade(); } else if (win->isShaded()) @@ -436,53 +419,39 @@ void Gnome::setLayer(FluxboxWindow *win, int layer) { switch (layer) { case WIN_LAYER_DESKTOP: -#ifdef DEBUG - cerr<<"Gnome::setLayer("<title()<<", WIN_LAYER_DESKTOP)"<title()<<", WIN_LAYER_DESKTOP)"<title()<<", WIN_LAYER_BELOW)"<title()<<", WIN_LAYER_BELOW)"<title()<<", WIN_LAYER_NORMAL)"<title()<<", WIN_LAYER_NORMAL)"<title()<<", WIN_LAYER_ONTOP)"<title()<<", WIN_LAYER_ONTOP)"<title()<<", WIN_LAYER_DOCK)"<title()<<", WIN_LAYER_DOCK)"<title()<<", WIN_LAYER_ABOVE_DOCK)"<title()<<", WIN_LAYER_ABOVE_DOCK)"<title()<<", WIN_LAYER_MENU)"<title()<<", WIN_LAYER_MENU)"<title()<<", "<title()<<", "<second; @@ -546,9 +542,9 @@ IconButton *IconbarTool::makeButton(Focusable &win) { FluxboxWindow *fbwin = win.fbwindow(); if (!fbwin || fbwin->clientList().empty()) return 0; -#ifdef DEBUG - cerr<<"IconbarTool::addWindow(0x"<<&win<<" title = "< '"< '"<execute(); delete tmp_exec_cmd; return true; @@ -708,9 +709,8 @@ void Remember::checkReload() { void Remember::reload() { string apps_string = FbTk::StringUtil::expandFilename(Fluxbox::instance()->getAppsFilename()); -#ifdef DEBUG - cerr<<__FILE__<<"("<<__FUNCTION__<<"): Loading apps file ["<getAppsFilename()); -#ifdef DEBUG - cerr<<__FILE__<<"("<<__FUNCTION__<<"): Saving apps file ["< #endif -using std::cerr; -using std::endl; using std::string; class BackgroundItem: public FbTk::ThemeItem { diff --git a/src/Screen.cc b/src/Screen.cc index 9e340f8..e3df8a0 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -54,6 +54,7 @@ #include "AtomHandler.hh" #include "HeadArea.hh" #include "FbCommands.hh" +#include "Debug.hh" #include "FbTk/I18n.hh" #include "FbTk/Subject.hh" @@ -154,10 +155,8 @@ using std::mem_fun; using std::bind2nd; using std::equal_to; -#ifdef DEBUG using std::hex; using std::dec; -#endif // DEBUG static bool running = true; namespace { @@ -631,10 +630,10 @@ void BScreen::initWindows() { (wmhints->icon_window != children[i])) for (unsigned int j = 0; j < nchild; j++) { if (children[j] == wmhints->icon_window) { -#ifdef DEBUG - cerr<<"BScreen::initWindows(): children[j] = 0x"<validateWindow(children[i])) { -#ifdef DEBUG - cerr<<"BScreen::initWindows(): not valid window = "< #include @@ -40,13 +41,10 @@ using std::string; -#ifdef DEBUG -#include -using std::cerr; + using std::endl; using std::hex; using std::dec; -#endif // DEBUG /// helper class for tray windows, so we dont call XDestroyWindow class TrayWindow: public FbTk::FbWindow { @@ -86,9 +84,9 @@ public: mapped = (bool)(static_cast(prop[1]) & XEMBED_MAPPED); XFree(static_cast(prop)); -#ifdef DEBUG - cerr<<__FILE__<<"(SystemTray::TrayWindow::getMappedDefault(): XEMBED_MAPPED = "<add(*this, win); @@ -400,9 +394,8 @@ void SystemTray::removeClient(Window win, bool destroyed) { if (tray_it == m_clients.end()) return; -#ifdef DEBUG - cerr<<__FILE__<<"(SystemTray::removeClient(Window)): 0x"<remove(window()); @@ -175,10 +171,9 @@ bool WinClient::sendFocus() { } if (!send_focus_message) return false; -#ifdef DEBUG - cerr<<"WinClient::"<<__FUNCTION__<<": this = "< #include -using std::cerr; using std::endl; using std::string; using std::vector; @@ -96,13 +96,10 @@ using std::mem_fun; using std::equal_to; using std::max; using std::swap; - -using namespace FbTk; - -#ifdef DEBUG using std::dec; using std::hex; -#endif // DEBUG + +using namespace FbTk; namespace { @@ -332,13 +329,11 @@ FluxboxWindow::~FluxboxWindow() { } -#ifdef DEBUG const char* title = m_client ? m_client->title().c_str() : "" ; - cerr<<__FILE__<<"("<<__LINE__<<"): starting ~FluxboxWindow("< 1"< 1"<transientFor()<transientFor()<transientFor() && m_client->transientFor()->fbwindow()) { - cerr<<"FluxboxWindow::init("<title(): "<< - m_client->transientFor()->fbwindow()->title()<title(): "<< + m_client->transientFor()->fbwindow()->title()<isStateModal()) return (*it)->focus(); } @@ -1330,9 +1313,8 @@ bool FluxboxWindow::focus() { // don't hide the frame directly, use this function void FluxboxWindow::hide(bool interrupt_moving) { -#ifdef DEBUG - cerr<<__FILE__<<"("<<__FUNCTION__<<")["<shaped) @@ -2017,9 +1990,7 @@ void FluxboxWindow::mapRequestEvent(XMapRequestEvent &re) { // we're only concerned about client window event WinClient *client = findClient(re.window); if (client == 0) { -#ifdef DEBUG - cerr<<__FILE__<<"("<<__FUNCTION__<<"): Can't find client!"<window()<window()<window(), ReparentNotify, &xev)) { -#ifdef DEBUG - cerr<<"FluxboxWindow::restore: reparent 0x"<window()<window()<reparent(screen().rootWindow(), wx, wy, false); @@ -3336,10 +3300,9 @@ void FluxboxWindow::restore(WinClient *client, bool remap) { delete client; -#ifdef DEBUG - cerr<<"FluxboxWindow::restore: remap = "< -using std::cerr; -using std::endl; -#endif // DEBUG - Workspace::Workspace(BScreen &scrn, const string &name, unsigned int id): m_screen(scrn), m_clientmenu(scrn, m_windowlist, false), diff --git a/src/Xutil.cc b/src/Xutil.cc index e179857..dfaccf9 100644 --- a/src/Xutil.cc +++ b/src/Xutil.cc @@ -21,6 +21,7 @@ // DEALINGS IN THE SOFTWARE. #include "Xutil.hh" +#include "Debug.hh" #include "FbTk/I18n.hh" #include "FbTk/App.hh" @@ -37,11 +38,8 @@ using std::string; using std::strlen; - -#ifdef DEBUG -using std::cerr; using std::endl; -#endif // DEBUG + namespace Xutil { @@ -97,9 +95,8 @@ string getWMClassName(Window win) { string instance_name; if (XGetClassHint(FbTk::App::instance()->display(), win, &ch) == 0) { -#ifdef DEBUG - cerr<<"Xutil: Failed to read class hint!"<display(), win, &ch) == 0) { -#ifdef DEBUG - cerr<<"Xutil: Failed to read class hint!"<xmaprequest.window<xmaprequest.window<xmaprequest.window); @@ -764,9 +755,8 @@ void Fluxbox::handleEvent(XEvent * const e) { break; case MappingNotify: // Update stored modifier mapping -#ifdef DEBUG - cerr<<__FILE__<<"("<<__FUNCTION__<<"): MappingNotify"<xmapping.request == MappingKeyboard || e->xmapping.request == MappingModifier) { XRefreshKeyboardMapping(&e->xmapping); @@ -942,7 +932,7 @@ void Fluxbox::handleClientMessage(XClientMessageEvent &ce) { if (ce.message_type) atom = XGetAtomName(FbTk::App::instance()->display(), ce.message_type); - cerr<<__FILE__<<"("<<__LINE__<<"): ClientMessage. data.l[0]=0x"<