From fbcdd34b223174a28ff712b7d03e56339fa2fe07 Mon Sep 17 00:00:00 2001 From: Mathias Gumz Date: Sun, 23 May 2010 12:25:47 +0200 Subject: mostly cosmetic fixes, mainly discovered by 'clang --analyze' reordering of Resource-related stuff was because of "error: explicit specialization of 'getString' after instantiation" complaints. --- src/FbTk/TextureRender.cc | 2 +- src/FbWinFrame.cc | 2 +- src/IconButton.cc | 6 +- src/Keys.cc | 2 +- src/Resources.cc | 151 +++++++++++++++++++++++----------------------- src/Screen.cc | 63 +++++++++---------- src/ScreenPlacement.cc | 61 ++++++++++--------- src/Slit.cc | 60 +++++++++--------- src/Toolbar.cc | 63 +++++++++---------- 9 files changed, 208 insertions(+), 202 deletions(-) diff --git a/src/FbTk/TextureRender.cc b/src/FbTk/TextureRender.cc index 73c1a94..116142d 100644 --- a/src/FbTk/TextureRender.cc +++ b/src/FbTk/TextureRender.cc @@ -68,7 +68,7 @@ TextureRender::TextureRender(ImageControl &imgctrl, XColor *_colors, size_t num_colors): control(imgctrl), colors(_colors), - ncolors(ncolors), + ncolors(static_cast(num_colors)), cpc(imgctrl.colorsPerChannel()), cpccpc(cpc * cpc), red(0), green(0), blue(0), diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index 2975252..b311be6 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc @@ -160,7 +160,7 @@ bool FbWinFrame::setTabMode(TabMode tabmode) { // reconfigure(); } - return true; + return ret; } void FbWinFrame::hide() { diff --git a/src/IconButton.cc b/src/IconButton.cc index 320918c..0a50661 100644 --- a/src/IconButton.cc +++ b/src/IconButton.cc @@ -189,8 +189,10 @@ void IconButton::refreshEverything(bool setup) { unsigned int w = width(); unsigned int h = height(); FbTk::translateSize(orientation(), w, h); - int iconx = 1, icony = 1; - unsigned int neww = w, newh = h; + int iconx = 1; + int icony = 1; + unsigned int neww; + unsigned int newh = h; if (newh > 2*static_cast(icony)) newh -= 2*icony; else diff --git a/src/Keys.cc b/src/Keys.cc index f03dc01..2b64656 100644 --- a/src/Keys.cc +++ b/src/Keys.cc @@ -458,7 +458,7 @@ bool Keys::addBinding(const string &linebuffer) { } else if (extractKeyFromString(arg, "move", key)) { type = MotionNotify; - } else if (key = FbTk::KeyUtil::getKey(val[argc].c_str())) { // convert from string symbol + } else if ((key = FbTk::KeyUtil::getKey(val[argc].c_str()))) { // convert from string symbol type = KeyPress; // keycode covers the following three two-byte cases: diff --git a/src/Resources.cc b/src/Resources.cc index 60c7461..734cd75 100644 --- a/src/Resources.cc +++ b/src/Resources.cc @@ -49,6 +49,14 @@ using namespace FbTk; namespace FbTk { template<> +string FbTk::Resource:: +getString() const { + char strval[256]; + sprintf(strval, "%d", **this); + return string(strval); +} + +template<> void FbTk::Resource:: setFromString(const char* strval) { int val; @@ -57,70 +65,16 @@ setFromString(const char* strval) { } template<> -void FbTk::Resource:: -setFromString(const char *strval) { - *this = strval; -} - -template<> -void FbTk::Resource:: -setFromString(char const *strval) { - *this = (bool)!strcasecmp(strval, "true"); -} - -template<> -void FbTk::Resource >:: -setFromString(char const *strval) { - vector val; - StringUtil::stringtok(val, strval); - //clear old values - m_value.clear(); - - std::string v; - for (size_t i = 0; i < val.size(); i++) { - v = FbTk::StringUtil::toLower(val[i]); - if (v == "maximize") - m_value.push_back(WinButton::MAXIMIZE); - else if (v == "minimize") - m_value.push_back(WinButton::MINIMIZE); - else if (v == "shade") - m_value.push_back(WinButton::SHADE); - else if (v == "stick") - m_value.push_back(WinButton::STICK); - else if (v == "menuIcon") - m_value.push_back(WinButton::MENUICON); - else if (v == "close") - m_value.push_back(WinButton::CLOSE); - } -} - -template<> -void FbTk::Resource:: -setFromString(char const *strval) { - if (strcasecmp(strval, "Titlebar")==0) - m_value= Fluxbox::ATTACH_AREA_TITLEBAR; - else - m_value= Fluxbox::ATTACH_AREA_WINDOW; -} - -template<> -void FbTk::Resource:: -setFromString(const char *strval) { - if (sscanf(strval, "%ul", &m_value) != 1) - setDefaultValue(); -} +string FbTk::Resource:: +getString() const { return **this; } template<> -void FbTk::Resource:: +void FbTk::Resource:: setFromString(const char *strval) { - if (sscanf(strval, "%lld", &m_value) != 1) - setDefaultValue(); + *this = strval; } -//----------------------------------------------------------------- -//---- manipulators for int, bool, and some enums with Resource --- -//----------------------------------------------------------------- template<> string FbTk::Resource:: getString() const { @@ -128,17 +82,11 @@ getString() const { } template<> -string FbTk::Resource:: -getString() const { - char strval[256]; - sprintf(strval, "%d", **this); - return string(strval); +void FbTk::Resource:: +setFromString(char const *strval) { + *this = (bool)!strcasecmp(strval, "true"); } -template<> -string FbTk::Resource:: -getString() const { return **this; } - template<> string FbTk::Resource >:: @@ -173,6 +121,34 @@ getString() const { return retval; } + + +template<> +void FbTk::Resource >:: +setFromString(char const *strval) { + vector val; + StringUtil::stringtok(val, strval); + //clear old values + m_value.clear(); + + std::string v; + for (size_t i = 0; i < val.size(); i++) { + v = FbTk::StringUtil::toLower(val[i]); + if (v == "maximize") + m_value.push_back(WinButton::MAXIMIZE); + else if (v == "minimize") + m_value.push_back(WinButton::MINIMIZE); + else if (v == "shade") + m_value.push_back(WinButton::SHADE); + else if (v == "stick") + m_value.push_back(WinButton::STICK); + else if (v == "menuIcon") + m_value.push_back(WinButton::MENUICON); + else if (v == "close") + m_value.push_back(WinButton::CLOSE); + } +} + template<> string FbTk::Resource:: getString() const { @@ -183,6 +159,15 @@ getString() const { } template<> +void FbTk::Resource:: +setFromString(char const *strval) { + if (strcasecmp(strval, "Titlebar")==0) + m_value= Fluxbox::ATTACH_AREA_TITLEBAR; + else + m_value= Fluxbox::ATTACH_AREA_WINDOW; +} + +template<> string FbTk::Resource:: getString() const { char tmpstr[128]; @@ -191,6 +176,14 @@ getString() const { } template<> +void FbTk::Resource:: +setFromString(const char *strval) { + if (sscanf(strval, "%ul", &m_value) != 1) + setDefaultValue(); +} + + +template<> string FbTk::Resource:: getString() const { char tmpstr[128]; @@ -199,13 +192,9 @@ getString() const { } template<> -void FbTk::Resource:: +void FbTk::Resource:: setFromString(const char *strval) { - string str(strval); - int tempnum = ::Layer::getNumFromString(str); - if (tempnum >= 0 && tempnum < ::Layer::NUM_LAYERS) - m_value = tempnum; - else + if (sscanf(strval, "%lld", &m_value) != 1) setDefaultValue(); } @@ -217,9 +206,13 @@ getString() const { } template<> -void FbTk::Resource:: +void FbTk::Resource:: setFromString(const char *strval) { - if (sscanf(strval, "%ld", &m_value) != 1) + string str(strval); + int tempnum = ::Layer::getNumFromString(str); + if (tempnum >= 0 && tempnum < ::Layer::NUM_LAYERS) + m_value = tempnum; + else setDefaultValue(); } @@ -230,4 +223,12 @@ getString() const { sprintf(tmpstr, "%ld", m_value); return string(tmpstr); } + +template<> +void FbTk::Resource:: +setFromString(const char *strval) { + if (sscanf(strval, "%ld", &m_value) != 1) + setDefaultValue(); +} + } // end namespace FbTk diff --git a/src/Screen.cc b/src/Screen.cc index c2929d0..b712b81 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -209,37 +209,6 @@ private: namespace FbTk { template<> -void FbTk::Resource:: -setFromString(const char *strval) { - if (strcasecmp(strval, "TopLeft") == 0) - m_value = FbWinFrame::TOPLEFT; - else if (strcasecmp(strval, "BottomLeft") == 0) - m_value = FbWinFrame::BOTTOMLEFT; - else if (strcasecmp(strval, "Top") == 0) - m_value = FbWinFrame::TOP; - else if (strcasecmp(strval, "Bottom") == 0) - m_value = FbWinFrame::BOTTOM; - else if (strcasecmp(strval, "TopRight") == 0) - m_value = FbWinFrame::TOPRIGHT; - else if (strcasecmp(strval, "BottomRight") == 0) - m_value = FbWinFrame::BOTTOMRIGHT; - else if (strcasecmp(strval, "LeftTop") == 0) - m_value = FbWinFrame::LEFTTOP; - else if (strcasecmp(strval, "Left") == 0) - m_value = FbWinFrame::LEFT; - else if (strcasecmp(strval, "LeftBottom") == 0) - m_value = FbWinFrame::LEFTBOTTOM; - else if (strcasecmp(strval, "RightTop") == 0) - m_value = FbWinFrame::RIGHTTOP; - else if (strcasecmp(strval, "Right") == 0) - m_value = FbWinFrame::RIGHT; - else if (strcasecmp(strval, "RightBottom") == 0) - m_value = FbWinFrame::RIGHTBOTTOM; - else - setDefaultValue(); -} - -template<> string FbTk::Resource:: getString() const { switch (m_value) { @@ -283,6 +252,38 @@ getString() const { //default string return string("TopLeft"); } + +template<> +void FbTk::Resource:: +setFromString(const char *strval) { + if (strcasecmp(strval, "TopLeft") == 0) + m_value = FbWinFrame::TOPLEFT; + else if (strcasecmp(strval, "BottomLeft") == 0) + m_value = FbWinFrame::BOTTOMLEFT; + else if (strcasecmp(strval, "Top") == 0) + m_value = FbWinFrame::TOP; + else if (strcasecmp(strval, "Bottom") == 0) + m_value = FbWinFrame::BOTTOM; + else if (strcasecmp(strval, "TopRight") == 0) + m_value = FbWinFrame::TOPRIGHT; + else if (strcasecmp(strval, "BottomRight") == 0) + m_value = FbWinFrame::BOTTOMRIGHT; + else if (strcasecmp(strval, "LeftTop") == 0) + m_value = FbWinFrame::LEFTTOP; + else if (strcasecmp(strval, "Left") == 0) + m_value = FbWinFrame::LEFT; + else if (strcasecmp(strval, "LeftBottom") == 0) + m_value = FbWinFrame::LEFTBOTTOM; + else if (strcasecmp(strval, "RightTop") == 0) + m_value = FbWinFrame::RIGHTTOP; + else if (strcasecmp(strval, "Right") == 0) + m_value = FbWinFrame::RIGHT; + else if (strcasecmp(strval, "RightBottom") == 0) + m_value = FbWinFrame::RIGHTBOTTOM; + else + setDefaultValue(); +} + } // end namespace FbTk diff --git a/src/ScreenPlacement.cc b/src/ScreenPlacement.cc index a617956..3e0c377 100644 --- a/src/ScreenPlacement.cc +++ b/src/ScreenPlacement.cc @@ -132,24 +132,6 @@ bool ScreenPlacement::placeWindow(const FluxboxWindow &win, int head, ////////////////////// Placement Resources namespace FbTk { - -template <> -void FbTk::Resource::setFromString(const char *str) { - if (strcasecmp("RowSmartPlacement", str) == 0) - *(*this) = ScreenPlacement::ROWSMARTPLACEMENT; - else if (strcasecmp("ColSmartPlacement", str) == 0) - *(*this) = ScreenPlacement::COLSMARTPLACEMENT; - else if (strcasecmp("RowMinOverlapPlacement", str) == 0) - *(*this) = ScreenPlacement::ROWMINOVERLAPPLACEMENT; - else if (strcasecmp("ColMinOverlapPlacement", str) == 0) - *(*this) = ScreenPlacement::COLMINOVERLAPPLACEMENT; - else if (strcasecmp("UnderMousePlacement", str) == 0) - *(*this) = ScreenPlacement::UNDERMOUSEPLACEMENT; - else if (strcasecmp("CascadePlacement", str) == 0) - *(*this) = ScreenPlacement::CASCADEPLACEMENT; - else - setDefaultValue(); -} template <> std::string FbTk::Resource::getString() const { @@ -172,16 +154,24 @@ std::string FbTk::Resource::getString() const } template <> -void FbTk::Resource::setFromString(const char *str) { - if (strcasecmp("LeftToRight", str) == 0) - *(*this) = ScreenPlacement::LEFTRIGHT; - else if (strcasecmp("RightToLeft", str) == 0) - *(*this) = ScreenPlacement::RIGHTLEFT; +void FbTk::Resource::setFromString(const char *str) { + if (strcasecmp("RowSmartPlacement", str) == 0) + *(*this) = ScreenPlacement::ROWSMARTPLACEMENT; + else if (strcasecmp("ColSmartPlacement", str) == 0) + *(*this) = ScreenPlacement::COLSMARTPLACEMENT; + else if (strcasecmp("RowMinOverlapPlacement", str) == 0) + *(*this) = ScreenPlacement::ROWMINOVERLAPPLACEMENT; + else if (strcasecmp("ColMinOverlapPlacement", str) == 0) + *(*this) = ScreenPlacement::COLMINOVERLAPPLACEMENT; + else if (strcasecmp("UnderMousePlacement", str) == 0) + *(*this) = ScreenPlacement::UNDERMOUSEPLACEMENT; + else if (strcasecmp("CascadePlacement", str) == 0) + *(*this) = ScreenPlacement::CASCADEPLACEMENT; else setDefaultValue(); - } + template <> std::string FbTk::Resource::getString() const { switch (*(*this)) { @@ -196,14 +186,13 @@ std::string FbTk::Resource::getString() const { template <> -void FbTk::Resource::setFromString(const char *str) { - if (strcasecmp("TopToBottom", str) == 0) - *(*this) = ScreenPlacement::TOPBOTTOM; - else if (strcasecmp("BottomToTop", str) == 0) - *(*this) = ScreenPlacement::BOTTOMTOP; +void FbTk::Resource::setFromString(const char *str) { + if (strcasecmp("LeftToRight", str) == 0) + *(*this) = ScreenPlacement::LEFTRIGHT; + else if (strcasecmp("RightToLeft", str) == 0) + *(*this) = ScreenPlacement::RIGHTLEFT; else setDefaultValue(); - } template <> @@ -217,4 +206,16 @@ std::string FbTk::Resource::getString() const return "TopToBottom"; } + + +template <> +void FbTk::Resource::setFromString(const char *str) { + if (strcasecmp("TopToBottom", str) == 0) + *(*this) = ScreenPlacement::TOPBOTTOM; + else if (strcasecmp("BottomToTop", str) == 0) + *(*this) = ScreenPlacement::BOTTOMTOP; + else + setDefaultValue(); +} + } // end namespace FbTk diff --git a/src/Slit.cc b/src/Slit.cc index fb3da30..7aaa096 100644 --- a/src/Slit.cc +++ b/src/Slit.cc @@ -90,36 +90,6 @@ using std::dec; namespace FbTk { template<> -void FbTk::Resource::setFromString(const char *strval) { - if (strcasecmp(strval, "TopLeft")==0) - m_value = Slit::TOPLEFT; - else if (strcasecmp(strval, "LeftCenter")==0) - m_value = Slit::LEFTCENTER; - else if (strcasecmp(strval, "BottomLeft")==0) - m_value = Slit::BOTTOMLEFT; - else if (strcasecmp(strval, "TopCenter")==0) - m_value = Slit::TOPCENTER; - else if (strcasecmp(strval, "BottomCenter")==0) - m_value = Slit::BOTTOMCENTER; - else if (strcasecmp(strval, "TopRight")==0) - m_value = Slit::TOPRIGHT; - else if (strcasecmp(strval, "RightCenter")==0) - m_value = Slit::RIGHTCENTER; - else if (strcasecmp(strval, "BottomRight")==0) - m_value = Slit::BOTTOMRIGHT; - else if (strcasecmp(strval, "LeftTop")==0) - m_value = Slit::LEFTTOP; - else if (strcasecmp(strval, "LeftBottom")==0) - m_value = Slit::LEFTBOTTOM; - else if (strcasecmp(strval, "RightTop")==0) - m_value = Slit::RIGHTTOP; - else if (strcasecmp(strval, "RightBottom")==0) - m_value = Slit::RIGHTBOTTOM; - else - setDefaultValue(); -} - -template<> string FbTk::Resource::getString() const { switch (m_value) { case Slit::TOPLEFT: @@ -163,6 +133,36 @@ string FbTk::Resource::getString() const { return string("RightBottom"); } +template<> +void FbTk::Resource::setFromString(const char *strval) { + if (strcasecmp(strval, "TopLeft")==0) + m_value = Slit::TOPLEFT; + else if (strcasecmp(strval, "LeftCenter")==0) + m_value = Slit::LEFTCENTER; + else if (strcasecmp(strval, "BottomLeft")==0) + m_value = Slit::BOTTOMLEFT; + else if (strcasecmp(strval, "TopCenter")==0) + m_value = Slit::TOPCENTER; + else if (strcasecmp(strval, "BottomCenter")==0) + m_value = Slit::BOTTOMCENTER; + else if (strcasecmp(strval, "TopRight")==0) + m_value = Slit::TOPRIGHT; + else if (strcasecmp(strval, "RightCenter")==0) + m_value = Slit::RIGHTCENTER; + else if (strcasecmp(strval, "BottomRight")==0) + m_value = Slit::BOTTOMRIGHT; + else if (strcasecmp(strval, "LeftTop")==0) + m_value = Slit::LEFTTOP; + else if (strcasecmp(strval, "LeftBottom")==0) + m_value = Slit::LEFTBOTTOM; + else if (strcasecmp(strval, "RightTop")==0) + m_value = Slit::RIGHTTOP; + else if (strcasecmp(strval, "RightBottom")==0) + m_value = Slit::RIGHTBOTTOM; + else + setDefaultValue(); +} + } // end namespace FbTk namespace { diff --git a/src/Toolbar.cc b/src/Toolbar.cc index e64d74e..4ed765a 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc @@ -80,37 +80,6 @@ using std::list; namespace FbTk { template<> -void FbTk::Resource:: -setFromString(const char *strval) { - if (strcasecmp(strval, "TopLeft")==0) - m_value = Toolbar::TOPLEFT; - else if (strcasecmp(strval, "BottomLeft")==0) - m_value = Toolbar::BOTTOMLEFT; - else if (strcasecmp(strval, "TopCenter")==0) - m_value = Toolbar::TOPCENTER; - else if (strcasecmp(strval, "BottomCenter")==0) - m_value = Toolbar::BOTTOMCENTER; - else if (strcasecmp(strval, "TopRight")==0) - m_value = Toolbar::TOPRIGHT; - else if (strcasecmp(strval, "BottomRight")==0) - m_value = Toolbar::BOTTOMRIGHT; - else if (strcasecmp(strval, "LeftTop") == 0) - m_value = Toolbar::LEFTTOP; - else if (strcasecmp(strval, "LeftCenter") == 0) - m_value = Toolbar::LEFTCENTER; - else if (strcasecmp(strval, "LeftBottom") == 0) - m_value = Toolbar::LEFTBOTTOM; - else if (strcasecmp(strval, "RightTop") == 0) - m_value = Toolbar::RIGHTTOP; - else if (strcasecmp(strval, "RightCenter") == 0) - m_value = Toolbar::RIGHTCENTER; - else if (strcasecmp(strval, "RightBottom") == 0) - m_value = Toolbar::RIGHTBOTTOM; - else - setDefaultValue(); -} - -template<> string FbTk::Resource:: getString() const { switch (m_value) { @@ -154,6 +123,38 @@ getString() const { //default string return string("BottomCenter"); } + +template<> +void FbTk::Resource:: +setFromString(const char *strval) { + if (strcasecmp(strval, "TopLeft")==0) + m_value = Toolbar::TOPLEFT; + else if (strcasecmp(strval, "BottomLeft")==0) + m_value = Toolbar::BOTTOMLEFT; + else if (strcasecmp(strval, "TopCenter")==0) + m_value = Toolbar::TOPCENTER; + else if (strcasecmp(strval, "BottomCenter")==0) + m_value = Toolbar::BOTTOMCENTER; + else if (strcasecmp(strval, "TopRight")==0) + m_value = Toolbar::TOPRIGHT; + else if (strcasecmp(strval, "BottomRight")==0) + m_value = Toolbar::BOTTOMRIGHT; + else if (strcasecmp(strval, "LeftTop") == 0) + m_value = Toolbar::LEFTTOP; + else if (strcasecmp(strval, "LeftCenter") == 0) + m_value = Toolbar::LEFTCENTER; + else if (strcasecmp(strval, "LeftBottom") == 0) + m_value = Toolbar::LEFTBOTTOM; + else if (strcasecmp(strval, "RightTop") == 0) + m_value = Toolbar::RIGHTTOP; + else if (strcasecmp(strval, "RightCenter") == 0) + m_value = Toolbar::RIGHTCENTER; + else if (strcasecmp(strval, "RightBottom") == 0) + m_value = Toolbar::RIGHTBOTTOM; + else + setDefaultValue(); +} + } // end namespace FbTk namespace { -- cgit v0.11.2