all repos — fluxbox @ 2b62cf973318978bc222db7719552148275887db

custom fork of the fluxbox windowmanager

cleanup and code deduplication

* ClientPattern.cc: make compiler happy (complaints about XPROP not handled in switch)
* FbTk/FbPixmap.cc FbTk/StringUtil.cc: signed vs unsigned
* FbTk/FbString.cc: missing return
* WinClient.cc: create atoms only once; use helper function
* Window.cc: use a helper function
Mathias Gumz akira at fluxbox dot org
commit

2b62cf973318978bc222db7719552148275887db

parent

c6047e9ebab5a0551c866078ed29fdda1e6b8174

5 files changed, 54 insertions(+), 51 deletions(-)

jump to
M src/ClientPattern.ccsrc/ClientPattern.cc

@@ -373,7 +373,7 @@

if (!term) return rc; - if (rc = !term->regexp.error()) { + if ((rc = !term->regexp.error())) { m_terms.push_back(term); } else { delete term;

@@ -383,76 +383,84 @@ return rc;

} FbTk::FbString ClientPattern::getProperty(WinProperty prop, const Focusable &client) { + + FbTk::FbString result; + // we need this for some of the window properties const FluxboxWindow *fbwin = client.fbwindow(); switch (prop) { case TITLE: - return client.title().logical(); + result = client.title().logical(); break; case CLASS: - return client.getWMClassClass(); - break; - case NAME: - return client.getWMClassName(); + result = client.getWMClassClass(); break; case ROLE: - return client.getWMRole(); + result = client.getWMRole(); break; case TRANSIENT: - return client.isTransient() ? "yes" : "no"; + result = client.isTransient() ? "yes" : "no"; break; case MAXIMIZED: - return (fbwin && fbwin->isMaximized()) ? "yes" : "no"; + result = (fbwin && fbwin->isMaximized()) ? "yes" : "no"; break; case MINIMIZED: - return (fbwin && fbwin->isIconic()) ? "yes" : "no"; + result = (fbwin && fbwin->isIconic()) ? "yes" : "no"; break; case SHADED: - return (fbwin && fbwin->isShaded()) ? "yes" : "no"; + result = (fbwin && fbwin->isShaded()) ? "yes" : "no"; break; case STUCK: - return (fbwin && fbwin->isStuck()) ? "yes" : "no"; + result = (fbwin && fbwin->isStuck()) ? "yes" : "no"; break; case FOCUSHIDDEN: - return (fbwin && fbwin->isFocusHidden()) ? "yes" : "no"; + result = (fbwin && fbwin->isFocusHidden()) ? "yes" : "no"; break; case ICONHIDDEN: - return (fbwin && fbwin->isIconHidden()) ? "yes" : "no"; + result = (fbwin && fbwin->isIconHidden()) ? "yes" : "no"; break; case WORKSPACE: { unsigned int wsnum = (fbwin ? fbwin->workspaceNumber() : client.screen().currentWorkspaceID()); - return FbTk::StringUtil::number2String(wsnum); + result = FbTk::StringUtil::number2String(wsnum); break; } case WORKSPACENAME: { const Workspace *w = (fbwin ? client.screen().getWorkspace(fbwin->workspaceNumber()) : client.screen().currentWorkspace()); - return w ? w->name() : ""; + if (w) { + result = w->name(); + } break; } - case HEAD: { - if (!fbwin) - return ""; - int head = client.screen().getHead(fbwin->fbWindow()); - return FbTk::StringUtil::number2String(head); + case HEAD: + if (fbwin) { + result = FbTk::StringUtil::number2String(client.screen().getHead(fbwin->fbWindow())); + } break; - } case LAYER: - return fbwin ? ::Layer::getString(fbwin->layerNum()) : ""; + if (fbwin) { + result = ::Layer::getString(fbwin->layerNum()); + } break; case URGENT: - return Fluxbox::instance()->attentionHandler() + result = Fluxbox::instance()->attentionHandler() .isDemandingAttention(client) ? "yes" : "no"; break; - case SCREEN: { - int screenId = client.screen().screenNumber(); - return FbTk::StringUtil::number2String(screenId); + case SCREEN: + result = FbTk::StringUtil::number2String(client.screen().screenNumber()); break; - } + + case XPROP: + break; + + case NAME: + default: + result = client.getWMClassName(); + break; } - return client.getWMClassName(); + return result; } bool ClientPattern::operator ==(const ClientPattern &pat) const {
M src/FbTk/FbPixmap.ccsrc/FbTk/FbPixmap.cc

@@ -369,7 +369,7 @@ if (!FbTk::Transparent::haveRender())

return false; checkAtoms(); - for (int i=0; i < sizeof(root_props)/sizeof(RootProps); ++i) { + for (size_t i = 0; i < sizeof(root_props)/sizeof(RootProps); ++i) { if (root_props[i].atom == atom) { Pixmap root_pm = None; Atom real_type;
M src/FbTk/FbString.ccsrc/FbTk/FbString.cc

@@ -126,6 +126,7 @@ } else {

m_visual_dirty = true; } #endif + return m_logical; } const FbString& BiDiString::visual() const {
M src/FbTk/StringUtil.ccsrc/FbTk/StringUtil.cc

@@ -183,7 +183,7 @@

string::size_type findCharFromAlphabetAfterTrigger(const std::string& in, char trigger, const char alphabet[], size_t len_alphabet, size_t* found) { for (const char* s = in.c_str(); *s != '\0'; ) { if (*s++ == trigger && *s != '\0') { - for (const char* a = alphabet; (a - alphabet) < len_alphabet; ++a) { + for (const char* a = alphabet; (a - alphabet) < static_cast<ssize_t>(len_alphabet); ++a) { if (*s == *a) { if (found) { *found = a - alphabet;
M src/Window.ccsrc/Window.cc

@@ -133,6 +133,16 @@ return client;

} +void callForAllTransient(FluxboxWindow& win, void (*callFunc)(FluxboxWindow&)) { + WinClient::TransientList::const_iterator it = win.winClient().transientList().begin(); + WinClient::TransientList::const_iterator it_end = win.winClient().transientList().end(); + for (; it != it_end; ++it) { + if ((*it)->fbwindow() && !(*it)->fbwindow()->isIconic()) + // TODO: should we also check if it is the active client? + callFunc(*(*it)->fbwindow()); + } +} + /// raise window and do the same for each transient of the current window void raiseFluxboxWindow(FluxboxWindow &win) { if (win.oplock)

@@ -150,18 +160,9 @@ win.screen().layerManager().lock();

win.layerItem().raise(); - // for each transient do raise - - WinClient::TransientList::const_iterator it = win.winClient().transientList().begin(); - WinClient::TransientList::const_iterator it_end = win.winClient().transientList().end(); - for (; it != it_end; ++it) { - if ((*it)->fbwindow() && !(*it)->fbwindow()->isIconic()) - // TODO: should we also check if it is the active client? - raiseFluxboxWindow(*(*it)->fbwindow()); - } + callForAllTransient(win, raiseFluxboxWindow); win.oplock = false; - if (!win.winClient().transientList().empty()) win.screen().layerManager().unlock();

@@ -210,16 +211,9 @@ if (!win.isIconic()) {

win.layerItem().tempRaise(); } - // for each transient do raise - WinClient::TransientList::const_iterator it = win.winClient().transientList().begin(); - WinClient::TransientList::const_iterator it_end = win.winClient().transientList().end(); - for (; it != it_end; ++it) { - if ((*it)->fbwindow() && !(*it)->fbwindow()->isIconic()) - // TODO: should we also check if it is the active client? - tempRaiseFluxboxWindow(*(*it)->fbwindow()); - } + callForAllTransient(win, tempRaiseFluxboxWindow); + win.oplock = false; - } class SetClientCmd:public FbTk::Command<void> {

@@ -1063,8 +1057,8 @@

m_timer.setTimeout(Fluxbox::instance()->getAutoRaiseDelay()); updateButtons(); - frame().reconfigure(); + frame().reconfigure(); menu().reconfigure(); Client2ButtonMap::iterator it = m_labelbuttons.begin(),