From d509be7ac9a01ad5e2de4e4de510788ada3c8a60 Mon Sep 17 00:00:00 2001 From: fluxgen <fluxgen> Date: Sun, 24 Aug 2003 11:19:45 +0000 Subject: cleaning --- src/FbWinFrame.cc | 68 ++++++++++++++++++++++++++++--------------------------- src/Screen.cc | 50 ++++++++++++++++------------------------ src/Workspace.cc | 10 ++++---- src/fluxbox.cc | 33 +++++++-------------------- 4 files changed, 66 insertions(+), 95 deletions(-) diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index 7943c8a..9c8989f 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbWinFrame.cc,v 1.39 2003/08/23 15:46:06 fluxgen Exp $ +// $Id: FbWinFrame.cc,v 1.40 2003/08/24 11:11:07 fluxgen Exp $ #include "FbWinFrame.hh" @@ -27,12 +27,14 @@ #include "FbTk/EventManager.hh" #include "FbTk/TextButton.hh" #include "FbTk/App.hh" +#include "FbTk/Compose.hh" #include "FbWinFrameTheme.hh" #ifdef SHAPE #include "Shape.hh" #endif // SHAPE + #include <algorithm> #include <iostream> using namespace std; @@ -505,14 +507,13 @@ void FbWinFrame::buttonPressEvent(XButtonEvent &event) { void FbWinFrame::buttonReleaseEvent(XButtonEvent &event) { // we can ignore which window the event was generated for - LabelList::iterator btn_it = m_labelbuttons.begin(); - LabelList::iterator btn_it_end = m_labelbuttons.end(); - for (; btn_it != btn_it_end; ++btn_it) { - if ((*btn_it)->window() == event.window) { - (*btn_it)->buttonReleaseEvent(event); - break; - } - } + LabelList::iterator button_it = find_if(m_labelbuttons.begin(), + m_labelbuttons.end(), + FbTk::Compose(bind2nd(equal_to<Window>(), event.window), + mem_fun(&FbTk::Button::window))); + if (button_it != m_labelbuttons.end()) + (*button_it)->buttonReleaseEvent(event); + if (event.window == m_grip_right.window() || event.window == m_grip_left.window() || @@ -549,35 +550,36 @@ void FbWinFrame::exposeEvent(XExposeEvent &event) { m_grip_right.clearArea(event.x, event.y, event.width, event.height); m_grip_right.updateTransparent(); } else { - LabelList::iterator btn_it = m_labelbuttons.begin(); - LabelList::iterator btn_it_end = m_labelbuttons.end(); - for (; btn_it != btn_it_end; ++btn_it) { - if ((*btn_it)->window() == event.window) { - (*btn_it)->exposeEvent(event); - return; - } + // create compare function + // that we should use with find_if + FbTk::Compose_base<std::binder2nd<std::equal_to<Window> >, + std::const_mem_fun_t<Window, FbTk::FbWindow> > + compare = FbTk::Compose(bind2nd(equal_to<Window>(), event.window), + mem_fun(&FbTk::Button::window)); + + LabelList::iterator btn_it = find_if(m_labelbuttons.begin(), + m_labelbuttons.end(), + compare); + if (btn_it != m_labelbuttons.end()) { + (*btn_it)->exposeEvent(event); + return; } - ButtonList::iterator it = m_buttons_left.begin(); - ButtonList::iterator it_end = m_buttons_left.end(); - for (; it != it_end; ++it) { - if ((*it)->window() == event.window) { - (*it)->exposeEvent(event); - return; - } + ButtonList::iterator it = find_if(m_buttons_left.begin(), + m_buttons_left.end(), + compare); + if (it != m_buttons_left.end()) { + (*it)->exposeEvent(event); + return; } - it = m_buttons_right.begin(); - it_end = m_buttons_right.end(); - for (; it != it_end; ++it) { - if ((*it)->window() == event.window) { - (*it)->exposeEvent(event); - return; - } - } - } + it = find_if(m_buttons_right.begin(), + m_buttons_right.end(), + compare); - + if (it != m_buttons_right.end()) + (*it)->exposeEvent(event); + } } void FbWinFrame::handleEvent(XEvent &event) { diff --git a/src/Screen.cc b/src/Screen.cc index bd1a919..d5379da 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.cc,v 1.223 2003/08/22 15:03:28 fluxgen Exp $ +// $Id: Screen.cc,v 1.224 2003/08/24 11:13:36 fluxgen Exp $ #include "Screen.hh" @@ -689,7 +689,7 @@ void BScreen::rereadMenu() { void BScreen::removeWorkspaceNames() { - m_workspace_names.erase(m_workspace_names.begin(), m_workspace_names.end()); + m_workspace_names.clear(); } void BScreen::updateWorkspaceNamesAtom() { @@ -935,7 +935,7 @@ void BScreen::addNetizen(Window win) { Workspace::Windows::iterator win_it_end = (*it)->windowList().end(); for (; win_it != win_it_end; ++win_it) { net->sendWindowAdd((*win_it)->clientWindow(), - (*it)->workspaceID()); + (*it)->workspaceID()); } } @@ -976,15 +976,11 @@ void BScreen::updateNetizenWorkspaceCount() { void BScreen::updateNetizenWindowFocus() { - - Netizens::iterator it = m_netizen_list.begin(); - Netizens::iterator it_end = m_netizen_list.end(); Window f = ((Fluxbox::instance()->getFocusedWindow()) ? Fluxbox::instance()->getFocusedWindow()->window() : None); - for (; it != it_end; ++it) { - (*it)->sendWindowFocus(f); - } - + for_each(m_netizen_list.begin(), + m_netizen_list.end(), + bind2nd(mem_fun(&Netizen::sendWindowFocus), f)); } @@ -1001,40 +997,32 @@ void BScreen::updateNetizenWindowAdd(Window w, unsigned long p) { void BScreen::updateNetizenWindowDel(Window w) { - Netizens::iterator it = m_netizen_list.begin(); - Netizens::iterator it_end = m_netizen_list.end(); - for (; it != it_end; ++it) { - (*it)->sendWindowDel(w); - } + for_each(m_netizen_list.begin(), + m_netizen_list.end(), + bind2nd(mem_fun(&Netizen::sendWindowDel), w)); m_clientlist_sig.notify(); } void BScreen::updateNetizenWindowRaise(Window w) { - Netizens::iterator it = m_netizen_list.begin(); - Netizens::iterator it_end = m_netizen_list.end(); - for (; it != it_end; ++it) { - (*it)->sendWindowRaise(w); - } + for_each(m_netizen_list.begin(), + m_netizen_list.end(), + bind2nd(mem_fun(&Netizen::sendWindowRaise), w)); } void BScreen::updateNetizenWindowLower(Window w) { - Netizens::iterator it = m_netizen_list.begin(); - Netizens::iterator it_end = m_netizen_list.end(); - for (; it != it_end; ++it) { - (*it)->sendWindowLower(w); - } + for_each(m_netizen_list.begin(), + m_netizen_list.end(), + bind2nd(mem_fun(&Netizen::sendWindowLower), w)); } - void BScreen::updateNetizenConfigNotify(XEvent &e) { Netizens::iterator it = m_netizen_list.begin(); Netizens::iterator it_end = m_netizen_list.end(); - for (; it != it_end; ++it) { + for (; it != it_end; ++it) (*it)->sendConfigNotify(e); - } } FluxboxWindow *BScreen::createWindow(Window client) { @@ -1047,7 +1035,7 @@ FluxboxWindow *BScreen::createWindow(Window client) { bool iskdedockapp = false; Atom ajunk; int ijunk; - unsigned long *data = (unsigned long *) 0, uljunk; + unsigned long *data = 0, uljunk; Display *disp = FbTk::App::instance()->display(); // Check if KDE v2.x dock applet if (XGetWindowProperty(disp, client, @@ -1185,8 +1173,8 @@ void BScreen::clearStrut(Strut *str) { return; // find strut and erase it std::list<Strut *>::iterator pos = find(m_strutlist.begin(), - m_strutlist.end(), - str); + m_strutlist.end(), + str); if (pos == m_strutlist.end()) return; m_strutlist.erase(pos); diff --git a/src/Workspace.cc b/src/Workspace.cc index 3023994..3bec41a 100644 --- a/src/Workspace.cc +++ b/src/Workspace.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Workspace.cc,v 1.80 2003/08/19 16:16:28 fluxgen Exp $ +// $Id: Workspace.cc,v 1.81 2003/08/24 11:16:42 fluxgen Exp $ #include "Workspace.hh" @@ -246,9 +246,8 @@ void Workspace::removeWindow(WinClient &client) { void Workspace::showAll() { Windows::iterator it = m_windowlist.begin(); Windows::iterator it_end = m_windowlist.end(); - for (; it != it_end; ++it) { + for (; it != it_end; ++it) (*it)->deiconify(false, false); - } } @@ -265,9 +264,8 @@ void Workspace::hideAll() { void Workspace::removeAll() { Windows::iterator it = m_windowlist.begin(); Windows::const_iterator it_end = m_windowlist.end(); - for (; it != it_end; ++it) { + for (; it != it_end; ++it) (*it)->iconify(); - } } @@ -291,7 +289,7 @@ namespace { class FindInGroup { public: FindInGroup(const FluxboxWindow &w):m_w(w) { } - bool operator ()(const string &name) { + bool operator ()(const string &name) const { return (name == m_w.winClient().getWMClassName()); } private: diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 370bc1d..c28a53c 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: fluxbox.cc,v 1.186 2003/08/22 21:38:58 fluxgen Exp $ +// $Id: fluxbox.cc,v 1.187 2003/08/24 11:19:45 fluxgen Exp $ #include "fluxbox.hh" @@ -1332,17 +1332,11 @@ void Fluxbox::attachSignals(WinClient &winclient) { } BScreen *Fluxbox::searchScreen(Window window) { - BScreen *screen = 0; ScreenList::iterator it = m_screen_list.begin(); ScreenList::iterator it_end = m_screen_list.end(); - for (; it != it_end; ++it) { - if (*it) { - if ((*it)->rootWindow() == window) { - screen = (*it); - return screen; - } - } + if (*it && (*it)->rootWindow() == window) + return (*it); } return 0; @@ -1431,12 +1425,8 @@ void Fluxbox::shutdown() { XSetInputFocus(FbTk::App::instance()->display(), PointerRoot, None, CurrentTime); //send shutdown to all screens - ScreenList::iterator it = m_screen_list.begin(); - ScreenList::iterator it_end = m_screen_list.end(); - for (; it != it_end; ++it) { - if(*it) - (*it)->shutdown(); - } + for_each(m_screen_list.begin(), m_screen_list.end(), mem_fun(&BScreen::shutdown)); + m_shutdown = true; XSync(FbTk::App::instance()->display(), False); @@ -1791,10 +1781,8 @@ void Fluxbox::real_reconfigure() { if (old_blackboxrc) XrmDestroyDatabase(old_blackboxrc); - ScreenList::iterator sit = m_screen_list.begin(); - ScreenList::iterator sit_end = m_screen_list.end(); - for (; sit != sit_end; ++sit) - (*sit)->reconfigure(); + // reconfigure all screens + for_each(m_screen_list.begin(), m_screen_list.end(), mem_fun(&BScreen::reconfigure)); //reconfigure keys m_key->reconfigure(StringUtil::expandFilename(*m_rc_keyfile).c_str()); @@ -1841,12 +1829,7 @@ void Fluxbox::real_rereadMenu() { delete *it; m_menu_timestamps.erase(m_menu_timestamps.begin(), m_menu_timestamps.end()); - - ScreenList::iterator sit = m_screen_list.begin(); - ScreenList::iterator sit_end = m_screen_list.end(); - for (; sit != sit_end; ++sit) { - (*sit)->rereadMenu(); - } + for_each(m_screen_list.begin(), m_screen_list.end(), mem_fun(&BScreen::rereadMenu)); } void Fluxbox::saveMenuFilename(const char *filename) { -- cgit v0.11.2