diff --git a/ChangeLog b/ChangeLog index 3b70addf..eadeaa5b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,16 +1,24 @@ (Format: Year/Month/Day) Changes for 1.0rc3: +*06/10/30: + * Cosmetic patch from Slava Semushin + CommandDialog.cc Ewmh.cc FbCommands.cc FbAtoms.cc Xutil.cc Gnome.cc + MenuTheme.cc Window.cc Resources.cc tests/testFont.cc FbWinFrameTheme.cc + SystemTray.cc MenuCreator.cc FbTk/TextureRender.cc FbTk/XFontImp.cc + FbTk/EventManager.cc FbTk/Menu.cc FbTk/FbPixmap.cc FbTk/ImageControl.cc + FbTk/XmbFontImp.cc FbTk/Font.cc ScreenResources.cc fluxbox.cc + Workspace.cc Toolbar.cc IconbarTool.cc util/fbsetroot.cc + util/fbrun/FbRun.cc util/fbrun/main.cc *06/10/27: * Changed mode for .fluxbox/startup to 644 (Mathias) some people on noexec-mounted partitions ran into problems util/startfluxbox.in * Small updates to the asciidoc-docs (Mathias) - * Cosmetic patch from Slave Semushin + * Cosmetic patch from Slava Semushin Slit.cc Screen.cc Keys.cc main.cc ToolbarTheme.cc FbTk/MultLayers.cc FbTk/Transparent.cc FbTk/Resource.cc FbTk/Theme.cc FbTk/XLayer.cc FbTk/Image.cc FbTk/Color.cc FbTk/FbString.cc Remember.cc RegExp.cc WinClient.cc Shape.cc ClientPattern.cc FbWinFrame.cc - *06/10/16: * Added CachedPixmap (Henrik) FbTk/CachedPixmap.hh/cc diff --git a/src/CommandDialog.cc b/src/CommandDialog.cc index 3fab06b2..e502bc1a 100644 --- a/src/CommandDialog.cc +++ b/src/CommandDialog.cc @@ -40,13 +40,17 @@ #include #include -#include #include #include -using namespace std; + +using std::string; +using std::vector; +using std::auto_ptr; +using std::less; +using std::out_of_range; CommandDialog::CommandDialog(BScreen &screen, - const std::string &title, const std::string precommand) : + const string &title, const string precommand) : FbTk::FbWindow(screen.rootWindow().screenNumber(), 0, 0, 200, 1, ExposureMask), m_textbox(*this, screen.winFrameTheme().font(), ""), m_label(*this, screen.winFrameTheme().font(), title), @@ -67,7 +71,7 @@ CommandDialog::~CommandDialog() { m_screen.imageControl().removeImage(m_pixmap); } -void CommandDialog::setText(const std::string &text) { +void CommandDialog::setText(const string &text) { m_textbox.setText(text); } @@ -135,7 +139,7 @@ void CommandDialog::keyPressEvent(XKeyEvent &event) { if (ks == XK_Return) { hide(); // hide and return focus to a FluxboxWindow // create command from line - std::auto_ptr cmd(CommandParser::instance(). + auto_ptr cmd(CommandParser::instance(). parseLine(m_precommand + m_textbox.text())); if (cmd.get()) cmd->execute(); @@ -168,7 +172,7 @@ void CommandDialog::tabComplete() { CommandParser::CommandFactoryMap::const_iterator it = CommandParser::instance().factorys().begin(); const CommandParser::CommandFactoryMap::const_iterator it_end = CommandParser::instance().factorys().end(); - std::vector matches; + vector matches; for (; it != it_end; ++it) { if ((*it).first.find(prefix) == 0) { matches.push_back((*it).first); @@ -177,12 +181,12 @@ void CommandDialog::tabComplete() { if (!matches.empty()) { // sort and apply larges match - std::sort(matches.begin(), matches.end(), less()); + sort(matches.begin(), matches.end(), less()); m_textbox.setText(m_textbox.text() + matches[0].substr(prefix.size())); } else XBell(FbTk::App::instance()->display(), 0); - } catch (std::out_of_range &oor) { + } catch (out_of_range &oor) { XBell(FbTk::App::instance()->display(), 0); } } diff --git a/src/Ewmh.cc b/src/Ewmh.cc index cb9f0f67..aada7cf3 100644 --- a/src/Ewmh.cc +++ b/src/Ewmh.cc @@ -43,7 +43,10 @@ #include #include -using namespace std; +using std::cerr; +using std::endl; +using std::vector; +using std::list; // mipspro has no new(nothrow) #if defined sgi && ! defined GCC @@ -61,7 +64,7 @@ enum EwmhMoveResizeDirection { _NET_WM_MOVERESIZE_SIZE_BOTTOM = 5, _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT = 6, _NET_WM_MOVERESIZE_SIZE_LEFT = 7, - _NET_WM_MOVERESIZE_MOVE = 8, // movement only + _NET_WM_MOVERESIZE_MOVE = 8, // movement only _NET_WM_MOVERESIZE_SIZE_KEYBOARD = 9, // size via keyboard _NET_WM_MOVERESIZE_MOVE_KEYBOARD = 10, // move via keyboard _NET_WM_MOVERESIZE_CANCEL = 11 // cancel operation @@ -84,19 +87,19 @@ void Ewmh::initForScreen(BScreen &screen) { /* From Extended Window Manager Hints, draft 1.3: * * _NET_SUPPORTING_WM_CHECK - * - * The Window Manager MUST set this property on the root window - * to be the ID of a child window created by himself, to indicate - * that a compliant window manager is active. The child window - * MUST also have the _NET_SUPPORTING_WM_CHECK property set to - * the ID of the child window. The child window MUST also have + * + * The Window Manager MUST set this property on the root window + * to be the ID of a child window created by himself, to indicate + * that a compliant window manager is active. The child window + * MUST also have the _NET_SUPPORTING_WM_CHECK property set to + * the ID of the child window. The child window MUST also have * the _NET_WM_NAME property set to the name of the Window Manager. - * - * Rationale: The child window is used to distinguish an active - * Window Manager from a stale _NET_SUPPORTING_WM_CHECK property - * that happens to point to another window. If the - * _NET_SUPPORTING_WM_CHECK window on the client window is missing - * or not properly set, clients SHOULD assume that no conforming + * + * Rationale: The child window is used to distinguish an active + * Window Manager from a stale _NET_SUPPORTING_WM_CHECK property + * that happens to point to another window. If the + * _NET_SUPPORTING_WM_CHECK window on the client window is missing + * or not properly set, clients SHOULD assume that no conforming * Window Manager is present. */ @@ -137,7 +140,7 @@ void Ewmh::initForScreen(BScreen &screen) { m_net_wm_state_below, m_net_wm_state_above, m_net_wm_state_demands_attention, - + // window type m_net_wm_window_type, m_net_wm_window_type_dock, @@ -174,7 +177,7 @@ void Ewmh::initForScreen(BScreen &screen) { m_net_request_frame_extents, m_net_wm_moveresize, - + m_net_frame_extents, // desktop properties @@ -289,8 +292,8 @@ void Ewmh::setupFrame(FluxboxWindow &win) { } else if (atoms[l] == m_net_wm_window_type_splash) { /* - * _NET_WM_WINDOW_TYPE_SPLASH indicates that the - * window is a splash screen displayed as an application + * _NET_WM_WINDOW_TYPE_SPLASH indicates that the + * window is a splash screen displayed as an application * is starting up. */ win.setDecoration(FluxboxWindow::DECOR_NONE); @@ -318,11 +321,11 @@ void Ewmh::setupFrame(FluxboxWindow &win) { } XFree(data); } else { - // if _NET_WM_WINDOW_TYPE not set and this window - // has transient_for the type must be set to _NET_WM_WINDOW_TYPE_DIALOG + // if _NET_WM_WINDOW_TYPE not set and this window + // has transient_for the type must be set to _NET_WM_WINDOW_TYPE_DIALOG if ( win.winClient().isTransient() ) { win.winClient(). - changeProperty(m_net_wm_window_type, + changeProperty(m_net_wm_window_type, XA_ATOM, 32, PropModeReplace, (unsigned char*)&m_net_wm_window_type_dialog, 1); } @@ -379,20 +382,20 @@ void Ewmh::updateClientClose(WinClient &winclient){ void Ewmh::updateClientList(BScreen &screen) { - std::list creation_order_list = screen.focusControl().creationOrderList(); + list creation_order_list = screen.focusControl().creationOrderList(); size_t num = creation_order_list.size(); Window *wl = FB_new_nothrow Window[num]; if (wl == 0) { _FB_USES_NLS; - cerr<<_FB_CONSOLETEXT(Ewmh, OutOfMemoryClientList, + cerr<<_FB_CONSOLETEXT(Ewmh, OutOfMemoryClientList, "Fatal: Out of memory, can't allocate for EWMH client list", "")<::iterator client_it = creation_order_list.begin(); - std::list::iterator client_it_end = creation_order_list.end(); + list::iterator client_it = creation_order_list.begin(); + list::iterator client_it_end = creation_order_list.end(); for (; client_it != client_it_end; ++client_it) wl[win++] = (*client_it)->window(); @@ -594,11 +597,11 @@ void Ewmh::updateWorkarea(BScreen &screen) { } void Ewmh::updateState(FluxboxWindow &win) { - + updateActions(win); - - typedef std::vector StateVec; + + typedef vector StateVec; StateVec state; @@ -622,7 +625,7 @@ void Ewmh::updateState(FluxboxWindow &win) { FluxboxWindow::ClientList::iterator it = win.clientList().begin(); FluxboxWindow::ClientList::iterator it_end = win.clientList().end(); for (; it != it_end; ++it) { - + // search the old states for _NET_WM_STATE_SKIP_PAGER and append it // to the current state, so it wont get deleted by us. StateVec client_state(state); @@ -646,7 +649,7 @@ void Ewmh::updateState(FluxboxWindow &win) { if (!client_state.empty()) { (*it)->changeProperty(m_net_wm_state, XA_ATOM, 32, PropModeReplace, - reinterpret_cast(&client_state.front()), + reinterpret_cast(&client_state.front()), client_state.size()); } else (*it)->deleteProperty(m_net_wm_state); @@ -782,7 +785,7 @@ bool Ewmh::checkClientMessage(const XClientMessageEvent &ce, FluxboxWindow* fbwin = winclient->fbwindow(); // if the raised window is on a different workspace - // we do what the user wish: + // we do what the user wish: // either ignore|go to that workspace|get the window if (fbwin->screen().currentWorkspaceID() != fbwin->workspaceNumber() && !fbwin->isStuck()) { @@ -801,7 +804,7 @@ bool Ewmh::checkClientMessage(const XClientMessageEvent &ce, } // else we ignore it. my favourite mode :) } fbwin->raise(); - } + } winclient->focus(); return true; } else if (ce.message_type == m_net_close_window) { @@ -836,7 +839,7 @@ bool Ewmh::checkClientMessage(const XClientMessageEvent &ce, // ce.data.l[0] = source indication // ce.data.l[1] = sibling window // ce.data.l[2] = detail - + WinClient *above_win = Fluxbox::instance()->searchWindow(ce.data.l[1]); if (above_win == 0 || above_win->fbwindow() == 0 || @@ -877,7 +880,7 @@ bool Ewmh::checkClientMessage(const XClientMessageEvent &ce, } else if (ce.message_type == m_net_wm_moveresize) { if (winclient == 0 || winclient->fbwindow() == 0) return true; - // data.l[0] = x_root + // data.l[0] = x_root // data.l[1] = y_root // data.l[2] = direction // data.l[3] = button @@ -1030,7 +1033,7 @@ void Ewmh::createAtoms() { void Ewmh::setFullscreen(FluxboxWindow &win, bool value) { // fullscreen implies maximised, above dock layer, // and no decorations (or decorations offscreen) - // + // // TODO: do we need the WindowState etc here anymore? // FluxboxWindow::setFullscreen() remembering old values // already and set them... @@ -1157,8 +1160,8 @@ void Ewmh::updateStrut(WinClient &winclient) { (unsigned char **) &data) && data) { int head = winclient.screen().getHead(winclient); - winclient.setStrut(winclient.screen().requestStrut(head, - data[0], data[1], + winclient.setStrut(winclient.screen().requestStrut(head, + data[0], data[1], data[2], data[3])); winclient.screen().updateAvailableWorkspaceArea(); } @@ -1172,17 +1175,17 @@ void Ewmh::updateActions(FluxboxWindow &win) { * * _NET_WM_ALLOWED_ACTIONS, ATOM[] * - * A list of atoms indicating user operations that the + * A list of atoms indicating user operations that the * Window Manager supports for this window. Atoms present in the - * list indicate allowed actions, atoms not present in the list - * indicate actions that are not supported for this window. The - * Window Manager MUST keep this property updated to reflect the + * list indicate allowed actions, atoms not present in the list + * indicate actions that are not supported for this window. The + * Window Manager MUST keep this property updated to reflect the * actions which are currently "active" or "sensitive" for a window. - * Taskbars, Pagers, and other tools use _NET_WM_ALLOWED_ACTIONS to - * decide which actions should be made available to the user. + * Taskbars, Pagers, and other tools use _NET_WM_ALLOWED_ACTIONS to + * decide which actions should be made available to the user. */ - - typedef std::vector ActionsVector; + + typedef vector ActionsVector; ActionsVector actions; actions.reserve(10); // all windows can change desktop, @@ -1190,7 +1193,7 @@ void Ewmh::updateActions(FluxboxWindow &win) { actions.push_back(m_net_wm_action_change_desktop); actions.push_back(m_net_wm_action_shade); actions.push_back(m_net_wm_action_stick); - + if (win.isResizable()) actions.push_back(m_net_wm_action_resize); if (win.isMoveable()) @@ -1225,7 +1228,7 @@ void Ewmh::updateActions(FluxboxWindow &win) { for (; it != it_end; ++it) { (*it)->changeProperty(m_net_wm_allowed_actions, XA_ATOM, 32, PropModeReplace, reinterpret_cast(&actions.front()), - actions.size()); + actions.size()); } } @@ -1267,7 +1270,7 @@ void Ewmh::setupState(FluxboxWindow &win) { } void Ewmh::updateFrameExtents(FluxboxWindow &win) { - /* Frame extents are basically the amount the window manager frame + /* Frame extents are basically the amount the window manager frame protrudes from the client window, on left, right, top, bottom (it is independent of window position). */ diff --git a/src/FbAtoms.cc b/src/FbAtoms.cc index 53145383..e6b5e514 100644 --- a/src/FbAtoms.cc +++ b/src/FbAtoms.cc @@ -26,7 +26,7 @@ #include -using namespace std; +using std::string; FbAtoms *FbAtoms::s_singleton = 0; diff --git a/src/FbCommands.cc b/src/FbCommands.cc index 08f1f939..83025ecc 100644 --- a/src/FbCommands.cc +++ b/src/FbCommands.cc @@ -54,7 +54,12 @@ #include // for P_NOWAIT #endif // __EMX__ -using namespace std; +using std::string; +using std::pair; +using std::set; +using std::ofstream; +using std::endl; +using std::ios; namespace { @@ -107,7 +112,7 @@ void showMenu(const BScreen &screen, FbTk::Menu &menu) { namespace FbCommands { -ExecuteCmd::ExecuteCmd(const std::string &cmd, int screen_num):m_cmd(cmd), m_screen_num(screen_num) { +ExecuteCmd::ExecuteCmd(const string &cmd, int screen_num):m_cmd(cmd), m_screen_num(screen_num) { } @@ -125,7 +130,7 @@ int ExecuteCmd::run() { if (pid) return pid; - std::string displaystring("DISPLAY="); + string displaystring("DISPLAY="); displaystring += DisplayString(FbTk::App::instance()->display()); char intbuff[64]; int screen_num = m_screen_num; @@ -149,7 +154,7 @@ int ExecuteCmd::run() { return pid; // compiler happy -> we are happy ;) } -SetModKeyCmd::SetModKeyCmd(const std::string& modkey) : m_modkey(modkey) { } +SetModKeyCmd::SetModKeyCmd(const string& modkey) : m_modkey(modkey) { } void SetModKeyCmd::execute() { Fluxbox::instance()->setModKey(m_modkey.c_str()); @@ -158,7 +163,7 @@ void SetModKeyCmd::execute() { Fluxbox::instance()->reconfigure(); } -ExportCmd::ExportCmd(const std::string& name, const std::string& value) : +ExportCmd::ExportCmd(const string& name, const string& value) : m_name(name), m_value(value) { } @@ -167,7 +172,7 @@ void ExportCmd::execute() { // the setenv()-routine is not everywhere available and // putenv() doesnt manage the strings in the environment // and hence we have to do that on our own to avoid memleaking - static std::set stored; + static set stored; char* newenv = new char[m_name.size() + m_value.size() + 2]; if (newenv) { @@ -203,7 +208,7 @@ void SaveResources::execute() { Fluxbox::instance()->save_rc(); } -RestartFluxboxCmd::RestartFluxboxCmd(const std::string &cmd):m_cmd(cmd){ +RestartFluxboxCmd::RestartFluxboxCmd(const string &cmd):m_cmd(cmd){ } void RestartFluxboxCmd::execute() { @@ -223,7 +228,7 @@ void ReloadStyleCmd::execute() { cmd.execute(); } -SetStyleCmd::SetStyleCmd(const std::string &filename):m_filename(filename) { +SetStyleCmd::SetStyleCmd(const string &filename):m_filename(filename) { } @@ -234,7 +239,7 @@ void SetStyleCmd::execute() { Fluxbox::instance()->getStyleOverlayFilename()); } -KeyModeCmd::KeyModeCmd(const std::string &arguments):m_keymode(arguments),m_end_args("None Escape") { +KeyModeCmd::KeyModeCmd(const string &arguments):m_keymode(arguments),m_end_args("None Escape") { string::size_type second_pos = m_keymode.find_first_of(" \t", 0); if (second_pos != string::npos) { // ok we have arguments, parsing them here @@ -267,7 +272,7 @@ void ShowWorkspaceMenuCmd::execute() { -SetWorkspaceNameCmd::SetWorkspaceNameCmd(const std::string &name, int spaceid): +SetWorkspaceNameCmd::SetWorkspaceNameCmd(const string &name, int spaceid): m_name(name), m_workspace(spaceid) { } void SetWorkspaceNameCmd::execute() { @@ -312,8 +317,8 @@ void CommandDialogCmd::execute() { } -SetResourceValueCmd::SetResourceValueCmd(const std::string &resname, - const std::string &value): +SetResourceValueCmd::SetResourceValueCmd(const string &resname, + const string &value): m_resname(resname), m_value(value) { @@ -336,7 +341,7 @@ void SetResourceValueDialogCmd::execute() { win->show(); }; -BindKeyCmd::BindKeyCmd(const std::string &keybind):m_keybind(keybind) { } +BindKeyCmd::BindKeyCmd(const string &keybind):m_keybind(keybind) { } void BindKeyCmd::execute() { if (Fluxbox::instance()->keys() != 0) { diff --git a/src/FbTk/EventManager.cc b/src/FbTk/EventManager.cc index 3370fb5c..02259acc 100644 --- a/src/FbTk/EventManager.cc +++ b/src/FbTk/EventManager.cc @@ -25,8 +25,11 @@ #include "FbWindow.hh" #include "App.hh" +#ifdef DEBUG #include -using namespace std; +using std::cerr; +using std::endl; +#endif // DEBUG namespace FbTk { @@ -180,13 +183,13 @@ void EventManager::dispatch(Window win, XEvent &ev, bool parent) { break; }; - // find out which window is the parent and + // find out which window is the parent and // dispatch event Window root, parent_win, *children = 0; unsigned int num_children; - if (XQueryTree(FbTk::App::instance()->display(), win, + if (XQueryTree(FbTk::App::instance()->display(), win, &root, &parent_win, &children, &num_children) != 0) { - if (children != 0) + if (children != 0) XFree(children); if (parent_win != 0 && diff --git a/src/FbTk/FbPixmap.cc b/src/FbTk/FbPixmap.cc index 3aebd622..14d05e74 100644 --- a/src/FbTk/FbPixmap.cc +++ b/src/FbTk/FbPixmap.cc @@ -30,9 +30,8 @@ #include #include #include -#include -using namespace std; +using std::cerr; namespace FbTk { @@ -245,7 +244,7 @@ void FbPixmap::rotate(FbTk::Orientation orient) { default: // kill warning break; } - + // copy new area unsigned int srcx, srcy, destx, desty; @@ -349,7 +348,7 @@ Pixmap FbPixmap::release() { } void FbPixmap::rootwinPropertyNotify(int screen_num, Atom atom) { - if (!FbTk::Transparent::haveRender()) + if (!FbTk::Transparent::haveRender()) return; checkAtoms(); @@ -396,7 +395,7 @@ void FbPixmap::setRootPixmap(int screen_num, Pixmap pm) { Pixmap FbPixmap::getRootPixmap(int screen_num, bool force_update) { /* - if (!FbTk::Transparent::haveRender()) + if (!FbTk::Transparent::haveRender()) return None; */ @@ -404,7 +403,7 @@ Pixmap FbPixmap::getRootPixmap(int screen_num, bool force_update) { if (m_root_pixmaps && !force_update) return m_root_pixmaps[screen_num]; - // else setup pixmap cache + // else setup pixmap cache int numscreens = ScreenCount(display()); for (int i=0; i < numscreens; ++i) { Atom real_type; diff --git a/src/FbTk/Font.cc b/src/FbTk/Font.cc index 1e89180d..a6bf32d4 100644 --- a/src/FbTk/Font.cc +++ b/src/FbTk/Font.cc @@ -1,6 +1,6 @@ // Font.cc // Copyright (c) 2002 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org) -// +// // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation @@ -32,7 +32,7 @@ #include "config.h" #endif // HAVE_CONFIG_H -// for antialias +// for antialias #ifdef USE_XFT #include "XftFontImp.hh" #endif // USE_XFT @@ -55,7 +55,6 @@ #define __USE_GNU #endif //__USE_GNU -#include #ifdef HAVE_CSTRING #include #else @@ -79,8 +78,9 @@ #include #endif -using namespace std; - +using std::string; +using std::map; +using std::list; namespace { @@ -89,12 +89,12 @@ namespace { #endif //HAVE_SETLOCALE // use to map || => -typedef std::map StringMap; +typedef map StringMap; typedef StringMap::iterator StringMapIt; StringMap lookup_map; // stores FontCache; +typedef map FontCache; typedef FontCache::iterator FontCacheIt; FontCache font_cache; @@ -114,7 +114,7 @@ void resetEffects(FbTk::Font& font) { namespace FbTk { -bool Font::s_multibyte = false; +bool Font::s_multibyte = false; bool Font::s_utf8mode = false; @@ -135,7 +135,7 @@ void Font::shutdown() { Font::Font(const char *name): m_fontimp(0), - m_shadow(false), m_shadow_color("black", DefaultScreen(App::instance()->display())), + m_shadow(false), m_shadow_color("black", DefaultScreen(App::instance()->display())), m_shadow_offx(2), m_shadow_offy(2), m_halo(false), m_halo_color("white", DefaultScreen(App::instance()->display())) { @@ -165,11 +165,11 @@ Font::Font(const char *name): Font::~Font() { } -bool Font::load(const std::string &name) { +bool Font::load(const string &name) { if (name.size() == 0) return false; - + StringMapIt lookup_entry; FontCacheIt cache_entry; @@ -181,13 +181,13 @@ bool Font::load(const std::string &name) { resetEffects(*this); return true; } - + // split up the namelist - typedef std::list StringList; + typedef list StringList; typedef StringList::iterator StringListIt; StringList names; FbTk::StringUtil::stringtok(names, name, "|"); - + StringListIt name_it; for (name_it = names.begin(); name_it != names.end(); name_it++) { FbTk::StringUtil::removeTrailingWhitespace(*name_it); @@ -202,12 +202,12 @@ bool Font::load(const std::string &name) { } FontImp* tmp_font(0); - + #ifdef USE_XFT if ((*name_it)[0] != '-') tmp_font = new XftFontImp(0, s_utf8mode); #endif // USE_XFT - + if (!tmp_font) { #ifdef USE_XMB if (s_multibyte || s_utf8mode) @@ -225,7 +225,7 @@ bool Font::load(const std::string &name) { resetEffects(*this); return true; } - + delete tmp_font; } @@ -244,7 +244,7 @@ int Font::ascent() const { return m_fontimp->ascent(); } -int Font::descent() const { +int Font::descent() const { return m_fontimp->descent(); } @@ -253,14 +253,14 @@ bool Font::validOrientation(FbTk::Orientation orient) { } void Font::drawText(const FbDrawable &w, int screen, GC gc, - const FbString &text, size_t len, int x, int y, + const FbString &text, size_t len, int x, int y, Orientation orient) const { if (text.empty() || len == 0) return; // so we don't end up in a loop with m_shadow - static bool first_run = true; - + static bool first_run = true; + // draw "effects" first if (first_run) { if (m_shadow) { @@ -284,7 +284,7 @@ void Font::drawText(const FbDrawable &w, int screen, GC gc, m_fontimp->drawText(w, screen, gc, text, len, x, y, orient); -} +} }; diff --git a/src/FbTk/ImageControl.cc b/src/FbTk/ImageControl.cc index f209958e..c1fa7a58 100644 --- a/src/FbTk/ImageControl.cc +++ b/src/FbTk/ImageControl.cc @@ -67,7 +67,9 @@ #include -using namespace std; +using std::cerr; +using std::endl; +using std::list; namespace FbTk { @@ -175,7 +177,7 @@ Pixmap ImageControl::searchCache(unsigned int width, unsigned int height, for (; it != it_end; ++it) { if ((*it)->texture_pixmap == text.pixmap().drawable() && (*it)->orient == orient && - (*it)->width == width && + (*it)->width == width && (*it)->height == height && (*it)->texture == text.type()) { (*it)->count++; @@ -233,7 +235,7 @@ Pixmap ImageControl::renderImage(unsigned int width, unsigned int height, } // render new image - + TextureRender image(*this, width, height, orient, m_colors, m_num_colors); pixmap = image.render(texture); @@ -398,7 +400,7 @@ unsigned long ImageControl::getSqrt(unsigned int x) const { void ImageControl::cleanCache() { Display *disp = FbTk::App::instance()->display(); - std::list deadlist; + list deadlist; CacheList::iterator it = cache.begin(); CacheList::iterator it_end = cache.end(); for (; it != it_end; ++it) { @@ -411,8 +413,8 @@ void ImageControl::cleanCache() { } } - std::list::iterator dead_it = deadlist.begin(); - std::list::iterator dead_it_end = deadlist.end(); + list::iterator dead_it = deadlist.begin(); + list::iterator dead_it_end = deadlist.end(); for (; dead_it != dead_it_end; ++dead_it) { cache.erase(*dead_it); } diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index 480569fe..9206ade2 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc @@ -1,4 +1,4 @@ -// Menu.cc for FbTk - Fluxbox Toolkit +// Menu.cc for FbTk - Fluxbox Toolkit // Copyright (c) 2001 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org) // // Basemenu.cc for blackbox - an X11 Window manager @@ -63,10 +63,13 @@ #else #include #endif -#include #include -using namespace std; +#ifdef DEBUG +#include +using std::cout; +using std::endl; +#endif // DEBUG namespace FbTk { @@ -126,7 +129,7 @@ Menu::Menu(MenuTheme &tm, ImageControl &imgctrl): menu.persub = menu.minsub = 0; - long event_mask = ButtonPressMask | ButtonReleaseMask | + long event_mask = ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | KeyPressMask | ExposureMask | FocusChangeMask; // create menu window menu.window = FbTk::FbWindow(tm.screenNum(), @@ -140,7 +143,7 @@ Menu::Menu(MenuTheme &tm, ImageControl &imgctrl): FbTk::EventManager &evm = *FbTk::EventManager::instance(); evm.add(*this, menu.window); - + event_mask |= EnterWindowMask | LeaveWindowMask; //create menu title @@ -171,7 +174,7 @@ Menu::Menu(MenuTheme &tm, ImageControl &imgctrl): Menu::~Menu() { menu.window.hide(); - + if (shown && shown->window() == window()) shown = 0; @@ -216,9 +219,9 @@ int Menu::insert(MenuItem *item, int pos) { int Menu::remove(unsigned int index) { if (index >= menuitems.size()) { #ifdef DEBUG - std::cout << "Bad index (" << index << ") given to Menu::remove()" + cout << "Bad index (" << index << ") given to Menu::remove()" << " -- should be between 0 and " << menuitems.size() - << " inclusive." << std::endl; + << " inclusive." << endl; #endif // DEBUG return -1; } @@ -240,8 +243,8 @@ int Menu::remove(unsigned int index) { // } else // tmp->internal_hide(); } - - + + delete item; } @@ -276,7 +279,7 @@ void Menu::nextItem() { int old_which_press = m_which_press; m_active_index = -1; - if (validIndex(old_which_press) && + if (validIndex(old_which_press) && menuitems[old_which_press] != 0) { if (menuitems[old_which_press]->submenu()) { // we need to do this explicitly on the menu.window @@ -302,10 +305,10 @@ void Menu::nextItem() { return; } - m_active_index = m_which_press; + m_active_index = m_which_press; clearItem(m_which_press); - + } void Menu::prevItem() { @@ -318,7 +321,7 @@ void Menu::prevItem() { if (menuitems[old_which_press]->submenu()) { // we need to do this explicitly on the menu.window // since it might hide the parent if we use Menu::hide - menuitems[old_which_press]->submenu()->internal_hide(); + menuitems[old_which_press]->submenu()->internal_hide(); } clearItem(old_which_press); } @@ -371,7 +374,7 @@ void Menu::enterParent() { m_active_index = -1; //clearItem(m_which_press); - m_which_press = -1; // dont select any in this + m_which_press = -1; // dont select any in this // hide self m_visible = false; menu.window.hide(); @@ -411,7 +414,7 @@ void Menu::updateMenu(int active_index) { menu.sublevels++; } - if (menu.sublevels < menu.minsub) + if (menu.sublevels < menu.minsub) menu.sublevels = menu.minsub; menu.persub = menuitems.size() / menu.sublevels; @@ -432,7 +435,7 @@ void Menu::updateMenu(int active_index) { if (new_width == 0) { - if (menu.item_w > 0) + if (menu.item_w > 0) new_width = menu.item_w; else new_width = 1; @@ -476,12 +479,12 @@ void Menu::updateMenu(int active_index) { } if (m_title_vis) { - menu.title.moveResize(-menu.title.borderWidth(), -menu.title.borderWidth(), + menu.title.moveResize(-menu.title.borderWidth(), -menu.title.borderWidth(), width() + menu.title.borderWidth(), theme().titleHeight()); } - menu.frame.moveResize(0, ((m_title_vis) ? menu.title.y() + menu.title.height() + - menu.title.borderWidth()*2 : 0), + menu.frame.moveResize(0, ((m_title_vis) ? menu.title.y() + menu.title.height() + + menu.title.borderWidth()*2 : 0), width(), menu.frame_h); if (m_title_vis && m_need_update) { @@ -497,7 +500,7 @@ void Menu::updateMenu(int active_index) { menu.title.setBackgroundPixmap(menu.title_pixmap); } - if (tmp) + if (tmp) m_image_ctrl.removeImage(tmp); } @@ -509,7 +512,7 @@ void Menu::updateMenu(int active_index) { menu.frame.setBackgroundColor(frame_tex.color()); } else { menu.frame_pixmap = - m_image_ctrl.renderImage(width(), menu.frame_h, frame_tex); + m_image_ctrl.renderImage(width(), menu.frame_h, frame_tex); menu.frame.setBackgroundPixmap(menu.frame_pixmap); } @@ -543,7 +546,7 @@ void Menu::show() { shown = this; } - + } @@ -559,7 +562,7 @@ void Menu::hide() { while ((! p->m_torn) && p->m_parent && p->m_parent->isVisible()) p = p->m_parent; - + p->internal_hide(); } else if (!m_torn) // if we dont have a parent then do hide here internal_hide(); @@ -577,7 +580,7 @@ void Menu::grabInputFocus() { void Menu::clearWindow() { menu.title.clear(); menu.frame.clear(); - + // clear foreground bits of frame items for (size_t i = 0; i < menuitems.size(); i++) { clearItem(i, false); // no clear @@ -598,7 +601,7 @@ void Menu::internal_hide() { tmp->submenu()->internal_hide(); } - // if we have an active index we need to redraw it + // if we have an active index we need to redraw it // as non active int old = m_active_index; m_active_index = -1; @@ -683,11 +686,11 @@ void Menu::drawSubmenu(unsigned int index) { item->submenu()->m_parent = this; item->submenu()->setScreen(m_screen_x, m_screen_y, m_screen_width, m_screen_height); - + int sbl = index / menu.persub, i = index - (sbl * menu.persub); int new_x = x() + ((menu.item_w * (sbl + 1)) + menu.window.borderWidth()); int new_y; - + if (m_alignment == ALIGNTOP) { new_y = (y() + ((m_title_vis) ? theme().titleHeight() + menu.title.borderWidth() : 0) - ((item->submenu()->m_title_vis) ? @@ -698,7 +701,7 @@ void Menu::drawSubmenu(unsigned int index) { ((item->submenu()->m_title_vis) ? item->submenu()->theme().titleHeight() + menu.window.borderWidth() : 0)); } - + if (m_alignment == ALIGNBOTTOM && (new_y + item->submenu()->height()) > (y() + height())) { new_y = (y() + height() - item->submenu()->height()); @@ -709,7 +712,7 @@ void Menu::drawSubmenu(unsigned int index) { if ((new_x + item->submenu()->width()) + 2*borderw > m_screen_x + m_screen_width) { new_x = x() - item->submenu()->width() - menu.window.borderWidth(); } - + if (new_x < m_screen_x) new_x = m_screen_x; @@ -717,7 +720,7 @@ void Menu::drawSubmenu(unsigned int index) { new_y = m_screen_y + m_screen_height - item->submenu()->height() - menu.window.borderWidth() * 2; } - + item->submenu()->m_moving = m_moving; m_which_sub = index; @@ -732,7 +735,7 @@ void Menu::drawSubmenu(unsigned int index) { item->showSubmenu(); item->submenu()->raise(); } - + } else m_which_sub = -1; @@ -743,11 +746,11 @@ void Menu::drawSubmenu(unsigned int index) { bool Menu::hasSubmenu(unsigned int index) const { if (index >= menuitems.size()) //boundary check return false; - + if (!menuitems[index]->submenu()) //has submenu? return false; - - return true; + + return true; } #endif // NOT_USED @@ -767,9 +770,9 @@ int Menu::drawItem(FbDrawable &drawable, unsigned int index, if (exclusive_drawable) item_x = item_y = 0; - item->draw(drawable, theme(), highlight, + item->draw(drawable, theme(), highlight, exclusive_drawable, true, // draw fg, draw bg - item_x, item_y, + item_x, item_y, menu.item_w, theme().itemHeight()); return item_y; @@ -830,8 +833,8 @@ bool Menu::isItemSelectable(unsigned int index) const { if (index >= menuitems.size()) return false; const MenuItem *item = find(index); - return (!item || - (typeid(*item) == typeid(FbTk::MenuSeparator)) || + return (!item || + (typeid(*item) == typeid(FbTk::MenuSeparator)) || !item->isEnabled()) ? false : true; } @@ -842,7 +845,7 @@ void Menu::handleEvent(XEvent &event) { s_focused = 0; } else if (event.type == FocusIn) { if (s_focused != this) - s_focused = this; + s_focused = this; } } @@ -891,9 +894,9 @@ void Menu::buttonReleaseEvent(XButtonEvent &re) { if (re.button == 3) internal_hide(); - + } else if (re.window == menu.frame) { - + int sbl = (re.x / menu.item_w), i = (re.y / theme().itemHeight()), ix = sbl * menu.item_w, iy = i * theme().itemHeight(), w = (sbl * menu.persub) + i, @@ -940,14 +943,13 @@ void Menu::motionNotifyEvent(XMotionEvent &me) { } else if (!(me.state & Button1Mask) && me.window == menu.frame) { stopHide(); - int sbl = (me.x / menu.item_w), + int sbl = (me.x / menu.item_w), i = (me.y / theme().itemHeight()), w = (sbl * menu.persub) + i; if (w == m_active_index) return; - if (validIndex(m_active_index) && w != m_active_index) { int old_active_index = m_active_index; @@ -965,7 +967,7 @@ void Menu::motionNotifyEvent(XMotionEvent &me) { item->submenu()->startHide(); m_which_sub = -1; } - } + } } @@ -1012,7 +1014,7 @@ void Menu::motionNotifyEvent(XMotionEvent &me) { clearItem(w); } } - + } } @@ -1057,7 +1059,7 @@ void Menu::keyPressEvent(XKeyEvent &event) { char keychar[1]; XLookupString(&event, keychar, 1, &ks, 0); // a modifier key by itself doesn't do anything - if (IsModifierKey(ks)) + if (IsModifierKey(ks)) return; switch (ks) { @@ -1068,7 +1070,7 @@ void Menu::keyPressEvent(XKeyEvent &event) { nextItem(); break; case XK_Left: // enter parent if we have one - enterParent(); + enterParent(); break; case XK_Right: // enter submenu if we have one enterSubmenu(); @@ -1078,7 +1080,7 @@ void Menu::keyPressEvent(XKeyEvent &event) { break; case XK_Return: // send fake button 1 click - if (validIndex(m_which_press) && + if (validIndex(m_which_press) && isItemEnabled(m_which_press)) { if (event.state & ShiftMask) menuitems[m_which_press]->click(3, event.time); @@ -1114,7 +1116,7 @@ void Menu::reconfigure() { updateMenu(); } - + void Menu::openSubmenu() { @@ -1127,10 +1129,10 @@ void Menu::openSubmenu() { return; clearItem(item); - + if (menuitems[item]->submenu() != 0) { // stop hide timer, so it doesnt hides the menu if we - // have the same submenu as the last shown submenu + // have the same submenu as the last shown submenu // (window menu for clients inside workspacemenu for example) menuitems[item]->submenu()->m_hide_timer.stop(); drawSubmenu(item); @@ -1148,7 +1150,7 @@ void Menu::startHide() { timeout.tv_sec = 0; timeout.tv_usec = theme().delayClose() * 1000; // transformed to usec m_hide_timer.setTimeout(timeout); - m_hide_timer.start(); + m_hide_timer.start(); } void Menu::stopHide() { @@ -1158,7 +1160,7 @@ void Menu::stopHide() { void Menu::update(FbTk::Subject *subj) { m_need_update = true; - + Menuitems::iterator it = menuitems.begin(); Menuitems::iterator it_end = menuitems.end(); for (; it != it_end; ++it) { @@ -1167,7 +1169,7 @@ void Menu::update(FbTk::Subject *subj) { reconfigure(); } - + void Menu::setScreen(int x, int y, int w, int h) { m_screen_x = x; m_screen_y = y; @@ -1208,7 +1210,7 @@ void Menu::clearItem(int index, bool clear) { if (! item) return; item->draw(menu.frame, theme(), highlight, - true, false, item_x, item_y, + true, false, item_x, item_y, item_w, item_h); } diff --git a/src/FbTk/TextureRender.cc b/src/FbTk/TextureRender.cc index 7626c3bd..e5271dc0 100644 --- a/src/FbTk/TextureRender.cc +++ b/src/FbTk/TextureRender.cc @@ -39,7 +39,6 @@ #else #include #endif -using namespace std; // mipspro has no new(nothrow) #if defined sgi && ! defined GCC @@ -48,10 +47,16 @@ using namespace std; #define FB_new_nothrow new(std::nothrow) #endif +using std::cerr; +using std::endl; +using std::string; +using std::max; +using std::min; + namespace FbTk { -TextureRender::TextureRender(ImageControl &imgctrl, - unsigned int w, unsigned int h, +TextureRender::TextureRender(ImageControl &imgctrl, + unsigned int w, unsigned int h, FbTk::Orientation orient, XColor *_colors, size_t num_colors): control(imgctrl), @@ -66,7 +71,7 @@ TextureRender::TextureRender(ImageControl &imgctrl, unsigned int texture_max_width = WidthOfScreen(ScreenOfDisplay(FbTk::App::instance()->display(), imgctrl.screenNumber())) * 2; unsigned int texture_max_height = HeightOfScreen(ScreenOfDisplay(FbTk::App::instance()->display(), imgctrl.screenNumber())) * 2; - + _FB_USES_NLS; // clamp to "normal" size if (width > texture_max_width) { @@ -83,14 +88,14 @@ TextureRender::TextureRender(ImageControl &imgctrl, imgctrl.colorTables(&red_table, &green_table, &blue_table, &red_offset, &green_offset, &blue_offset, &red_bits, &green_bits, &blue_bits); - + } TextureRender::~TextureRender() { if (red != 0) delete [] red; if (green != 0) delete [] green; - if (blue != 0) delete [] blue; + if (blue != 0) delete [] blue; } @@ -119,8 +124,8 @@ void TextureRender::allocateColorTables() { if (red == 0) { char sbuf[128]; sprintf(sbuf, "%ld", (long int) size); - throw std::string("TextureRender::TextureRender(): " + - std::string(_FBTK_CONSOLETEXT(Error, OutOfMemoryRed, "Out of memory while allocating red buffer.", "")) + string(sbuf)); + throw string("TextureRender::TextureRender(): " + + string(_FBTK_CONSOLETEXT(Error, OutOfMemoryRed, "Out of memory while allocating red buffer.", "")) + string(sbuf)); } @@ -128,16 +133,16 @@ void TextureRender::allocateColorTables() { if (green == 0) { char sbuf[128]; sprintf(sbuf, "%ld", (long int) size); - throw std::string("TextureRender::TextureRender(): " + - std::string(_FBTK_CONSOLETEXT(Error, OutOfMemoryGreen, "Out of memory while allocating green buffer.", ""))+ string(sbuf)); + throw string("TextureRender::TextureRender(): " + + string(_FBTK_CONSOLETEXT(Error, OutOfMemoryGreen, "Out of memory while allocating green buffer.", ""))+ string(sbuf)); } blue = FB_new_nothrow unsigned char[size]; if (blue == 0) { char sbuf[128]; sprintf(sbuf, "%ld", (long int) size); - throw std::string("TextureRender::TextureRender(): " + - std::string(_FBTK_CONSOLETEXT(Error, OutOfMemoryBlue, "Out of memory while allocating blue buffer.", ""))+ string(sbuf)); + throw string("TextureRender::TextureRender(): " + + string(_FBTK_CONSOLETEXT(Error, OutOfMemoryBlue, "Out of memory while allocating blue buffer.", ""))+ string(sbuf)); } @@ -146,7 +151,7 @@ void TextureRender::allocateColorTables() { Pixmap TextureRender::renderSolid(const FbTk::Texture &texture) { FbPixmap pixmap(RootWindow(FbTk::App::instance()->display(), - control.screenNumber()), + control.screenNumber()), width, height, control.depth()); @@ -157,7 +162,7 @@ Pixmap TextureRender::renderSolid(const FbTk::Texture &texture) { } - FbTk::GContext gc(pixmap), + FbTk::GContext gc(pixmap), hgc(pixmap), lgc(pixmap); gc.setForeground(texture.color()); @@ -166,9 +171,9 @@ Pixmap TextureRender::renderSolid(const FbTk::Texture &texture) { hgc.setForeground(texture.hiColor()); pixmap.fillRectangle(gc.gc(), 0, 0, width, height); - + using namespace FbTk; - + if (texture.type() & Texture::INTERLACED) { lgc.setForeground(texture.colorTo()); register unsigned int i = 0; @@ -181,7 +186,7 @@ Pixmap TextureRender::renderSolid(const FbTk::Texture &texture) { if (texture.type() & Texture::BEVEL1) { if (texture.type() & Texture::RAISED) { - pixmap.drawLine(lgc.gc(), + pixmap.drawLine(lgc.gc(), 0, height - 1, width - 1, height - 1); pixmap.drawLine(lgc.gc(), width - 1, height - 1, width - 1, 0); @@ -244,33 +249,33 @@ Pixmap TextureRender::renderGradient(const FbTk::Texture &texture) { from = &(texture.colorTo()); to = &(texture.color()); - if (! (texture.type() & Texture::INVERT)) + if (! (texture.type() & Texture::INVERT)) inverted = true; } else { from = &(texture.color()); to = &(texture.colorTo()); - if (texture.type() & Texture::INVERT) + if (texture.type() & Texture::INVERT) inverted = true; } control.getGradientBuffers(width, height, &xtable, &ytable); - if (texture.type() & Texture::DIAGONAL) + if (texture.type() & Texture::DIAGONAL) dgradient(); - else if (texture.type() & Texture::ELLIPTIC) + else if (texture.type() & Texture::ELLIPTIC) egradient(); - else if (texture.type() & Texture::HORIZONTAL) + else if (texture.type() & Texture::HORIZONTAL) hgradient(); - else if (texture.type() & Texture::PYRAMID) + else if (texture.type() & Texture::PYRAMID) pgradient(); - else if (texture.type() & Texture::RECTANGLE) + else if (texture.type() & Texture::RECTANGLE) rgradient(); - else if (texture.type() & Texture::VERTICAL) + else if (texture.type() & Texture::VERTICAL) vgradient(); - else if (texture.type() & Texture::CROSSDIAGONAL) + else if (texture.type() & Texture::CROSSDIAGONAL) cdgradient(); - else if (texture.type() & Texture::PIPECROSS) + else if (texture.type() & Texture::PIPECROSS) pcgradient(); if (texture.type() & Texture::BEVEL1) @@ -293,10 +298,10 @@ Pixmap TextureRender::renderPixmap(const FbTk::Texture &src_texture) { if (tmpw != src_texture.pixmap().width() || tmph != src_texture.pixmap().height()) { - // copy src_texture's pixmap and + // copy src_texture's pixmap and // scale/tile to fit our size FbPixmap new_pm(src_texture.pixmap()); - + if ((src_texture.type() & Texture::TILED)) { new_pm.tile(tmpw,tmph); } else { @@ -336,14 +341,14 @@ XImage *TextureRender::renderXImage() { o = image->bits_per_pixel + ((image->byte_order == MSBFirst) ? 1 : 0); if (control.doDither()) { - unsigned char dither4[4][4] = { + unsigned char dither4[4][4] = { {0, 4, 1, 5}, {6, 2, 7, 3}, {1, 5, 0, 4}, {7, 3, 6, 2} }; #ifdef ORDEREDPSEUDO - unsigned char dither8[8][8] = { + unsigned char dither8[8][8] = { { 0, 32, 8, 40, 2, 34, 10, 42 }, { 48, 16, 56, 24, 50, 18, 58, 26 }, { 12, 44, 4, 36, 14, 46, 6, 38 }, @@ -711,7 +716,7 @@ return image; Pixmap TextureRender::renderPixmap() { Display *disp = FbTk::App::instance()->display(); - FbPixmap pixmap(RootWindow(disp, control.screenNumber()), + FbPixmap pixmap(RootWindow(disp, control.screenNumber()), width, height, control.depth()); if (pixmap.drawable() == None) { @@ -1441,9 +1446,9 @@ void TextureRender::rgradient() { // normal rgradient for (yt = ytable, y = 0; y < height; y++, yt += 3) { for (xt = xtable, x = 0; x < width; x++) { - *(pr++) = (unsigned char) (tr - (rsign * std::max(*(xt++), *(yt)))); - *(pg++) = (unsigned char) (tg - (gsign * std::max(*(xt++), *(yt + 1)))); - *(pb++) = (unsigned char) (tb - (bsign * std::max(*(xt++), *(yt + 2)))); + *(pr++) = (unsigned char) (tr - (rsign * max(*(xt++), *(yt)))); + *(pg++) = (unsigned char) (tg - (gsign * max(*(xt++), *(yt + 1)))); + *(pb++) = (unsigned char) (tb - (bsign * max(*(xt++), *(yt + 2)))); } } @@ -1454,32 +1459,32 @@ void TextureRender::rgradient() { for (yt = ytable, y = 0; y < height; y++, yt += 3) { for (xt = xtable, x = 0; x < width; x++) { if (y & 1) { - channel = (unsigned char) (tr - (rsign * std::max(*(xt++), *(yt)))); + channel = (unsigned char) (tr - (rsign * max(*(xt++), *(yt)))); channel2 = (channel >> 1) + (channel >> 2); if (channel2 > channel) channel2 = 0; *(pr++) = channel2; - channel = (unsigned char) (tg - (gsign * std::max(*(xt++), *(yt + 1)))); + channel = (unsigned char) (tg - (gsign * max(*(xt++), *(yt + 1)))); channel2 = (channel >> 1) + (channel >> 2); if (channel2 > channel) channel2 = 0; *(pg++) = channel2; - channel = (unsigned char) (tb - (bsign * std::max(*(xt++), *(yt + 2)))); + channel = (unsigned char) (tb - (bsign * max(*(xt++), *(yt + 2)))); channel2 = (channel >> 1) + (channel >> 2); if (channel2 > channel) channel2 = 0; *(pb++) = channel2; } else { - channel = (unsigned char) (tr - (rsign * std::max(*(xt++), *(yt)))); + channel = (unsigned char) (tr - (rsign * max(*(xt++), *(yt)))); channel2 = channel + (channel >> 3); if (channel2 < channel) channel2 = ~0; *(pr++) = channel2; - channel = (unsigned char) (tg - (gsign * std::max(*(xt++), *(yt + 1)))); + channel = (unsigned char) (tg - (gsign * max(*(xt++), *(yt + 1)))); channel2 = channel + (channel >> 3); if (channel2 < channel) channel2 = ~0; *(pg++) = channel2; - channel = (unsigned char) (tb - (bsign * std::max(*(xt++), *(yt + 2)))); + channel = (unsigned char) (tb - (bsign * max(*(xt++), *(yt + 2)))); channel2 = channel + (channel >> 3); if (channel2 < channel) channel2 = ~0; *(pb++) = channel2; @@ -1675,9 +1680,9 @@ void TextureRender::pcgradient() { // normal pcgradient for (yt = ytable, y = 0; y < height; y++, yt += 3) { for (xt = xtable, x = 0; x < width; x++) { - *(pr++) = (unsigned char) (tr - (rsign * std::min(*(xt++), *(yt)))); - *(pg++) = (unsigned char) (tg - (gsign * std::min(*(xt++), *(yt + 1)))); - *(pb++) = (unsigned char) (tb - (bsign * std::min(*(xt++), *(yt + 2)))); + *(pr++) = (unsigned char) (tr - (rsign * min(*(xt++), *(yt)))); + *(pg++) = (unsigned char) (tg - (gsign * min(*(xt++), *(yt + 1)))); + *(pb++) = (unsigned char) (tb - (bsign * min(*(xt++), *(yt + 2)))); } } @@ -1688,32 +1693,32 @@ void TextureRender::pcgradient() { for (yt = ytable, y = 0; y < height; y++, yt += 3) { for (xt = xtable, x = 0; x < width; x++) { if (y & 1) { - channel = (unsigned char) (tr - (rsign * std::min(*(xt++), *(yt)))); + channel = (unsigned char) (tr - (rsign * min(*(xt++), *(yt)))); channel2 = (channel >> 1) + (channel >> 2); if (channel2 > channel) channel2 = 0; *(pr++) = channel2; - channel = (unsigned char) (tg - (bsign * std::min(*(xt++), *(yt + 1)))); + channel = (unsigned char) (tg - (bsign * min(*(xt++), *(yt + 1)))); channel2 = (channel >> 1) + (channel >> 2); if (channel2 > channel) channel2 = 0; *(pg++) = channel2; - channel = (unsigned char) (tb - (gsign * std::min(*(xt++), *(yt + 2)))); + channel = (unsigned char) (tb - (gsign * min(*(xt++), *(yt + 2)))); channel2 = (channel >> 1) + (channel >> 2); if (channel2 > channel) channel2 = 0; *(pb++) = channel2; } else { - channel = (unsigned char) (tr - (rsign * std::min(*(xt++), *(yt)))); + channel = (unsigned char) (tr - (rsign * min(*(xt++), *(yt)))); channel2 = channel + (channel >> 3); if (channel2 < channel) channel2 = ~0; *(pr++) = channel2; - channel = (unsigned char) (tg - (gsign * std::min(*(xt++), *(yt + 1)))); + channel = (unsigned char) (tg - (gsign * min(*(xt++), *(yt + 1)))); channel2 = channel + (channel >> 3); if (channel2 < channel) channel2 = ~0; *(pg++) = channel2; - channel = (unsigned char) (tb - (bsign * std::min(*(xt++), *(yt + 2)))); + channel = (unsigned char) (tb - (bsign * min(*(xt++), *(yt + 2)))); channel2 = channel + (channel >> 3); if (channel2 < channel) channel2 = ~0; *(pb++) = channel2; diff --git a/src/FbTk/XFontImp.cc b/src/FbTk/XFontImp.cc index 7398625b..515b1e2b 100644 --- a/src/FbTk/XFontImp.cc +++ b/src/FbTk/XFontImp.cc @@ -1,6 +1,6 @@ // XFontImp.cc for FbTk fluxbox toolkit // Copyright (c) 2002 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org) -// +// // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation @@ -36,7 +36,11 @@ #else #include #endif -using namespace std; + +using std::cerr; +using std::endl; +using std::string; +using std::nothrow; namespace FbTk { @@ -45,13 +49,13 @@ XFontImp::XFontImp(const char *fontname):m_fontstruct(0) { m_rotfonts[i] = 0; if (fontname != 0) - load(fontname); + load(fontname); } XFontImp::~XFontImp() { if (m_fontstruct != 0) XFreeFont(App::instance()->display(), m_fontstruct); - + for (int i = ROT0; i <= ROT270; ++i) if (m_rotfonts[i] != 0) freeRotFont(m_rotfonts[i]); @@ -60,11 +64,11 @@ XFontImp::~XFontImp() { int XFontImp::ascent() const { if (m_fontstruct == 0) return 0; - + return m_fontstruct->ascent; } -bool XFontImp::load(const std::string &fontname) { +bool XFontImp::load(const string &fontname) { XFontStruct *font = XLoadQueryFont(App::instance()->display(), fontname.c_str()); if (font == 0) @@ -91,8 +95,8 @@ void XFontImp::drawText(const FbDrawable &w, int screen, GC gc, const FbString & return; } - std::string localestr = text; - localestr.erase(len, std::string::npos); + string localestr = text; + localestr.erase(len, string::npos); localestr = FbStringUtil::FbStrToLocale(localestr); XSetFont(w.display(), gc, m_fontstruct->fid); @@ -103,8 +107,8 @@ unsigned int XFontImp::textWidth(const FbString &text, unsigned int size) const if (text.empty() || m_fontstruct == 0) return 0; - std::string localestr = text; - localestr.erase(size, std::string::npos); + string localestr = text; + localestr.erase(size, string::npos); localestr = FbStringUtil::FbStrToLocale(localestr); return XTextWidth(m_fontstruct, localestr.data(), localestr.size()); @@ -138,7 +142,7 @@ void XFontImp::rotate(FbTk::Orientation orient) { // create the depth 1 canvas bitmap FbTk::FbPixmap canvas(rootwin, boxlen, boxlen, 1); - + // create graphic context for our canvas FbTk::GContext font_gc(canvas); font_gc.setBackground(None); @@ -152,22 +156,22 @@ void XFontImp::rotate(FbTk::Orientation orient) { cerr<<"RotFont: "<<_FBTK_CONSOLETEXT(Error, OutOfMemory, "Out of memory", "Something couldn't allocate memory")<min_char_or_byte2; + min_char = m_fontstruct->min_char_or_byte2; max_char = m_fontstruct->max_char_or_byte2; - + // we only want printable chars if (min_char<32) min_char = 32; if (max_char>126) max_char = 126; - + /* some overall font data ... */ rotfont->min_char = min_char; rotfont->max_char = max_char; rotfont->max_ascent = m_fontstruct->max_bounds.ascent; - rotfont->max_descent = m_fontstruct->max_bounds.descent; + rotfont->max_descent = m_fontstruct->max_bounds.descent; rotfont->height = rotfont->max_ascent + rotfont->max_descent; // font needs rotation @@ -183,9 +187,9 @@ void XFontImp::rotate(FbTk::Orientation orient) { rotfont->per_char[ichar-32].width = m_fontstruct->per_char[index].width; // some space chars have zero body, but a bitmap can't have - if (!ascent && !descent) + if (!ascent && !descent) ascent = rotfont->per_char[ichar-32].ascent = 1; - if (!lbearing && !rbearing) + if (!lbearing && !rbearing) rbearing = rotfont->per_char[ichar-32].rbearing = 1; // glyph width and height when vertical @@ -193,9 +197,9 @@ void XFontImp::rotate(FbTk::Orientation orient) { vert_h = ascent + descent; // width in bytes - vert_len = (vert_w-1)/8+1; + vert_len = (vert_w-1)/8+1; - font_gc.setForeground(None); + font_gc.setForeground(None); canvas.fillRectangle(font_gc.gc(), 0, 0, boxlen, boxlen); @@ -209,14 +213,14 @@ void XFontImp::rotate(FbTk::Orientation orient) { // reserve memory for first XImage vertdata = (unsigned char *)calloc((unsigned)(vert_len * vert_h), 1); - XImage *I1 = XCreateImage(dpy, DefaultVisual(dpy, screen), + XImage *I1 = XCreateImage(dpy, DefaultVisual(dpy, screen), 1, XYBitmap, - 0, (char *)vertdata, + 0, (char *)vertdata, vert_w, vert_h, 8, 0); - if (I1 == None) { - cerr << "RotFont: " << _FBTK_CONSOLETEXT(Error, CreateXImage, - "Can't create XImage", + if (I1 == None) { + cerr << "RotFont: " << _FBTK_CONSOLETEXT(Error, CreateXImage, + "Can't create XImage", "XCreateImage failed for some reason") << "." << endl; free(vertdata); @@ -228,19 +232,19 @@ void XFontImp::rotate(FbTk::Orientation orient) { I1->byte_order = I1->bitmap_bit_order = MSBFirst; // extract character from canvas - XGetSubImage(dpy, canvas.drawable(), + XGetSubImage(dpy, canvas.drawable(), boxlen/2, boxlen/2 - vert_h, vert_w, vert_h, 1, XYPixmap, I1, 0, 0); - I1->format = XYBitmap; + I1->format = XYBitmap; // width, height of rotated character - if (orient == ROT180) { + if (orient == ROT180) { bit_w = vert_w; - bit_h = vert_h; + bit_h = vert_h; } else { bit_w = vert_h; - bit_h = vert_w; + bit_h = vert_w; } // width in bytes @@ -254,12 +258,12 @@ void XFontImp::rotate(FbTk::Orientation orient) { // create the image XImage *I2 = XCreateImage(dpy, DefaultVisual(dpy, screen), 1, XYBitmap, 0, - (char *)bitdata, bit_w, bit_h, 8, 0); + (char *)bitdata, bit_w, bit_h, 8, 0); if (I2 == None) { cerr << "XFontImp: " <<_FBTK_CONSOLETEXT(Error, CreateXImage, "Can't create XImage", - "XCreateImage failed for some reason") + "XCreateImage failed for some reason") << "." << endl; free(bitdata); delete rotfont; @@ -280,9 +284,9 @@ void XFontImp::rotate(FbTk::Orientation orient) { val = vertdata[(vert_h-j-1)*vert_len + (vert_w-i-1)/8] & (128>>((vert_w-i-1)%8)); } else { - val = vertdata[(vert_h-i-1)*vert_len + j/8] & + val = vertdata[(vert_h-i-1)*vert_len + j/8] & (128>>(j%8)); - } + } if (val) { bitdata[j*bit_len + i/8] = bitdata[j*bit_len + i/8] | (128>>(i%8)); @@ -290,12 +294,12 @@ void XFontImp::rotate(FbTk::Orientation orient) { } } - // create this character's bitmap - rotfont->per_char[ichar-32].glyph.bm = + // create this character's bitmap + rotfont->per_char[ichar-32].glyph.bm = XCreatePixmap(dpy, rootwin, bit_w, bit_h, 1); - - // put the image into the bitmap - XPutImage(dpy, rotfont->per_char[ichar-32].glyph.bm, + + // put the image into the bitmap + XPutImage(dpy, rotfont->per_char[ichar-32].glyph.bm, font_gc.gc(), I2, 0, 0, 0, 0, bit_w, bit_h); // free the image and data @@ -307,7 +311,7 @@ void XFontImp::rotate(FbTk::Orientation orient) { void XFontImp::freeRotFont(XRotFontStruct *rotfont) { // loop through each character and free its pixmap - for (int ichar = rotfont->min_char - 32; + for (int ichar = rotfont->min_char - 32; ichar <= rotfont->max_char - 32; ++ichar) { XFreePixmap(App::instance()->display(), rotfont->per_char[ichar].glyph.bm); } @@ -316,7 +320,7 @@ void XFontImp::freeRotFont(XRotFontStruct *rotfont) { rotfont = 0; } -void XFontImp::drawRotText(Drawable w, int screen, GC gc, const FbString &text, size_t len, int x, int y, FbTk::Orientation orient) const { +void XFontImp::drawRotText(Drawable w, int screen, GC gc, const FbString &text, size_t len, int x, int y, FbTk::Orientation orient) const { Display *dpy = App::instance()->display(); static GC my_gc = 0; @@ -335,8 +339,8 @@ void XFontImp::drawRotText(Drawable w, int screen, GC gc, const FbString &text, // vertical or upside down XSetFillStyle(dpy, my_gc, FillStippled); - std::string localestr = text; - localestr.erase(len, std::string::npos); + string localestr = text; + localestr.erase(len, string::npos); localestr = FbStringUtil::FbStrToLocale(localestr); const char *ctext = localestr.data(); len = localestr.size(); @@ -351,30 +355,30 @@ void XFontImp::drawRotText(Drawable w, int screen, GC gc, const FbString &text, // suitable offset if (orient == ROT270) { xp = x-rotfont->per_char[ichar].ascent; - yp = y-rotfont->per_char[ichar].rbearing; + yp = y-rotfont->per_char[ichar].rbearing; } else if (orient == ROT180) { xp = x-rotfont->per_char[ichar].rbearing; - yp = y-rotfont->per_char[ichar].descent+1; + yp = y-rotfont->per_char[ichar].descent+1; } else { // ROT90 xp = x-rotfont->per_char[ichar].descent; - yp = y+rotfont->per_char[ichar].lbearing; + yp = y+rotfont->per_char[ichar].lbearing; } - + // draw the glyph XSetStipple(dpy, my_gc, rotfont->per_char[ichar].glyph.bm); - + XSetTSOrigin(dpy, my_gc, xp, yp); - + XFillRectangle(dpy, w, my_gc, xp, yp, rotfont->per_char[ichar].glyph.bit_w, rotfont->per_char[ichar].glyph.bit_h); - + // advance position if (orient == ROT270) y -= rotfont->per_char[ichar].width; else if (orient == ROT180) x -= rotfont->per_char[ichar].width; - else + else y += rotfont->per_char[ichar].width; } } diff --git a/src/FbTk/XmbFontImp.cc b/src/FbTk/XmbFontImp.cc index 160b0be9..9b3c3024 100644 --- a/src/FbTk/XmbFontImp.cc +++ b/src/FbTk/XmbFontImp.cc @@ -50,7 +50,6 @@ #else #include #endif -#include #ifdef HAVE_CSTRING #include #else @@ -59,7 +58,7 @@ #include -using namespace std; +using std::string; namespace { @@ -118,7 +117,7 @@ XFontSet createFontSet(const char *fontname, bool& utf8mode) { XFontSet fs; char **missing, *def = "-"; int nmissing; - std::string orig_locale = ""; + string orig_locale = ""; #ifdef HAVE_SETLOCALE if (utf8mode) { @@ -156,7 +155,7 @@ XFontSet createFontSet(const char *fontname, bool& utf8mode) { // set to false because our strings won't be utf8-happy utf8mode = false; - + return fs; } @@ -173,7 +172,7 @@ XmbFontImp::~XmbFontImp() { XFreeFontSet(App::instance()->display(), m_fontset); } -bool XmbFontImp::load(const std::string &fontname) { +bool XmbFontImp::load(const string &fontname) { if (fontname.empty()) return false; @@ -205,8 +204,8 @@ void XmbFontImp::drawText(const FbDrawable &d, int screen, GC main_gc, const FbS } else #endif //X_HAVE_UTF8_STRING { - std::string localestr = text; - localestr.erase(len, std::string::npos); + string localestr = text; + localestr.erase(len, string::npos); localestr = FbStringUtil::FbStrToLocale(localestr); XmbDrawString(d.display(), d.drawable(), m_fontset, main_gc, x, y, @@ -226,7 +225,7 @@ void XmbFontImp::drawText(const FbDrawable &d, int screen, GC main_gc, const FbS // not straight forward, we actually draw it elsewhere, then rotate it FbTk::FbPixmap canvas(d.drawable(), w, h, 1); - + // create graphic context for our canvas FbTk::GContext font_gc(canvas); font_gc.setBackground(None); @@ -244,8 +243,8 @@ void XmbFontImp::drawText(const FbDrawable &d, int screen, GC main_gc, const FbS } else #endif //X_HAVE_UTF8_STRING { - std::string localestr = text; - localestr.erase(len, std::string::npos); + string localestr = text; + localestr.erase(len, string::npos); localestr = FbStringUtil::FbStrToLocale(localestr); XmbDrawString(dpy, canvas.drawable(), m_fontset, font_gc.gc(), xpos, ypos, @@ -260,7 +259,7 @@ void XmbFontImp::drawText(const FbDrawable &d, int screen, GC main_gc, const FbS // vertical or upside down - XSetFillStyle(dpy, my_gc, FillStippled); + XSetFillStyle(dpy, my_gc, FillStippled); // vertical or upside down @@ -275,7 +274,7 @@ void XmbFontImp::drawText(const FbDrawable &d, int screen, GC main_gc, const FbS canvas.height()); XFreeGC(dpy, my_gc); - + } unsigned int XmbFontImp::textWidth(const FbString &text, unsigned int len) const { @@ -292,8 +291,8 @@ unsigned int XmbFontImp::textWidth(const FbString &text, unsigned int len) const } #endif // X_HAVE_UTF8_STRING - std::string localestr = text; - localestr.erase(len, std::string::npos); + string localestr = text; + localestr.erase(len, string::npos); localestr = FbStringUtil::FbStrToLocale(localestr); XmbTextExtents(m_fontset, localestr.data(), localestr.size(), &ink, &logical); diff --git a/src/FbWinFrameTheme.cc b/src/FbWinFrameTheme.cc index 06e53654..898171f6 100644 --- a/src/FbWinFrameTheme.cc +++ b/src/FbWinFrameTheme.cc @@ -26,10 +26,7 @@ #include -#include -using namespace std; - -FbWinFrameTheme::FbWinFrameTheme(int screen_num): +FbWinFrameTheme::FbWinFrameTheme(int screen_num): FbTk::Theme(screen_num), m_label_focus(*this, "window.label.focus", "Window.Label.Focus"), m_label_unfocus(*this, "window.label.unfocus", "Window.Label.Unfocus"), @@ -44,14 +41,14 @@ FbWinFrameTheme::FbWinFrameTheme(int screen_num): m_button_focus(*this, "window.button.focus", "Window.Button.Focus"), m_button_unfocus(*this, "window.button.unfocus", "Window.Button.Unfocus"), m_button_pressed(*this, "window.button.pressed", "Window.Button.Pressed"), - + m_grip_focus(*this, "window.grip.focus", "Window.Grip.Focus"), m_grip_unfocus(*this, "window.grip.unfocus", "Window.Grip.Unfocus"), - + m_label_focus_color(*this, "window.label.focus.textColor", "Window.Label.Focus.TextColor"), m_label_unfocus_color(*this, "window.label.unfocus.textColor", "Window.Label.Unfocus.TextColor"), m_label_active_color(*this, "window.label.active.textColor", "Window.Label.Active.TextColor"), - + m_button_focus_color(*this, "window.button.focus.picColor", "Window.Button.Focus.PicColor"), m_button_unfocus_color(*this, "window.button.unfocus.picColor", "Window.Button.Unfocus.PicColor"), @@ -103,7 +100,7 @@ bool FbWinFrameTheme::fallback(FbTk::ThemeItem_base &item) { *m_label_active = *m_label_unfocus; return true; } else if (item.name() == "window.label.active.textColor") { - return FbTk::ThemeManager::instance().loadItem(item, "window.label.unfocus.textColor", + return FbTk::ThemeManager::instance().loadItem(item, "window.label.unfocus.textColor", "Window.Label.Unfocus.TextColor"); } diff --git a/src/Gnome.cc b/src/Gnome.cc index 81803ddf..33bc88d0 100644 --- a/src/Gnome.cc +++ b/src/Gnome.cc @@ -31,10 +31,17 @@ #include "Layer.hh" #include "FbTk/I18n.hh" - #include #include -using namespace std; + +using std::cerr; +using std::endl; +using std::list; + +#ifdef DEBUG +using std::hex; +using std::dec; +#endif // DEBUG Gnome::Gnome() { createAtoms(); @@ -45,7 +52,7 @@ Gnome::~Gnome() { // destroy gnome windows while (!m_gnomewindows.empty()) { XDestroyWindow(FbTk::App::instance()->display(), m_gnomewindows.back()); - m_gnomewindows.pop_back(); + m_gnomewindows.pop_back(); } } @@ -56,12 +63,12 @@ void Gnome::initForScreen(BScreen &screen) { Window gnome_win = XCreateSimpleWindow(disp, screen.rootWindow().window(), 0, 0, 5, 5, 0, 0, 0); // supported WM check - screen.rootWindow().changeProperty(m_gnome_wm_supporting_wm_check, - XA_WINDOW, 32, + screen.rootWindow().changeProperty(m_gnome_wm_supporting_wm_check, + XA_WINDOW, 32, PropModeReplace, (unsigned char *) &gnome_win, 1); - XChangeProperty(disp, gnome_win, - m_gnome_wm_supporting_wm_check, + XChangeProperty(disp, gnome_win, + m_gnome_wm_supporting_wm_check, XA_WINDOW, 32, PropModeReplace, (unsigned char *) &gnome_win, 1); // supported gnome atoms @@ -74,9 +81,9 @@ void Gnome::initForScreen(BScreen &screen) { m_gnome_wm_win_layer }; //list atoms that we support - screen.rootWindow().changeProperty(m_gnome_wm_prot, + screen.rootWindow().changeProperty(m_gnome_wm_prot, XA_ATOM, 32, PropModeReplace, - (unsigned char *)gnomeatomlist, + (unsigned char *)gnomeatomlist, (sizeof gnomeatomlist)/sizeof gnomeatomlist[0]); m_gnomewindows.push_back(gnome_win); @@ -85,7 +92,7 @@ void Gnome::initForScreen(BScreen &screen) { updateWorkspaceNames(screen); updateWorkspaceCount(screen); updateCurrentWorkspace(screen); - + } void Gnome::setupFrame(FluxboxWindow &win) { @@ -95,8 +102,8 @@ void Gnome::setupFrame(FluxboxWindow &win) { unsigned long nitems, bytes_after; long flags, *data = 0; - if (win.winClient().property(m_gnome_wm_win_state, 0, 1, False, XA_CARDINAL, - &ret_type, &fmt, &nitems, &bytes_after, + if (win.winClient().property(m_gnome_wm_win_state, 0, 1, False, XA_CARDINAL, + &ret_type, &fmt, &nitems, &bytes_after, (unsigned char **) &data) && data) { flags = *data; setState(&win, flags); @@ -106,8 +113,8 @@ void Gnome::setupFrame(FluxboxWindow &win) { } // load gnome layer atom - if (win.winClient().property(m_gnome_wm_win_layer, 0, 1, False, XA_CARDINAL, - &ret_type, &fmt, &nitems, &bytes_after, + if (win.winClient().property(m_gnome_wm_win_layer, 0, 1, False, XA_CARDINAL, + &ret_type, &fmt, &nitems, &bytes_after, (unsigned char **) &data) && data) { flags = *data; setLayer(&win, flags); @@ -117,11 +124,11 @@ void Gnome::setupFrame(FluxboxWindow &win) { } // load gnome workspace atom - if (win.winClient().property(m_gnome_wm_win_workspace, 0, 1, False, XA_CARDINAL, - &ret_type, &fmt, &nitems, &bytes_after, + if (win.winClient().property(m_gnome_wm_win_workspace, 0, 1, False, XA_CARDINAL, + &ret_type, &fmt, &nitems, &bytes_after, (unsigned char **) &data) && data) { unsigned int workspace_num = *data; - if (win.workspaceNumber() != workspace_num) + if (win.workspaceNumber() != workspace_num) win.setWorkspace(workspace_num); XFree (data); } else { @@ -131,7 +138,7 @@ void Gnome::setupFrame(FluxboxWindow &win) { } -bool Gnome::propertyNotify(WinClient &winclient, Atom the_property) { +bool Gnome::propertyNotify(WinClient &winclient, Atom the_property) { if (the_property == m_gnome_wm_win_state) { #ifdef DEBUG cerr<<__FILE__<<"("<<__FUNCTION__<<"): _WIN_STATE"<windowList().begin(); - Workspace::Windows::iterator win_it_end = + Workspace::Windows::iterator win_it_end = (*workspace_it)->windowList().end(); for (; win_it != win_it_end; ++win_it) num += (*win_it)->numClients(); } - + Window *wl = new Window[num]; if (wl == 0) { _FB_USES_NLS; @@ -175,19 +182,19 @@ void Gnome::updateClientList(BScreen &screen) { workspace_it = screen.getWorkspacesList().begin(); int win=0; for (; workspace_it != workspace_it_end; ++workspace_it) { - + // Fill in array of window ID's - Workspace::Windows::const_iterator it = + Workspace::Windows::const_iterator it = (*workspace_it)->windowList().begin(); - Workspace::Windows::const_iterator it_end = - (*workspace_it)->windowList().end(); + Workspace::Windows::const_iterator it_end = + (*workspace_it)->windowList().end(); for (; it != it_end; ++it) { // TODO! //check if the window don't want to be visible in the list //if (! ( (*it)->getGnomeHints() & WIN_STATE_HIDDEN) ) { - std::list::iterator client_it = + list::iterator client_it = (*it)->clientList().begin(); - std::list::iterator client_it_end = + list::iterator client_it_end = (*it)->clientList().end(); for (; client_it != client_it_end; ++client_it) wl[win++] = (*client_it)->window(); @@ -196,10 +203,10 @@ void Gnome::updateClientList(BScreen &screen) { } //number of windows to show in client list num = win; - screen.rootWindow().changeProperty(m_gnome_wm_win_client_list, + screen.rootWindow().changeProperty(m_gnome_wm_win_client_list, XA_WINDOW, 32, PropModeReplace, (unsigned char *)wl, num); - + delete[] wl; } @@ -208,14 +215,14 @@ void Gnome::updateWorkspaceNames(BScreen &screen) { size_t number_of_desks = screen.getWorkspaceNames().size(); const BScreen::WorkspaceNames &workspace_names = screen.getWorkspaceNames(); // convert our desktop names to a char * so we can send it - char *names[number_of_desks]; - - for (size_t i = 0; i < number_of_desks; i++) { + char *names[number_of_desks]; + + for (size_t i = 0; i < number_of_desks; i++) { names[i] = new char[workspace_names[i].size() + 1]; strcpy(names[i], workspace_names[i].c_str()); } - XTextProperty text; + XTextProperty text; if (XStringListToTextProperty(names, number_of_desks, &text)) { XSetTextProperty(FbTk::App::instance()->display(), screen.rootWindow().window(), &text, m_gnome_wm_win_workspace_names); @@ -254,7 +261,7 @@ void Gnome::updateWorkspace(FluxboxWindow &win) { FluxboxWindow::ClientList::iterator client_it = win.clientList().begin(); FluxboxWindow::ClientList::iterator client_it_end = win.clientList().end(); for (; client_it != client_it_end; ++client_it) - (*client_it)->changeProperty(m_gnome_wm_win_workspace, + (*client_it)->changeProperty(m_gnome_wm_win_workspace, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&val, 1); } @@ -268,12 +275,12 @@ void Gnome::updateState(FluxboxWindow &win) { state |= WIN_STATE_MINIMIZED; if (win.isShaded()) state |= WIN_STATE_SHADED; - + FluxboxWindow::ClientList::iterator client_it = win.clientList().begin(); FluxboxWindow::ClientList::iterator client_it_end = win.clientList().end(); for (; client_it != client_it_end; ++client_it) { (*client_it)->changeProperty(m_gnome_wm_win_state, - XA_CARDINAL, 32, + XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&state, 1); } } @@ -287,14 +294,14 @@ void Gnome::updateLayer(FluxboxWindow &win) { FluxboxWindow::ClientList::iterator client_it_end = win.clientList().end(); for (; client_it != client_it_end; ++client_it) (*client_it)->changeProperty(m_gnome_wm_win_layer, - XA_CARDINAL, 32, PropModeReplace, + XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&layernum, 1); - + } void Gnome::updateHints(FluxboxWindow &win) { //TODO - + } bool Gnome::checkClientMessage(const XClientMessageEvent &ce, BScreen * screen, WinClient * const winclient) { @@ -306,29 +313,26 @@ bool Gnome::checkClientMessage(const XClientMessageEvent &ce, BScreen * screen, ce.data.l[0] >= 0 && ce.data.l[0] < (signed)winclient->screen().numberOfWorkspaces()) { winclient->screen().changeWorkspaceID(ce.data.l[0]); - + } else if (screen!=0 && //the message sent to root window? ce.data.l[0] >= 0 && ce.data.l[0] < (signed)screen->numberOfWorkspaces()) screen->changeWorkspaceID(ce.data.l[0]); return true; } else if (winclient == 0) - return false; - + return false; + if (ce.message_type == m_gnome_wm_win_state) { #ifdef DEBUG cerr<<__FILE__<<"("<<__LINE__<<"): _WIN_STATE"<fbwindow()) { - //get new states + //get new states int flag = ce.data.l[0] & ce.data.l[1]; //don't update this when when we set new state disableUpdate(); @@ -368,7 +372,7 @@ void Gnome::setState(FluxboxWindow *win, int state) { win->stick(); } else if (win->isStuck()) win->stick(); - + if (state & WIN_STATE_MINIMIZED) { #ifdef DEBUG cerr<<"Gnome state: Minimized"<title()<<", WIN_LAYER_NORMAL)"<title()<<", WIN_LAYER_ONTOP)"< #include #include -using namespace std; + +using std::string; +using std::list; + +#ifdef DEBUG +using std::cerr; +using std::endl; +#endif // DEBUG namespace FbTk { template<> void FbTk::Resource::setFromString(const char *strval) { - if (strcasecmp(strval, "None") == 0) + if (strcasecmp(strval, "None") == 0) m_value = IconbarTool::NONE; - else if (strcasecmp(strval, "Icons") == 0) + else if (strcasecmp(strval, "Icons") == 0) m_value = IconbarTool::ICONS; else if (strcasecmp(strval, "NoIcons") == 0) m_value = IconbarTool::NOICONS; - else if (strcasecmp(strval, "WorkspaceIcons") == 0) + else if (strcasecmp(strval, "WorkspaceIcons") == 0) m_value = IconbarTool::WORKSPACEICONS; else if (strcasecmp(strval, "WorkspaceNoIcons") == 0) m_value = IconbarTool::WORKSPACENOICONS; - else if (strcasecmp(strval, "Workspace") == 0) + else if (strcasecmp(strval, "Workspace") == 0) m_value = IconbarTool::WORKSPACE; - else if (strcasecmp(strval, "AllWindows") == 0) + else if (strcasecmp(strval, "AllWindows") == 0) m_value = IconbarTool::ALLWINDOWS; else setDefaultValue(); @@ -93,17 +100,17 @@ void FbTk::Resource::setFromString(const char* strval) { template<> -std::string FbTk::Resource::getString() const { +string FbTk::Resource::getString() const { switch(m_value) { case IconbarTool::ON: - return std::string("On"); + return string("On"); break; case IconbarTool::SCREEN: - return std::string("Screen"); + return string("Screen"); break; case IconbarTool::OFF: default: - return std::string("Off"); + return string("Off"); }; } @@ -172,8 +179,8 @@ namespace { class ToolbarModeMenuItem : public FbTk::MenuItem { public: - ToolbarModeMenuItem(const FbTk::FbString &label, IconbarTool &handler, - IconbarTool::Mode mode, + ToolbarModeMenuItem(const FbTk::FbString &label, IconbarTool &handler, + IconbarTool::Mode mode, FbTk::RefCount &cmd): FbTk::MenuItem(label, cmd), m_handler(handler), m_mode(mode) { } @@ -190,8 +197,8 @@ private: class ToolbarAlignMenuItem: public FbTk::MenuItem { public: - ToolbarAlignMenuItem(const FbTk::FbString &label, IconbarTool &handler, - Container::Alignment mode, + ToolbarAlignMenuItem(const FbTk::FbString &label, IconbarTool &handler, + Container::Alignment mode, FbTk::RefCount &cmd): FbTk::MenuItem(label, cmd), m_handler(handler), m_mode(mode) { } @@ -213,17 +220,17 @@ void setupModeMenu(FbTk::Menu &menu, IconbarTool &handler) { menu.setLabel(_FB_XTEXT(Toolbar, IconbarMode, "Iconbar Mode", "Menu title - chooses which set of icons are shown in the iconbar")); RefCount saverc_cmd(new FbCommands::SaveResources()); - - menu.insert(new ToolbarModeMenuItem(_FB_XTEXT(Toolbar, IconbarModeNone, + + menu.insert(new ToolbarModeMenuItem(_FB_XTEXT(Toolbar, IconbarModeNone, "None", "No icons are shown in the iconbar"), - handler, + handler, IconbarTool::NONE, saverc_cmd)); menu.insert(new ToolbarModeMenuItem( - _FB_XTEXT(Toolbar, IconbarModeIcons, + _FB_XTEXT(Toolbar, IconbarModeIcons, "Icons", "Iconified windows from all workspaces are shown"), - handler, + handler, IconbarTool::ICONS, saverc_cmd)); menu.insert(new ToolbarModeMenuItem( @@ -233,26 +240,26 @@ void setupModeMenu(FbTk::Menu &menu, IconbarTool &handler) { IconbarTool::NOICONS, saverc_cmd)); menu.insert(new ToolbarModeMenuItem( - _FB_XTEXT(Toolbar, IconbarModeWorkspaceIcons, + _FB_XTEXT(Toolbar, IconbarModeWorkspaceIcons, "WorkspaceIcons", "Iconified windows from this workspace are shown"), handler, IconbarTool::WORKSPACEICONS, saverc_cmd)); menu.insert(new ToolbarModeMenuItem( - _FB_XTEXT(Toolbar, IconbarModeWorkspaceNoIcons, + _FB_XTEXT(Toolbar, IconbarModeWorkspaceNoIcons, "WorkspaceNoIcons", "No iconified windows from this workspace are shown"), handler, IconbarTool::WORKSPACENOICONS, saverc_cmd)); - + menu.insert(new ToolbarModeMenuItem( - _FB_XTEXT(Toolbar, IconbarModeWorkspace, + _FB_XTEXT(Toolbar, IconbarModeWorkspace, "Workspace", "Normal and iconified windows from this workspace are shown"), - handler, + handler, IconbarTool::WORKSPACE, saverc_cmd)); menu.insert(new ToolbarModeMenuItem( _FB_XTEXT(Toolbar, IconbarModeAllWindows, "All Windows", "All windows are shown"), - handler, + handler, IconbarTool::ALLWINDOWS, saverc_cmd)); menu.insert(new FbTk::MenuSeparator()); @@ -276,7 +283,7 @@ void setupModeMenu(FbTk::Menu &menu, IconbarTool &handler) { menu.updateMenu(); } - + inline bool checkAddWindow(IconbarTool::Mode mode, const FluxboxWindow &win) { bool ret_val = false; // just add the icons that are on the this workspace @@ -314,10 +321,10 @@ inline bool checkAddWindow(IconbarTool::Mode mode, const FluxboxWindow &win) { return ret_val; } -void removeDuplicate(const IconbarTool::IconList &iconlist, std::list &windowlist) { +void removeDuplicate(const IconbarTool::IconList &iconlist, list &windowlist) { IconbarTool::IconList::const_iterator icon_it = iconlist.begin(); IconbarTool::IconList::const_iterator icon_it_end = iconlist.end(); - std::list::iterator remove_it = windowlist.end(); + list::iterator remove_it = windowlist.end(); for (; icon_it != icon_it_end; ++icon_it) remove_it = remove(windowlist.begin(), remove_it, &(*icon_it)->win()); @@ -359,13 +366,14 @@ IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, BScr _FB_USES_NLS; using namespace FbTk; // setup use pixmap item to reconfig iconbar and save resource on click - MacroCommand *save_and_reconfig = new MacroCommand(); + MacroCommand *save_and_reconfig = new MacroCommand(); RefCount reconfig(new SimpleCommand(*this, &IconbarTool::renderTheme)); RefCount save(CommandParser::instance().parseLine("saverc")); save_and_reconfig->add(reconfig); save_and_reconfig->add(save); RefCount s_and_reconfig(save_and_reconfig); - m_menu.insert(new BoolMenuItem(_FB_XTEXT(Toolbar, ShowIcons, "Show Pictures", "chooses if little icons are shown next to title in the iconbar") , + m_menu.insert(new BoolMenuItem(_FB_XTEXT(Toolbar, ShowIcons, + "Show Pictures", "chooses if little icons are shown next to title in the iconbar"), *m_rc_use_pixmap, s_and_reconfig)); m_menu.updateMenu(); // must be internal menu, otherwise toolbar main menu tries to delete it. @@ -459,12 +467,12 @@ unsigned int IconbarTool::borderWidth() const { return m_icon_container.borderWidth(); } -void IconbarTool::update(FbTk::Subject *subj) { +void IconbarTool::update(FbTk::Subject *subj) { // ignore updates if we're shutting down if (m_screen.isShuttingdown()) { m_screen.clientListSig().detach(this); m_screen.iconListSig().detach(this); - m_screen.currentWorkspaceSig().detach(this); + m_screen.currentWorkspaceSig().detach(this); if (!m_icon_list.empty()) deleteIcons(); return; @@ -512,7 +520,7 @@ void IconbarTool::update(FbTk::Subject *subj) { return; // we don't need to update the entire list } else if (subj == &(winsubj->win().stateSig())) { if (!checkAddWindow(mode(), winsubj->win())) { - removeWindow(winsubj->win()); + removeWindow(winsubj->win()); renderTheme(); } @@ -522,7 +530,7 @@ void IconbarTool::update(FbTk::Subject *subj) { // render with titlebar focus, on attention IconButton *button = findButton(winsubj->win()); if (button) { - renderButton(*button, true, + renderButton(*button, true, winsubj->win().getAttentionState()); } return; @@ -532,7 +540,7 @@ void IconbarTool::update(FbTk::Subject *subj) { } } - bool remove_all = false; // if we should readd all windows + bool remove_all = false; // if we should readd all windows if (subj != 0 && typeid(*subj) == typeid(BScreen::ScreenSubject) && mode() != ALLWINDOWS && mode() != ICONS ) { @@ -541,7 +549,7 @@ void IconbarTool::update(FbTk::Subject *subj) { if (&m_screen.currentWorkspaceSig() == screen_subj ) { remove_all = true; // remove and readd all windows } - + } // lock graphic update @@ -559,7 +567,7 @@ void IconbarTool::update(FbTk::Subject *subj) { m_icon_container.setUpdateLock(false); m_icon_container.update(); m_icon_container.showSubwindows(); - + // another renderTheme we hopefully shouldn't need? These renders // should be done individually above // renderTheme(); @@ -588,13 +596,13 @@ void IconbarTool::updateSizing() { m_icon_container.setBorderWidth(m_theme.border().width()); IconList::iterator icon_it = m_icon_list.begin(); - const IconList::iterator icon_it_end = m_icon_list.end(); + const IconList::iterator icon_it_end = m_icon_list.end(); for (; icon_it != icon_it_end; ++icon_it) { if ((*icon_it)->win().isFocused()) (*icon_it)->setBorderWidth(m_theme.focusedBorder().width()); else // unfocused (*icon_it)->setBorderWidth(m_theme.unfocusedBorder().width()); - } + } } @@ -608,10 +616,10 @@ void IconbarTool::renderTheme() { // update button sizes before we get max width per client! updateSizing(); - + unsigned int icon_width = 0, icon_height = 0; unsigned int icon_width_off=0, icon_height_off=0; - + if (orientation() == FbTk::ROT0 || orientation() == FbTk::ROT180) { icon_width = m_icon_container.maxWidthPerClient(); icon_height = m_icon_container.height(); @@ -634,7 +642,7 @@ void IconbarTool::renderTheme() { icon_height + icon_height_off, m_theme.focusedTexture(), orientation()) ); } - + if (!m_theme.unfocusedTexture().usePixmap()) { m_unfocused_pm.reset( 0 ); m_unfocused_err_pm.reset( 0 ); @@ -666,7 +674,7 @@ void IconbarTool::renderTheme() { // update buttons IconList::iterator icon_it = m_icon_list.begin(); - const IconList::iterator icon_it_end = m_icon_list.end(); + const IconList::iterator icon_it_end = m_icon_list.end(); for (; icon_it != icon_it_end; ++icon_it) { renderButton(*(*icon_it)); } @@ -690,15 +698,15 @@ void IconbarTool::renderButton(IconButton &button, bool clear, // button.height() != m_icon_container.back()->height()); } - if (focusOption == 1 || + if (focusOption == 1 || (focusOption == -1 && - button.win().isFocused())) { - + button.win().isFocused())) { + // focused texture if (button.win().isFocused()) m_icon_container.setSelected(m_icon_container.find(&button)); - button.setGC(m_theme.focusedText().textGC()); + button.setGC(m_theme.focusedText().textGC()); button.setFont(m_theme.focusedText().font()); button.setJustify(m_theme.focusedText().justify()); button.setBorderWidth(m_theme.focusedBorder().width()); @@ -709,7 +717,7 @@ void IconbarTool::renderButton(IconButton &button, bool clear, else if (wider_button && m_focused_err_pm != 0) button.setBackgroundPixmap(m_focused_err_pm); else - button.setBackgroundColor(m_theme.focusedTexture().color()); + button.setBackgroundColor(m_theme.focusedTexture().color()); } else { // unfocused if (m_icon_container.selected() == &button) @@ -755,7 +763,7 @@ void IconbarTool::removeWindow(FluxboxWindow &win) { } #ifdef DEBUG cerr<<"IconbarTool::"<<__FUNCTION__<<"( 0x"<<&win<<" title = "<setTextPadding(*m_rc_client_padding); renderButton(*button, false); // update the attributes, but don't clear it - m_icon_container.insertItem(button); + m_icon_container.insertItem(button); m_icon_list.push_back(button); // dont forget to detach signal in removeWindow @@ -802,10 +810,10 @@ void IconbarTool::addWindow(FluxboxWindow &win) { } void IconbarTool::updateList() { - std::list ordered_list = + list ordered_list = m_screen.focusControl().creationOrderList(); - std::list::iterator it = ordered_list.begin(); - std::list::iterator it_end = ordered_list.end(); + list::iterator it = ordered_list.begin(); + list::iterator it_end = ordered_list.end(); for (; it != it_end; ++it) { if ((*it)->fbwindow() && checkAddWindow(mode(), *(*it)->fbwindow()) && !checkDuplicate(*(*it)->fbwindow())) diff --git a/src/MenuCreator.cc b/src/MenuCreator.cc index e33db194..030991c1 100644 --- a/src/MenuCreator.cc +++ b/src/MenuCreator.cc @@ -53,15 +53,21 @@ #include "FbTk/MenuIcon.hh" #include -using namespace std; -std::list MenuCreator::encoding_stack; -std::list MenuCreator::stacksize_stack; +using std::cerr; +using std::endl; +using std::string; +using std::vector; +using std::list; +using std::less; + +list MenuCreator::encoding_stack; +list MenuCreator::stacksize_stack; FbTk::StringConvertor MenuCreator::m_stringconvertor(FbTk::StringConvertor::ToFbString); -static void createStyleMenu(FbTk::Menu &parent, const std::string &label, - const std::string &directory) { +static void createStyleMenu(FbTk::Menu &parent, const string &label, + const string &directory) { // perform shell style ~ home directory expansion string stylesdir(FbTk::StringUtil::expandFilename(directory)); @@ -72,15 +78,15 @@ static void createStyleMenu(FbTk::Menu &parent, const std::string &label, // create a vector of all the filenames in the directory // add sort it - std::vector filelist(dir.entries()); + vector filelist(dir.entries()); for (size_t file_index = 0; file_index < dir.entries(); ++file_index) filelist[file_index] = dir.readFilename(); - std::sort(filelist.begin(), filelist.end(), less()); + sort(filelist.begin(), filelist.end(), less()); // for each file in directory add filename and path to menu for (size_t file_index = 0; file_index < dir.entries(); file_index++) { - std::string style(stylesdir + '/' + filelist[file_index]); + string style(stylesdir + '/' + filelist[file_index]); // add to menu only if the file is a regular file, and not a // .file or a backup~ file if ((FbTk::FileUtil::isRegularFile(style.c_str()) && @@ -140,10 +146,10 @@ public: p>>m_key>>m_label>>m_cmd>>m_icon; m_label.second = m_labelconvertor.recode(m_label.second); } - inline const std::string &icon() const { return m_icon.second; } - inline const std::string &command() const { return m_cmd.second; } - inline const std::string &label() const { return m_label.second; } - inline const std::string &key() const { return m_key.second; } + inline const string &icon() const { return m_icon.second; } + inline const string &command() const { return m_cmd.second; } + inline const string &label() const { return m_label.second; } + inline const string &key() const { return m_key.second; } inline FbTk::Menu *menu() { return m_menu; } private: Parser::Item m_key, m_label, m_cmd, m_icon; @@ -182,9 +188,9 @@ static void translateMenuItem(Parser &parse, ParseItem &pitem, FbTk::StringConve throw string("translateMenuItem: We must have a menu in ParseItem!"); FbTk::Menu &menu = *pitem.menu(); - const std::string &str_key = pitem.key(); - const std::string &str_cmd = pitem.command(); - const std::string &str_label = pitem.label(); + const string &str_key = pitem.key(); + const string &str_cmd = pitem.command(); + const string &str_label = pitem.label(); const int screen_number = menu.screenNumber(); _FB_USES_NLS; @@ -250,13 +256,13 @@ static void translateMenuItem(Parser &parse, ParseItem &pitem, FbTk::StringConve // inject every file in this directory into the current menu FbTk::Directory dir(newfile.c_str()); - std::vector filelist(dir.entries()); + vector filelist(dir.entries()); for (size_t file_index = 0; file_index < dir.entries(); ++file_index) filelist[file_index] = dir.readFilename(); - std::sort(filelist.begin(), filelist.end(), less()); + sort(filelist.begin(), filelist.end(), less()); for (size_t file_index = 0; file_index < dir.entries(); file_index++) { - std::string thisfile(newfile + '/' + filelist[file_index]); + string thisfile(newfile + '/' + filelist[file_index]); if (FbTk::FileUtil::isRegularFile(thisfile.c_str()) && (filelist[file_index][0] != '.') && @@ -367,7 +373,7 @@ static void parseWindowMenu(Parser &parse, FbTk::Menu &menu, FbTk::StringConvert } } -FbTk::Menu *MenuCreator::createMenu(const std::string &label, int screen_number) { +FbTk::Menu *MenuCreator::createMenu(const string &label, int screen_number) { BScreen *screen = Fluxbox::instance()->findScreen(screen_number); if (screen == 0) return 0; @@ -381,7 +387,7 @@ FbTk::Menu *MenuCreator::createMenu(const std::string &label, int screen_number) return menu; } -bool getStart(FbMenuParser &parser, std::string &label, FbTk::StringConvertor &labelconvertor) { +bool getStart(FbMenuParser &parser, string &label, FbTk::StringConvertor &labelconvertor) { ParseItem pitem(0); while (!parser.eof()) { // get first begin line @@ -397,15 +403,15 @@ bool getStart(FbMenuParser &parser, std::string &label, FbTk::StringConvertor &l return true; } -FbTk::Menu *MenuCreator::createFromFile(const std::string &filename, int screen_number, bool require_begin) { - std::string real_filename = FbTk::StringUtil::expandFilename(filename); +FbTk::Menu *MenuCreator::createFromFile(const string &filename, int screen_number, bool require_begin) { + string real_filename = FbTk::StringUtil::expandFilename(filename); Fluxbox::instance()->saveMenuFilename(real_filename.c_str()); FbMenuParser parser(real_filename); if (!parser.isLoaded()) return 0; - std::string label; + string label; if (require_begin && !getStart(parser, label, m_stringconvertor)) return 0; @@ -420,15 +426,15 @@ FbTk::Menu *MenuCreator::createFromFile(const std::string &filename, int screen_ } -bool MenuCreator::createFromFile(const std::string &filename, +bool MenuCreator::createFromFile(const string &filename, FbTk::Menu &inject_into, bool require_begin) { - std::string real_filename = FbTk::StringUtil::expandFilename(filename); + string real_filename = FbTk::StringUtil::expandFilename(filename); FbMenuParser parser(real_filename); if (!parser.isLoaded()) return false; - std::string label; + string label; if (require_begin && !getStart(parser, label, m_stringconvertor)) return false; @@ -440,15 +446,15 @@ bool MenuCreator::createFromFile(const std::string &filename, } -bool MenuCreator::createWindowMenuFromFile(const std::string &filename, +bool MenuCreator::createWindowMenuFromFile(const string &filename, FbTk::Menu &inject_into, bool require_begin) { - std::string real_filename = FbTk::StringUtil::expandFilename(filename); + string real_filename = FbTk::StringUtil::expandFilename(filename); FbMenuParser parser(real_filename); if (!parser.isLoaded()) return false; - std::string label; + string label; if (require_begin && !getStart(parser, label, m_stringconvertor)) return false; @@ -461,7 +467,7 @@ bool MenuCreator::createWindowMenuFromFile(const std::string &filename, } -FbTk::Menu *MenuCreator::createMenuType(const std::string &type, int screen_num) { +FbTk::Menu *MenuCreator::createMenuType(const string &type, int screen_num) { BScreen *screen = Fluxbox::instance()->findScreen(screen_num); if (screen == 0) return 0; @@ -476,7 +482,7 @@ FbTk::Menu *MenuCreator::createMenuType(const std::string &type, int screen_num) if (screen->windowMenuFilename().empty() || ! createWindowMenuFromFile(screen->windowMenuFilename(), *menu, true)) { char *default_menu[] = { - "shade", + "shade", "stick", "maximize", "iconify", @@ -499,8 +505,8 @@ FbTk::Menu *MenuCreator::createMenuType(const std::string &type, int screen_num) return 0; } -bool MenuCreator::createWindowMenuItem(const std::string &type, - const std::string &label, +bool MenuCreator::createWindowMenuItem(const string &type, + const string &label, FbTk::Menu &menu) { typedef FbTk::RefCount RefCmd; _FB_USES_NLS; @@ -512,10 +518,10 @@ bool MenuCreator::createWindowMenuItem(const std::string &type, RefCmd maximize_cmd(new WindowCmd(&FluxboxWindow::maximizeFull)); RefCmd maximize_vert_cmd(new WindowCmd(&FluxboxWindow::maximizeVertical)); RefCmd maximize_horiz_cmd(new WindowCmd(&FluxboxWindow::maximizeHorizontal)); - FbTk::MultiButtonMenuItem *maximize_item = - new FbTk::MultiButtonMenuItem(3, + FbTk::MultiButtonMenuItem *maximize_item = + new FbTk::MultiButtonMenuItem(3, label.empty()? - _FB_XTEXT(Windowmenu, Maximize, + _FB_XTEXT(Windowmenu, Maximize, "Maximize", "Maximize the window"): label); // create maximize item with: @@ -529,37 +535,37 @@ bool MenuCreator::createWindowMenuItem(const std::string &type, } else if (type == "iconify") { RefCmd iconify_cmd(new WindowCmd(&FluxboxWindow::iconify)); menu.insert(label.empty() ? - _FB_XTEXT(Windowmenu, Iconify, + _FB_XTEXT(Windowmenu, Iconify, "Iconify", "Iconify the window") : label, iconify_cmd); } else if (type == "close") { RefCmd close_cmd(new WindowCmd(&FluxboxWindow::close)); - menu.insert(label.empty() ? - _FB_XTEXT(Windowmenu, Close, - "Close", "Close the window") : + menu.insert(label.empty() ? + _FB_XTEXT(Windowmenu, Close, + "Close", "Close the window") : label, close_cmd); } else if (type == "kill" || type == "killwindow") { RefCmd kill_cmd(new WindowCmd(&FluxboxWindow::kill)); menu.insert(label.empty() ? - _FB_XTEXT(Windowmenu, Kill, + _FB_XTEXT(Windowmenu, Kill, "Kill", "Kill the window"): label, kill_cmd); } else if (type == "lower") { RefCmd lower_cmd(new WindowCmd(&FluxboxWindow::lower)); - menu.insert( label.empty() ? - _FB_XTEXT(Windowmenu, Lower, + menu.insert( label.empty() ? + _FB_XTEXT(Windowmenu, Lower, "Lower", "Lower the window"): label, lower_cmd); } else if (type == "raise") { RefCmd raise_cmd(new WindowCmd(&FluxboxWindow::raise)); - menu.insert(label.empty() ? - _FB_XTEXT(Windowmenu, Raise, + menu.insert(label.empty() ? + _FB_XTEXT(Windowmenu, Raise, "Raise", "Raise the window"): label, raise_cmd); } else if (type == "stick") { RefCmd stick_cmd(new WindowCmd(&FluxboxWindow::stick)); - menu.insert(label.empty() ? - _FB_XTEXT(Windowmenu, Stick, + menu.insert(label.empty() ? + _FB_XTEXT(Windowmenu, Stick, "Stick", "Stick the window"): label, stick_cmd); } else if (type == "extramenus") { @@ -570,7 +576,7 @@ bool MenuCreator::createWindowMenuItem(const std::string &type, it->second->disableTitle(); menu.insert(it->first, it->second); } - + } else if (type == "sendto") { menu.insert(label.empty() ? _FB_XTEXT(Windowmenu, SendTo, "Send To...", "Send to menu item name"): label, new SendToMenu(*Fluxbox::instance()->findScreen(menu.screenNumber()))); @@ -621,7 +627,7 @@ void MenuCreator::endFile() { for (; curr_size > (target_size+1); --curr_size) encoding_stack.pop_back(); - if (curr_size == (target_size+1)) + if (curr_size == (target_size+1)) endEncoding(); stacksize_stack.pop_back(); @@ -630,7 +636,7 @@ void MenuCreator::endFile() { /** * Push the encoding onto the stack, and make it active. */ -void MenuCreator::startEncoding(const std::string &encoding) { +void MenuCreator::startEncoding(const string &encoding) { // we push it regardless of whether it's valid, since we // need to stay balanced with the endEncodings. encoding_stack.push_back(encoding); @@ -646,7 +652,6 @@ void MenuCreator::startEncoding(const std::string &encoding) { void MenuCreator::endEncoding() { size_t min_size = stacksize_stack.back(); if (encoding_stack.size() <= min_size) { - // TODO: nls _FB_USES_NLS; cerr<<_FB_CONSOLETEXT(Menu, ErrorEndEncoding, "Warning: unbalanced [encoding] tags", "User menu file had unbalanced [encoding] tags")<::reverse_iterator it = encoding_stack.rbegin(); - std::list::reverse_iterator it_end = encoding_stack.rend(); + list::reverse_iterator it = encoding_stack.rbegin(); + list::reverse_iterator it_end = encoding_stack.rend(); while (it != it_end && !m_stringconvertor.setSource(*it)) ++it; diff --git a/src/MenuTheme.cc b/src/MenuTheme.cc index 2bcbf10b..4d6f55c4 100644 --- a/src/MenuTheme.cc +++ b/src/MenuTheme.cc @@ -1,6 +1,6 @@ // MenuTheme.cc // Copyright (c) 2003 Henrik Kinnunen (fluxgen at fluxbox dot org) -// +// // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation @@ -23,13 +23,13 @@ #include "MenuTheme.hh" #include "StringUtil.hh" -#include -using namespace std; + +using std::string; namespace FbTk { template <> -void FbTk::ThemeItem::load(const std::string *name, const std::string *altname) { } +void FbTk::ThemeItem::load(const string *name, const string *altname) { } template <> void FbTk::ThemeItem::setDefaultValue() { diff --git a/src/Resources.cc b/src/Resources.cc index feab9eab..9603523d 100644 --- a/src/Resources.cc +++ b/src/Resources.cc @@ -35,7 +35,10 @@ #include #include #include -using namespace std; + +using std::string; +using std::vector; + using namespace FbTk; //----------------------------------------------------------------- @@ -52,7 +55,7 @@ setFromString(const char* strval) { } template<> -void FbTk::Resource:: +void FbTk::Resource:: setFromString(const char *strval) { *this = strval; } @@ -64,13 +67,13 @@ setFromString(char const *strval) { } template<> -void FbTk::Resource >:: +void FbTk::Resource >:: setFromString(char const *strval) { - vector val; + vector val; StringUtil::stringtok(val, strval); //clear old values m_value.clear(); - + for (size_t i = 0; i < val.size(); i++) { if (strcasecmp(val[i].c_str(), "Maximize")==0) m_value.push_back(WinButton::MAXIMIZE); @@ -98,14 +101,14 @@ setFromString(char const *strval) { template<> void FbTk::Resource:: -setFromString(const char *strval) { +setFromString(const char *strval) { if (sscanf(strval, "%ul", &m_value) != 1) setDefaultValue(); } template<> void FbTk::Resource:: -setFromString(const char *strval) { +setFromString(const char *strval) { if (sscanf(strval, "%llu", &m_value) != 1) setDefaultValue(); } @@ -115,26 +118,26 @@ setFromString(const char *strval) { //---- manipulators for int, bool, and some enums with Resource --- //----------------------------------------------------------------- template<> -std::string FbTk::Resource:: +string FbTk::Resource:: getString() const { - return std::string(**this == true ? "true" : "false"); + return string(**this == true ? "true" : "false"); } template<> -std::string FbTk::Resource:: +string FbTk::Resource:: getString() const { char strval[256]; sprintf(strval, "%d", **this); - return std::string(strval); + return string(strval); } template<> -std::string FbTk::Resource:: +string FbTk::Resource:: getString() const { return **this; } template<> -std::string FbTk::Resource >:: +string FbTk::Resource >:: getString() const { string retval; for (size_t i = 0; i < m_value.size(); i++) { @@ -167,7 +170,7 @@ getString() const { } template<> -std::string FbTk::Resource:: +string FbTk::Resource:: getString() const { if (m_value == Fluxbox::ATTACH_AREA_TITLEBAR) return "Titlebar"; @@ -211,43 +214,43 @@ setFromString(const char *strval) { m_value = ::Layer::BOTTOM; else if (strcasecmp(strval, "Desktop") == 0) m_value = ::Layer::DESKTOP; - else + else setDefaultValue(); } template<> -std::string FbTk::Resource:: +string FbTk::Resource:: getString() const { switch (m_value.getNum()) { case Layer::MENU: - return std::string("Menu"); + return string("Menu"); case Layer::ABOVE_DOCK: - return std::string("AboveDock"); + return string("AboveDock"); case Layer::DOCK: - return std::string("Dock"); + return string("Dock"); case Layer::TOP: - return std::string("Top"); + return string("Top"); case Layer::NORMAL: - return std::string("Normal"); + return string("Normal"); case Layer::BOTTOM: - return std::string("Bottom"); + return string("Bottom"); case Layer::DESKTOP: - return std::string("Desktop"); + return string("Desktop"); default: char tmpstr[128]; sprintf(tmpstr, "%d", m_value.getNum()); - return std::string(tmpstr); + return string(tmpstr); } } template<> void FbTk::Resource:: -setFromString(const char *strval) { +setFromString(const char *strval) { if (sscanf(strval, "%ld", &m_value) != 1) setDefaultValue(); } - + template<> string FbTk::Resource:: getString() const { diff --git a/src/ScreenResources.cc b/src/ScreenResources.cc index 83bd7c95..0f17c2a4 100644 --- a/src/ScreenResources.cc +++ b/src/ScreenResources.cc @@ -27,7 +27,8 @@ #include "Screen.hh" #include -using namespace std; + +using std::string; namespace FbTk { @@ -53,17 +54,17 @@ void FbTk::Resource::setFromString(const char *str) { } template <> -std::string FbTk::Resource::getString() const { +string FbTk::Resource::getString() const { switch (m_value) { case BScreen::QUADRANTRESIZE: - return std::string("Quadrant"); + return string("Quadrant"); case BScreen::BOTTOMRESIZE: - return std::string("Bottom"); + return string("Bottom"); case BScreen::CENTERRESIZE: - return std::string("Center"); + return string("Center"); } - return std::string("Default"); + return string("Default"); } template<> @@ -75,25 +76,25 @@ setFromString(char const *strval) { m_value = BScreen::QUADRANTRESIZE; } else if (strcasecmp(strval, "Center") == 0) { m_value = BScreen::CENTERRESIZE; - } else + } else m_value = BScreen::DEFAULTRESIZE; } template<> -std::string FbTk::Resource::getString() const { +string FbTk::Resource::getString() const { switch (m_value) { case BScreen::FOLLOW_ACTIVE_WINDOW: - return std::string("Follow"); + return string("Follow"); break; case BScreen::FETCH_ACTIVE_WINDOW: - return std::string("Current"); + return string("Current"); break; case BScreen::SEMIFOLLOW_ACTIVE_WINDOW: - return std::string("SemiFollow"); + return string("SemiFollow"); break; case BScreen::IGNORE_OTHER_WORKSPACES: - default: - return std::string("Ignore"); + default: + return string("Ignore"); break; } @@ -104,7 +105,7 @@ void FbTk::Resource:: setFromString(char const *strval) { if (strcasecmp(strval, "Follow") == 0) m_value = BScreen::FOLLOW_ACTIVE_WINDOW; - else if (strcasecmp(strval, "Current") == 0 || + else if (strcasecmp(strval, "Current") == 0 || strcasecmp(strval, "CurrentWorkspace") == 0 || strcasecmp(strval, "Fetch") == 0) m_value = BScreen::FETCH_ACTIVE_WINDOW; @@ -115,7 +116,7 @@ setFromString(char const *strval) { } template<> -std::string FbTk::Resource::getString() const { +string FbTk::Resource::getString() const { switch(m_value) { case FbTk::GContext::LINESOLID: return "LineSolid"; @@ -132,20 +133,20 @@ std::string FbTk::Resource::getString() const { template<> void FbTk::Resource -::setFromString(char const *strval) { +::setFromString(char const *strval) { if (strcasecmp(strval, "LineSolid") == 0 ) m_value = FbTk::GContext::LINESOLID; else if (strcasecmp(strval, "LineOnOffDash") == 0 ) m_value = FbTk::GContext::LINEONOFFDASH; - else if (strcasecmp(strval, "LineDoubleDash") == 0) + else if (strcasecmp(strval, "LineDoubleDash") == 0) m_value = FbTk::GContext::LINEDOUBLEDASH; else setDefaultValue(); } template<> -std::string FbTk::Resource::getString() const { +string FbTk::Resource::getString() const { switch(m_value) { case FbTk::GContext::JOINMITER: return "JoinMiter"; @@ -162,20 +163,20 @@ std::string FbTk::Resource::getString() const { template<> void FbTk::Resource -::setFromString(char const *strval) { +::setFromString(char const *strval) { if (strcasecmp(strval, "JoinRound") == 0 ) m_value = FbTk::GContext::JOINROUND; else if (strcasecmp(strval, "JoinMiter") == 0 ) m_value = FbTk::GContext::JOINMITER; - else if (strcasecmp(strval, "JoinBevel") == 0) + else if (strcasecmp(strval, "JoinBevel") == 0) m_value = FbTk::GContext::JOINBEVEL; else setDefaultValue(); } template<> -std::string FbTk::Resource::getString() const { +string FbTk::Resource::getString() const { switch(m_value) { case FbTk::GContext::CAPNOTLAST: return "CapNotLast"; @@ -195,13 +196,13 @@ std::string FbTk::Resource::getString() const { template<> void FbTk::Resource -::setFromString(char const *strval) { +::setFromString(char const *strval) { if (strcasecmp(strval, "CapNotLast") == 0 ) m_value = FbTk::GContext::CAPNOTLAST; else if (strcasecmp(strval, "CapProjecting") == 0 ) m_value = FbTk::GContext::CAPPROJECTING; - else if (strcasecmp(strval, "CapRound") == 0) + else if (strcasecmp(strval, "CapRound") == 0) m_value = FbTk::GContext::CAPROUND; else if (strcasecmp(strval, "CapButt" ) == 0) m_value = FbTk::GContext::CAPBUTT; diff --git a/src/SystemTray.cc b/src/SystemTray.cc index e9adeae9..ea3e0bb0 100644 --- a/src/SystemTray.cc +++ b/src/SystemTray.cc @@ -36,7 +36,15 @@ #include -using namespace std; +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 { @@ -118,7 +126,7 @@ SystemTray::SystemTray(const FbTk::FbWindow& parent, ButtonTheme& theme, BScreen // setup atom name to _NET_SYSTEM_TRAY_S char intbuff[16]; sprintf(intbuff, "%d", m_window.screenNumber()); - std::string atom_name("_NET_SYSTEM_TRAY_S"); + string atom_name("_NET_SYSTEM_TRAY_S"); atom_name += intbuff; // append number // get selection owner and see if it's free @@ -240,7 +248,7 @@ bool SystemTray::clientMessage(const XClientMessageEvent &event) { int type = event.data.l[1]; if (type == SYSTEM_TRAY_REQUEST_DOCK) { -#ifndef DEBUG +#ifdef DEBUG cerr<<"SystemTray::clientMessage(const XClientMessageEvent): SYSTEM_TRAY_REQUEST_DOCK"<(event.xconfigure.height) != (*it)->height()) { // the position might differ so we update from our local // copy of position - XMoveResizeWindow(FbTk::App::instance()->display(), (*it)->window(), + XMoveResizeWindow(FbTk::App::instance()->display(), (*it)->window(), (*it)->x(), (*it)->y(), (*it)->width(), (*it)->height()); diff --git a/src/Toolbar.cc b/src/Toolbar.cc index f93465cb..f012570f 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc @@ -76,7 +76,9 @@ #include #include -using namespace std; +using std::string; +using std::pair; +using std::list; namespace FbTk { @@ -376,7 +378,7 @@ void Toolbar::reconfigure() { bool need_update = false; // parse and transform to lower case - std::list tools; + list tools; FbTk::StringUtil::stringtok(tools, *m_rc_tools, ", "); transform(tools.begin(), tools.end(), @@ -427,7 +429,7 @@ void Toolbar::reconfigure() { // show all items frame.window.showSubwindows(); } - + } else { // just update the menu menu().reconfigure(); } @@ -542,7 +544,7 @@ void Toolbar::buttonReleaseEvent(XButtonEvent &re) { screen().nextWorkspace(1); } } else if (re.button == 5) { //mousewheel scroll down - if(screen().isReverseWheeling()) { + if(screen().isReverseWheeling()) { screen().nextWorkspace(1); } else { screen().prevWorkspace(1); @@ -828,7 +830,7 @@ void Toolbar::setupMenus(bool skip_new_placement) { visible_macro->add(reconfig_toolbar); visible_macro->add(save_resources); RefCommand toggle_visible_cmd(visible_macro); - menu().insert(new BoolMenuItem(_FB_XTEXT(Common, Visible, + menu().insert(new BoolMenuItem(_FB_XTEXT(Common, Visible, "Visible", "Whether this item is visible"), *m_rc_visible, toggle_visible_cmd)); @@ -837,9 +839,9 @@ void Toolbar::setupMenus(bool skip_new_placement) { *m_rc_auto_hide, reconfig_toolbar_and_save_resource)); - MenuItem *toolbar_menuitem = - new IntResMenuItem(_FB_XTEXT(Toolbar, WidthPercent, - "Toolbar width percent", + MenuItem *toolbar_menuitem = + new IntResMenuItem(_FB_XTEXT(Toolbar, WidthPercent, + "Toolbar width percent", "Percentage of screen width taken by toolbar"), m_rc_width_percent, 0, 100, menu()); // min/max value @@ -849,7 +851,7 @@ void Toolbar::setupMenus(bool skip_new_placement) { menu().insert(toolbar_menuitem); menu().insert(new BoolMenuItem(_FB_XTEXT(Common, MaximizeOver, - "Maximize Over", + "Maximize Over", "Maximize over this thing when maximizing"), *m_rc_maximize_over, reconfig_toolbar_and_save_resource)); @@ -862,7 +864,7 @@ void Toolbar::setupMenus(bool skip_new_placement) { screen().imageControl(), *screen().layerManager().getLayer(::Layer::MENU), *this, - _FB_XTEXT(Toolbar, OnHead, "Toolbar on Head", + _FB_XTEXT(Toolbar, OnHead, "Toolbar on Head", "Title of toolbar on head menu"))); } #endif // XINERAMA @@ -911,7 +913,7 @@ void Toolbar::setupMenus(bool skip_new_placement) { menu().insert(_FB_XTEXT(Menu, Placement, "Placement", "Title of Placement menu"), &placementMenu()); placementMenu().updateMenu(); - + // this saves resources and clears the slit window to update alpha value FbTk::MenuItem *alpha_menuitem = diff --git a/src/Window.cc b/src/Window.cc index 29f8bca8..6fc40076 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -58,8 +58,8 @@ #endif // SHAPE //use GNU extensions -#ifndef _GNU_SOURCE -#define _GNU_SOURCE +#ifndef _GNU_SOURCE +#define _GNU_SOURCE #endif // _GNU_SOURCE #include @@ -84,9 +84,23 @@ #include #include -using namespace std; +using std::cerr; +using std::endl; +using std::string; +using std::vector; +using std::bind2nd; +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 + namespace { void grabButton(unsigned int button, @@ -439,7 +453,7 @@ void FluxboxWindow::init() { decorations.enabled = true; // set default values for decoration - decorations.menu = true; //override menu option + decorations.menu = true; //override menu option // all decorations on by default decorations.titlebar = decorations.border = decorations.handle = true; decorations.maximize = decorations.close = @@ -518,7 +532,7 @@ void FluxboxWindow::init() { if (fluxbox.isStartup()) place_window = false; - else if (m_client->isTransient() || + else if (m_client->isTransient() || m_client->normal_hint_flags & (PPosition|USPosition)) { int real_x = frame().x(); @@ -640,15 +654,15 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) { if (client.fbwindow() != 0) { FluxboxWindow *old_win = client.fbwindow(); // store old window - ClientList::iterator client_insert_pos = getClientInsertPosition(x, y); - FbTk::TextButton *button_insert_pos = NULL; - if (client_insert_pos != m_clientlist.end()) + ClientList::iterator client_insert_pos = getClientInsertPosition(x, y); + FbTk::TextButton *button_insert_pos = NULL; + if (client_insert_pos != m_clientlist.end()) button_insert_pos = m_labelbuttons[*client_insert_pos]; // make sure we set new window search for each client ClientList::iterator client_it = old_win->clientList().begin(); ClientList::iterator client_it_end = old_win->clientList().end(); - for (; client_it != client_it_end; ++client_it) { + for (; client_it != client_it_end; ++client_it) { // reparent window to this frame().setClientWindow(**client_it); if ((*client_it) == focused_win) @@ -665,7 +679,7 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) { associateClient(*(*client_it)); //null if we want the new button at the end of the list - if (x >= 0 && button_insert_pos) + if (x >= 0 && button_insert_pos) frame().moveLabelButtonLeftOf(*m_labelbuttons[*client_it], *button_insert_pos); (*client_it)->saveBlackboxAttribs(m_blackbox_attrib); @@ -673,8 +687,8 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) { // add client and move over all attached clients // from the old window to this list - m_clientlist.splice(client_insert_pos, old_win->m_clientlist); - updateClientLeftWindow(); + m_clientlist.splice(client_insert_pos, old_win->m_clientlist); + updateClientLeftWindow(); old_win->m_client = 0; delete old_win; @@ -879,7 +893,7 @@ void FluxboxWindow::moveClientLeft() { // move client in clientlist to the left ClientList::iterator oldpos = find(m_clientlist.begin(), m_clientlist.end(), &winClient()); ClientList::iterator newpos = oldpos; newpos--; - std::swap(*newpos, *oldpos); + swap(*newpos, *oldpos); frame().moveLabelButtonLeft(*m_labelbuttons[&winClient()]); updateClientLeftWindow(); @@ -893,13 +907,13 @@ void FluxboxWindow::moveClientRight() { ClientList::iterator oldpos = find(m_clientlist.begin(), m_clientlist.end(), &winClient()); ClientList::iterator newpos = oldpos; newpos++; - std::swap(*newpos, *oldpos); + swap(*newpos, *oldpos); frame().moveLabelButtonRight(*m_labelbuttons[&winClient()]); updateClientLeftWindow(); } -//std::list<*WinClient>::iterator FluxboxWindow::getClientInsertPosition(int x, int y) { +//list<*WinClient>::iterator FluxboxWindow::getClientInsertPosition(int x, int y) { FluxboxWindow::ClientList::iterator FluxboxWindow::getClientInsertPosition(int x, int y) { int dest_x = 0, dest_y = 0; @@ -2448,7 +2462,7 @@ void FluxboxWindow::mapRequestEvent(XMapRequestEvent &re) { if (wsp != 0 && isGroupable()) destroyed = wsp->checkGrouping(*this); - // if we weren't grouped with another window we deiconify ourself + // if we weren't grouped with another window we deiconify ourself if (!destroyed && !iconic) deiconify(false); @@ -2612,7 +2626,7 @@ void FluxboxWindow::propertyNotifyEvent(WinClient &client, Atom atom) { if (changed) setupWindow(); - } + } moveResize(frame().x(), frame().y(), frame().width(), frame().height()); @@ -3116,10 +3130,10 @@ void FluxboxWindow::setDecoration(Decoration decoration, bool apply) { decorations.iconify = decorations.maximize = decorations.tab = false; //tab is also a decor decorations.menu = true; // menu is present - // functions.iconify = functions.maximize = true; - // functions.move = true; // We need to move even without decor - // functions.resize = true; // We need to resize even without decor - break; + // functions.iconify = functions.maximize = true; + // functions.move = true; // We need to move even without decor + // functions.resize = true; // We need to resize even without decor + break; default: case DECOR_NORMAL: @@ -3128,7 +3142,7 @@ void FluxboxWindow::setDecoration(Decoration decoration, bool apply) { decorations.menu = decorations.tab = true; functions.resize = functions.move = functions.iconify = functions.maximize = true; - break; + break; case DECOR_TAB: decorations.border = decorations.iconify = decorations.maximize = @@ -3136,21 +3150,21 @@ void FluxboxWindow::setDecoration(Decoration decoration, bool apply) { decorations.titlebar = decorations.handle = false; functions.resize = functions.move = functions.iconify = functions.maximize = true; - break; + break; case DECOR_TINY: decorations.titlebar = decorations.iconify = decorations.menu = functions.move = functions.iconify = decorations.tab = true; decorations.border = decorations.handle = decorations.maximize = functions.resize = functions.maximize = false; - break; + break; case DECOR_TOOL: decorations.titlebar = decorations.tab = decorations.menu = functions.move = true; decorations.iconify = decorations.border = decorations.handle = decorations.maximize = functions.resize = functions.maximize = functions.iconify = false; - break; + break; } // we might want to wait with apply decorations @@ -3778,14 +3792,14 @@ Window FluxboxWindow::clientWindow() const { return m_client->window(); } -const std::string &FluxboxWindow::title() const { +const string &FluxboxWindow::title() const { static string empty_string(""); if (m_client == 0) return empty_string; return m_client->title(); } -const std::string &FluxboxWindow::iconTitle() const { +const string &FluxboxWindow::iconTitle() const { static string empty_string(""); if (m_client == 0) return empty_string; @@ -3992,10 +4006,10 @@ void FluxboxWindow::setupWindow() { // clear old buttons from frame frame().removeAllButtons(); - typedef FbTk::Resource > WinButtonsResource; + typedef FbTk::Resource > WinButtonsResource; - std::string titlebar_name[2]; - std::string titlebar_alt_name[2]; + string titlebar_name[2]; + string titlebar_alt_name[2]; titlebar_name[0] = screen().name() + ".titlebar.left"; titlebar_alt_name[0] = screen().altName() + ".Titlebar.Left"; titlebar_name[1] = screen().name() + ".titlebar.right"; @@ -4050,7 +4064,7 @@ void FluxboxWindow::setupWindow() { for (size_t c = 0; c < 2 ; c++) { // get titlebar configuration for current side - const std::vector &dir = *(*titlebar_side[c]); + const vector &dir = *(*titlebar_side[c]); for (size_t i=0; i < dir.size(); ++i) { //create new buttons @@ -4142,10 +4156,10 @@ void FluxboxWindow::setupWindow() { if (screen().getScrollReverse()) reverse = 1; - if (StringUtil::toLower(screen().getScrollAction()) == std::string("shade")) { + if (StringUtil::toLower(screen().getScrollAction()) == string("shade")) { frame().setOnClickTitlebar(shade_on_cmd, 5 - reverse); // shade on mouse roll frame().setOnClickTitlebar(shade_off_cmd, 4 + reverse); // unshade if rolled oposite direction - } else if (StringUtil::toLower(screen().getScrollAction()) == std::string("nexttab")) { + } else if (StringUtil::toLower(screen().getScrollAction()) == string("nexttab")) { frame().setOnClickTitlebar(next_tab_cmd, 5 - reverse); // next tab frame().setOnClickTitlebar(prev_tab_cmd, 4 + reverse); // previous tab } diff --git a/src/Workspace.cc b/src/Workspace.cc index 83db8efe..236aadbd 100644 --- a/src/Workspace.cc +++ b/src/Workspace.cc @@ -67,7 +67,14 @@ #include #include -using namespace std; +using std::string; +using std::vector; +using std::ifstream; + +#ifdef DEBUG +using std::cerr; +using std::endl; +#endif // DEBUG namespace { // anonymous @@ -75,7 +82,7 @@ int countTransients(const WinClient &client) { if (client.transientList().empty()) return 0; // now go throu the entire tree and count transients - size_t ret = client.transientList().size(); + size_t ret = client.transientList().size(); WinClient::TransientList::const_iterator it = client.transientList().begin(); WinClient::TransientList::const_iterator it_end = client.transientList().end(); for (; it != it_end; ++it) @@ -89,7 +96,7 @@ public: ClientMenuItem(WinClient &client): FbTk::MenuItem(client.title().c_str(), &client.screen().windowMenu()), m_client(client) { - + } FbTk::Menu *submenu() { return &m_client.screen().windowMenu(); } const FbTk::Menu *submenu() const { return &m_client.screen().windowMenu(); } @@ -123,14 +130,14 @@ public: win.raiseAndFocus(); } - const std::string &label() const { return m_client.title(); } - bool isSelected() const { + const string &label() const { return m_client.title(); } + bool isSelected() const { if (m_client.fbwindow() == 0) return false; if (m_client.fbwindow()->isFocused() == false) return false; return (&(m_client.fbwindow()->winClient()) == &m_client); - + } private: WinClient &m_client; @@ -140,8 +147,8 @@ private: Workspace::GroupList Workspace::m_groups; -Workspace::Workspace(BScreen &scrn, FbTk::MultLayers &layermanager, - const std::string &name, unsigned int id): +Workspace::Workspace(BScreen &scrn, FbTk::MultLayers &layermanager, + const string &name, unsigned int id): m_screen(scrn), m_clientmenu(scrn.menuTheme(), scrn.imageControl(), *scrn.layerManager().getLayer(Layer::MENU)), @@ -174,9 +181,9 @@ void Workspace::addWindow(FluxboxWindow &w, bool place) { updateClientmenu(); if (!w.isStuck()) { - FluxboxWindow::ClientList::iterator client_it = + FluxboxWindow::ClientList::iterator client_it = w.clientList().begin(); - FluxboxWindow::ClientList::iterator client_it_end = + FluxboxWindow::ClientList::iterator client_it_end = w.clientList().end(); for (; client_it != client_it_end; ++client_it) screen().updateNetizenWindowAdd((*client_it)->window(), m_id); @@ -185,7 +192,7 @@ void Workspace::addWindow(FluxboxWindow &w, bool place) { } // still_alive is true if the window will continue to exist after -// this event. Particularly, this isn't the removeWindow for +// this event. Particularly, this isn't the removeWindow for // the destruction of the window. Because if so, the focus revert // is done in another place int Workspace::removeWindow(FluxboxWindow *w, bool still_alive) { @@ -198,9 +205,9 @@ int Workspace::removeWindow(FluxboxWindow *w, bool still_alive) { if (w->isFocused() && still_alive) FocusControl::unfocusWindow(w->winClient(), true, true); - + // we don't remove it from the layermanager, as it may be being moved - Windows::iterator erase_it = remove(m_windowlist.begin(), + Windows::iterator erase_it = remove(m_windowlist.begin(), m_windowlist.end(), w); if (erase_it != m_windowlist.end()) m_windowlist.erase(erase_it); @@ -208,9 +215,9 @@ int Workspace::removeWindow(FluxboxWindow *w, bool still_alive) { updateClientmenu(); if (!w->isStuck()) { - FluxboxWindow::ClientList::iterator client_it = + FluxboxWindow::ClientList::iterator client_it = w->clientList().begin(); - FluxboxWindow::ClientList::iterator client_it_end = + FluxboxWindow::ClientList::iterator client_it_end = w->clientList().end(); for (; client_it != client_it_end; ++client_it) screen().updateNetizenWindowDel((*client_it)->window()); @@ -308,8 +315,8 @@ bool Workspace::checkGrouping(FluxboxWindow &win) { #ifdef DEBUG cerr<<__FILE__<<" check group with : "<<(*wit)->winClient().getWMClassName()<attachClient(win.winClient()); (*wit)->raise(); return true; // grouping done - + } - + } } @@ -333,7 +340,7 @@ bool Workspace::checkGrouping(FluxboxWindow &win) { return false; } -bool Workspace::loadGroups(const std::string &filename) { +bool Workspace::loadGroups(const string &filename) { string real_filename = FbTk::StringUtil::expandFilename(filename); FbTk::StringUtil::removeTrailingWhitespace(real_filename); ifstream infile(real_filename.c_str()); @@ -350,7 +357,7 @@ bool Workspace::loadGroups(const std::string &filename) { FbTk::StringUtil::stringtok(names, line); m_groups.push_back(names); } - + return true; } @@ -359,18 +366,18 @@ void Workspace::update(FbTk::Subject *subj) { } -void Workspace::setName(const std::string &name) { +void Workspace::setName(const string &name) { if (!name.empty() && name != "") { m_name = name; } else { //if name == 0 then set default name from nls _FB_USES_NLS; char tname[128]; - sprintf(tname, - _FB_XTEXT(Workspace, DefaultNameFormat, + sprintf(tname, + _FB_XTEXT(Workspace, DefaultNameFormat, "Workspace %d", "Default workspace names, with a %d for the workspace number").c_str(), m_id + 1); //m_id starts at 0 } - + screen().updateWorkspaceNamesAtom(); menu().setLabel(m_name); @@ -386,21 +393,21 @@ void Workspace::shutdown() { // note: when the window dies it'll remove it self from the list while (!m_windowlist.empty()) { //delete window (the window removes it self from m_windowlist) - delete m_windowlist.back(); + delete m_windowlist.back(); } } void Workspace::updateClientmenu() { // remove all items and then add them again menu().removeAll(); - // for each fluxboxwindow add every client in them to our clientlist + // for each fluxboxwindow add every client in them to our clientlist Windows::iterator win_it = m_windowlist.begin(); Windows::iterator win_it_end = m_windowlist.end(); for (; win_it != win_it_end; ++win_it) { // add every client in this fluxboxwindow to menu - FluxboxWindow::ClientList::iterator client_it = + FluxboxWindow::ClientList::iterator client_it = (*win_it)->clientList().begin(); - FluxboxWindow::ClientList::iterator client_it_end = + FluxboxWindow::ClientList::iterator client_it_end = (*win_it)->clientList().end(); for (; client_it != client_it_end; ++client_it) menu().insert(new ClientMenuItem(*(*client_it))); @@ -411,7 +418,7 @@ void Workspace::updateClientmenu() { void Workspace::placeWindow(FluxboxWindow &win) { int place_x, place_y; - // we ignore the return value, + // we ignore the return value, // the screen placement strategy is guaranteed to succeed. screen().placementStrategy().placeWindow(m_windowlist, win, diff --git a/src/Xutil.cc b/src/Xutil.cc index 87f52534..c1381424 100644 --- a/src/Xutil.cc +++ b/src/Xutil.cc @@ -32,7 +32,13 @@ #include #include #include -using namespace std; + +using std::string; + +#ifdef DEBUG +using std::cerr; +using std::endl; +#endif // DEBUG namespace Xutil { @@ -48,14 +54,14 @@ FbTk::FbString getWMName(Window window) { char **list; int num; _FB_USES_NLS; - std::string name; + string name; if (XGetWMName(display, window, &text_prop)) { if (text_prop.value && text_prop.nitems > 0) { if (text_prop.encoding != XA_STRING) { - + text_prop.nitems = strlen((char *) text_prop.value); - + if ((XmbTextPropertyToTextList(display, &text_prop, &list, &num) == Success) && (num > 0) && *list) { @@ -63,7 +69,7 @@ FbTk::FbString getWMName(Window window) { XFreeStringList(list); } else name = text_prop.value ? FbTk::FbStringUtil::XStrToFb((char *)text_prop.value) : ""; - + } else name = text_prop.value ? FbTk::FbStringUtil::XStrToFb((char *)text_prop.value) : ""; @@ -82,19 +88,19 @@ FbTk::FbString getWMName(Window window) { // The name of this particular instance -std::string getWMClassName(Window win) { +string getWMClassName(Window win) { XClassHint ch; - std::string instance_name; + string instance_name; if (XGetClassHint(FbTk::App::instance()->display(), win, &ch) == 0) { #ifdef DEBUG cerr<<"Xutil: Failed to read class hint!"<(ch.res_name); XFree(ch.res_name); @@ -108,19 +114,19 @@ std::string getWMClassName(Window win) { } // the name of the general class of the app -std::string getWMClassClass(Window win) { +string getWMClassClass(Window win) { XClassHint ch; - std::string class_name; + string class_name; if (XGetClassHint(FbTk::App::instance()->display(), win, &ch) == 0) { #ifdef DEBUG cerr<<"Xutil: Failed to read class hint!"<(ch.res_class); XFree(ch.res_class); diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 59859ad1..b23ab704 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -154,7 +154,21 @@ class Toolbar { }; #include #include -using namespace std; +using std::cerr; +using std::endl; +using std::string; +using std::vector; +using std::list; +using std::pair; +using std::bind2nd; +using std::mem_fun; +using std::equal_to; + +#ifdef DEBUG +using std::hex; +using std::dec; +#endif // DEBUG + using namespace FbTk; namespace { @@ -1348,7 +1362,7 @@ BScreen *Fluxbox::searchScreen(Window window) { } -AtomHandler* Fluxbox::getAtomHandler(const std::string &name) { +AtomHandler* Fluxbox::getAtomHandler(const string &name) { if ( name != "" ) { using namespace FbTk; AtomHandlerContainerIt it = find_if(m_atomhandler.begin(), @@ -1360,7 +1374,7 @@ AtomHandler* Fluxbox::getAtomHandler(const std::string &name) { } return 0; } -void Fluxbox::addAtomHandler(AtomHandler *atomh, const std::string &name) { +void Fluxbox::addAtomHandler(AtomHandler *atomh, const string &name) { m_atomhandler[atomh]= name;; } @@ -1514,7 +1528,7 @@ string Fluxbox::getRcFilename() { } /// Provides default filename of data file -void Fluxbox::getDefaultDataFilename(char *name, std::string &filename) { +void Fluxbox::getDefaultDataFilename(char *name, string &filename) { filename = string(getenv("HOME") + string("/.") + m_RC_PATH + string("/") + name); } @@ -1607,7 +1621,7 @@ void Fluxbox::load_rc(BScreen &screen) { sprintf(class_lookup, "Session.Screen%d.imageSearchPath", screen_number); if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, &value) && value.addr) { - std::vector paths; + vector paths; StringUtil::stringtok(paths, value.addr, ", "); for (size_t i = 0; i < paths.size(); ++i) FbTk::Image::addSearchPath(paths[i]); @@ -1685,8 +1699,8 @@ BScreen *Fluxbox::findScreen(int id) { } bool Fluxbox::menuTimestampsChanged() const { - std::list::const_iterator it = m_menu_timestamps.begin(); - std::list::const_iterator it_end = m_menu_timestamps.end(); + list::const_iterator it = m_menu_timestamps.begin(); + list::const_iterator it_end = m_menu_timestamps.end(); for (; it != it_end; ++it) { time_t timestamp = FbTk::FileUtil::getLastStatusChangeTimestamp((*it)->filename.c_str()); @@ -1745,8 +1759,8 @@ void Fluxbox::saveMenuFilename(const char *filename) { bool found = false; - std::list::iterator it = m_menu_timestamps.begin(); - std::list::iterator it_end = m_menu_timestamps.end(); + list::iterator it = m_menu_timestamps.begin(); + list::iterator it_end = m_menu_timestamps.end(); for (; it != it_end; ++it) { if ((*it)->filename == filename) { found = true; diff --git a/src/tests/testFont.cc b/src/tests/testFont.cc index e5e2377a..7d097bd8 100644 --- a/src/tests/testFont.cc +++ b/src/tests/testFont.cc @@ -85,7 +85,6 @@ public: int by1 = 0; int bx2 = text_w; int by2 = 0; - int tmp; switch (m_orient) { case FbTk::ROT90: @@ -99,6 +98,8 @@ public: by2 = -bx2; bx2 = 0; break; + default: + break; } /* diff --git a/util/fbrun/FbRun.cc b/util/fbrun/FbRun.cc index c175e673..7797f769 100644 --- a/util/fbrun/FbRun.cc +++ b/util/fbrun/FbRun.cc @@ -49,7 +49,13 @@ #include #include -using namespace std; +using std::cerr; +using std::endl; +using std::string; +using std::fstream; +using std::ifstream; +using std::ofstream; +using std::ios; FbRun::FbRun(int x, int y, size_t width): FbTk::TextBox(DefaultScreen(FbTk::App::instance()->display()), diff --git a/util/fbrun/main.cc b/util/fbrun/main.cc index 878b5ebe..e5d3e2f6 100644 --- a/util/fbrun/main.cc +++ b/util/fbrun/main.cc @@ -35,7 +35,9 @@ extern "C" { #include #include -using namespace std; +using std::cerr; +using std::endl; +using std::string; void showUsage(const char *progname) { cerr<<"fbrun 1.5 : (c) 2002-2004 Henrik Kinnunen"<display(); - - if (XQueryPointer(dpy, DefaultRootWindow(dpy), + + if (XQueryPointer(dpy, DefaultRootWindow(dpy), &ret_win, &child_win, &x, &y, &wx, &wy, &mask)) { @@ -202,12 +204,12 @@ int main(int argc, char **argv) { y = root_y + root_h - fbrun.height(); } } - + if (set_pos) fbrun.move(x, y); fbrun.lockPosition(set_pos); - + fbrun.show(); application.eventLoop(); diff --git a/util/fbsetroot.cc b/util/fbsetroot.cc index 54f5adb8..9d2cf73b 100644 --- a/util/fbsetroot.cc +++ b/util/fbsetroot.cc @@ -50,7 +50,10 @@ #endif #include -using namespace std; +using std::cout; +using std::cerr; +using std::endl; +using std::string; fbsetroot::fbsetroot(int argc, char **argv, char *dpy_name) : FbTk::App(dpy_name), m_app_name(argv[0]) { @@ -118,7 +121,7 @@ fbsetroot::fbsetroot(int argc, char **argv, char *dpy_name) if ((mod + sol + grd) != true) { _FB_USES_NLS; - cerr << _FB_CONSOLETEXT(fbsetroot, MustSpecify, + cerr << _FB_CONSOLETEXT(fbsetroot, MustSpecify, "Error: must specify one of: -solid, -mod, -gradient\n", "user didn't give one of the required options") << endl; @@ -172,10 +175,10 @@ void fbsetroot::setRootAtoms(Pixmap pixmap, int screen) { if (type == XA_PIXMAP) { root.property(atom_eroot, 0L, 1L, False, AnyPropertyType, &type, &format, &length, &after, &data_eroot); - + if (data_root && data_eroot && type == XA_PIXMAP && *((Pixmap *) data_root) == *((Pixmap *) data_eroot)) { - + XKillClient(display(), *((Pixmap *) data_root)); } } @@ -197,7 +200,7 @@ void fbsetroot::setRootAtoms(Pixmap pixmap, int screen) { } /** - Draws pixmaps with a single color + Draws pixmaps with a single color */ void fbsetroot::solid() { FbTk::Color c(fore, screen); @@ -209,7 +212,7 @@ void fbsetroot::solid() { FbTk::GContext gc(root); gc.setForeground(c); - pixmap = new Pixmap(XCreatePixmap(display(), + pixmap = new Pixmap(XCreatePixmap(display(), root.window(), root.width(), root.height(), root.depth())); @@ -282,7 +285,7 @@ void fbsetroot::modula(int x, int y) { gc.setTile(r_bitmap); gc.setFillStyle(FillTiled); - pixmap = new Pixmap(XCreatePixmap(display(), + pixmap = new Pixmap(XCreatePixmap(display(), root.window(), root.width(), root.height(), root.depth())); @@ -328,7 +331,7 @@ void fbsetroot::gradient() { tmp = img_ctrl->renderImage(root.width(), root.height(), texture); - pixmap = new Pixmap(XCreatePixmap(display(), + pixmap = new Pixmap(XCreatePixmap(display(), root.window(), root.width(), root.height(), root.depth())); @@ -376,9 +379,9 @@ void fbsetroot::usage(int exit_code) { int main(int argc, char **argv) { char *display_name = (char *) 0; int i = 1; - + FbTk::NLSInit("fluxbox.cat"); - + for (; i < argc; i++) { if (! strcmp(argv[i], "-display")) { // check for -display option @@ -398,7 +401,7 @@ int main(int argc, char **argv) { try { fbsetroot app(argc, argv, display_name); - } catch (std::string error_str) { + } catch (string error_str) { _FB_USES_NLS; cerr<<_FB_CONSOLETEXT(Common, Error, "Error", "Error message header")<<": "<