all repos — fluxbox @ fbcdd34b223174a28ff712b7d03e56339fa2fe07

custom fork of the fluxbox windowmanager

mostly cosmetic fixes, mainly discovered by 'clang --analyze'

reordering of Resource-related stuff was because of

   "error: explicit specialization of 'getString' after instantiation"

complaints.
Mathias Gumz akira at fluxbox dot org
commit

fbcdd34b223174a28ff712b7d03e56339fa2fe07

parent

ff9c68e247704bd1522ea7a2055b7fa4b2b0c568

M src/FbTk/TextureRender.ccsrc/FbTk/TextureRender.cc

@@ -68,7 +68,7 @@ FbTk::Orientation orient,

XColor *_colors, size_t num_colors): control(imgctrl), colors(_colors), - ncolors(ncolors), + ncolors(static_cast<int>(num_colors)), cpc(imgctrl.colorsPerChannel()), cpccpc(cpc * cpc), red(0), green(0), blue(0),
M src/FbWinFrame.ccsrc/FbWinFrame.cc

@@ -160,7 +160,7 @@ m_label.hide();

// reconfigure(); } - return true; + return ret; } void FbWinFrame::hide() {
M src/IconButton.ccsrc/IconButton.cc

@@ -189,8 +189,10 @@ m_icon_window.show();

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<unsigned>(icony)) newh -= 2*icony; else
M src/Keys.ccsrc/Keys.cc

@@ -458,7 +458,7 @@ type = ButtonRelease;

} 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:
M src/Resources.ccsrc/Resources.cc

@@ -49,6 +49,14 @@ //-----------------------------------------------------------------

namespace FbTk { template<> +string FbTk::Resource<int>:: +getString() const { + char strval[256]; + sprintf(strval, "%d", **this); + return string(strval); +} + +template<> void FbTk::Resource<int>:: setFromString(const char* strval) { int val;

@@ -57,70 +65,16 @@ *this = val;

} template<> -void FbTk::Resource<string>:: -setFromString(const char *strval) { - *this = strval; -} - -template<> -void FbTk::Resource<bool>:: -setFromString(char const *strval) { - *this = (bool)!strcasecmp(strval, "true"); -} - -template<> -void FbTk::Resource<vector<WinButton::Type> >:: -setFromString(char const *strval) { - vector<string> 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<Fluxbox::TabsAttachArea>:: -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<unsigned int>:: -setFromString(const char *strval) { - if (sscanf(strval, "%ul", &m_value) != 1) - setDefaultValue(); -} +string FbTk::Resource<string>:: +getString() const { return **this; } template<> -void FbTk::Resource<long long>:: +void FbTk::Resource<string>:: 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<bool>:: getString() const {

@@ -128,16 +82,10 @@ return string(**this == true ? "true" : "false");

} template<> -string FbTk::Resource<int>:: -getString() const { - char strval[256]; - sprintf(strval, "%d", **this); - return string(strval); +void FbTk::Resource<bool>:: +setFromString(char const *strval) { + *this = (bool)!strcasecmp(strval, "true"); } - -template<> -string FbTk::Resource<string>:: -getString() const { return **this; } template<>

@@ -173,6 +121,34 @@

return retval; } + + +template<> +void FbTk::Resource<vector<WinButton::Type> >:: +setFromString(char const *strval) { + vector<string> 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<Fluxbox::TabsAttachArea>:: getString() const {

@@ -183,6 +159,15 @@ return "Window";

} template<> +void FbTk::Resource<Fluxbox::TabsAttachArea>:: +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<unsigned int>:: getString() const { char tmpstr[128];

@@ -191,6 +176,14 @@ return string(tmpstr);

} template<> +void FbTk::Resource<unsigned int>:: +setFromString(const char *strval) { + if (sscanf(strval, "%ul", &m_value) != 1) + setDefaultValue(); +} + + +template<> string FbTk::Resource<long long>:: getString() const { char tmpstr[128];

@@ -199,13 +192,9 @@ return string(tmpstr);

} template<> -void FbTk::Resource<Layer>:: +void FbTk::Resource<long long>:: 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 @@ return ::Layer::getString(m_value.getNum());

} template<> -void FbTk::Resource<long>:: +void FbTk::Resource<Layer>:: 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 @@ char tmpstr[128];

sprintf(tmpstr, "%ld", m_value); return string(tmpstr); } + +template<> +void FbTk::Resource<long>:: +setFromString(const char *strval) { + if (sscanf(strval, "%ld", &m_value) != 1) + setDefaultValue(); +} + } // end namespace FbTk
M src/Screen.ccsrc/Screen.cc

@@ -209,37 +209,6 @@

namespace FbTk { template<> -void FbTk::Resource<FbWinFrame::TabPlacement>:: -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<FbWinFrame::TabPlacement>:: getString() const { switch (m_value) {

@@ -283,6 +252,38 @@ }

//default string return string("TopLeft"); } + +template<> +void FbTk::Resource<FbWinFrame::TabPlacement>:: +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
M src/ScreenPlacement.ccsrc/ScreenPlacement.cc

@@ -132,24 +132,6 @@

////////////////////// Placement Resources namespace FbTk { - -template <> -void FbTk::Resource<ScreenPlacement::PlacementPolicy>::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<ScreenPlacement::PlacementPolicy>::getString() const {

@@ -172,15 +154,23 @@ return "RowSmartPlacement";

} template <> -void FbTk::Resource<ScreenPlacement::RowDirection>::setFromString(const char *str) { - if (strcasecmp("LeftToRight", str) == 0) - *(*this) = ScreenPlacement::LEFTRIGHT; - else if (strcasecmp("RightToLeft", str) == 0) - *(*this) = ScreenPlacement::RIGHTLEFT; +void FbTk::Resource<ScreenPlacement::PlacementPolicy>::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<ScreenPlacement::RowDirection>::getString() const {

@@ -196,14 +186,13 @@ }

template <> -void FbTk::Resource<ScreenPlacement::ColumnDirection>::setFromString(const char *str) { - if (strcasecmp("TopToBottom", str) == 0) - *(*this) = ScreenPlacement::TOPBOTTOM; - else if (strcasecmp("BottomToTop", str) == 0) - *(*this) = ScreenPlacement::BOTTOMTOP; +void FbTk::Resource<ScreenPlacement::RowDirection>::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 @@ }

return "TopToBottom"; } + + +template <> +void FbTk::Resource<ScreenPlacement::ColumnDirection>::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
M src/Slit.ccsrc/Slit.cc

@@ -90,36 +90,6 @@

namespace FbTk { template<> -void FbTk::Resource<Slit::Placement>::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<Slit::Placement>::getString() const { switch (m_value) { case Slit::TOPLEFT:

@@ -161,6 +131,36 @@ break;

} //default string return string("RightBottom"); +} + +template<> +void FbTk::Resource<Slit::Placement>::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
M src/Toolbar.ccsrc/Toolbar.cc

@@ -80,37 +80,6 @@

namespace FbTk { template<> -void FbTk::Resource<Toolbar::Placement>:: -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<Toolbar::Placement>:: getString() const { switch (m_value) {

@@ -154,6 +123,38 @@ }

//default string return string("BottomCenter"); } + +template<> +void FbTk::Resource<Toolbar::Placement>:: +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 {