aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2010-09-15 00:07:09 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2010-09-15 00:07:09 (GMT)
commit12e1ef78265a621dc51f7b9af245d81431835dcc (patch)
treeb1e7c9ec99f24c89989a34cb994119319184abb7
parentba316aa18a8813958cedea1cc4d54452e40c4b59 (diff)
downloadfluxbox-12e1ef78265a621dc51f7b9af245d81431835dcc.zip
fluxbox-12e1ef78265a621dc51f7b9af245d81431835dcc.tar.bz2
code deduplication by using <algorithm> and FbTk/STLUtil.hh
-rw-r--r--src/FbTk/Container.cc70
-rw-r--r--src/FbTk/STLUtil.hh27
-rw-r--r--src/FbTk/Theme.cc9
-rw-r--r--src/FbWinFrame.cc20
-rw-r--r--src/IconbarTool.cc10
-rw-r--r--src/fluxbox.cc136
6 files changed, 104 insertions, 168 deletions
diff --git a/src/FbTk/Container.cc b/src/FbTk/Container.cc
index ce143ef..e1d2e07 100644
--- a/src/FbTk/Container.cc
+++ b/src/FbTk/Container.cc
@@ -26,6 +26,7 @@
26#include "TextUtils.hh" 26#include "TextUtils.hh"
27#include "EventManager.hh" 27#include "EventManager.hh"
28#include "CompareEqual.hh" 28#include "CompareEqual.hh"
29#include "STLUtil.hh"
29 30
30#include <algorithm> 31#include <algorithm>
31 32
@@ -78,7 +79,7 @@ void Container::insertItem(Item item, int pos) {
78 } else if (pos == 0) { 79 } else if (pos == 0) {
79 m_item_list.push_front(item); 80 m_item_list.push_front(item);
80 } else { 81 } else {
81 ItemList::iterator it = m_item_list.begin(); 82 ItemList::iterator it = begin();
82 for (; pos != 0; ++it, --pos) 83 for (; pos != 0; ++it, --pos)
83 continue; 84 continue;
84 85
@@ -104,12 +105,10 @@ void Container::moveItem(Item item, int movement) {
104 if (newindex < 0) // neg wrap 105 if (newindex < 0) // neg wrap
105 newindex += size; 106 newindex += size;
106 107
107 ItemList::iterator it = std::find(m_item_list.begin(), 108 ItemList::iterator it = std::find(begin(), end(), item);
108 m_item_list.end(),
109 item);
110 m_item_list.erase(it); 109 m_item_list.erase(it);
111 110
112 for (it = m_item_list.begin(); newindex >= 0; ++it, --newindex) { 111 for (it = begin(); newindex >= 0; ++it, --newindex) {
113 if (newindex == 0) { 112 if (newindex == 0) {
114 break; 113 break;
115 } 114 }
@@ -143,12 +142,11 @@ bool Container::moveItemTo(Item item, int x, int y) {
143 &itemwin)) 142 &itemwin))
144 return false; 143 return false;
145 144
146 ItemList::iterator it = find_if(m_item_list.begin(), 145 ItemList::iterator it = find_if(begin(), end(),
147 m_item_list.end(),
148 CompareWindow(&FbWindow::window, 146 CompareWindow(&FbWindow::window,
149 itemwin)); 147 itemwin));
150 // not found :( 148 // not found :(
151 if (it == m_item_list.end()) 149 if (it == end())
152 return false; 150 return false;
153 151
154 Window child_return = 0; 152 Window child_return = 0;
@@ -162,8 +160,8 @@ bool Container::moveItemTo(Item item, int x, int y) {
162} 160}
163 161
164bool Container::removeItem(Item item) { 162bool Container::removeItem(Item item) {
165 ItemList::iterator it = m_item_list.begin(); 163 ItemList::iterator it = begin();
166 ItemList::iterator it_end = m_item_list.end(); 164 ItemList::iterator it_end = end();
167 for (; it != it_end && (*it) != item; ++it); 165 for (; it != it_end && (*it) != item; ++it);
168 166
169 if (it == it_end) 167 if (it == it_end)
@@ -178,7 +176,7 @@ bool Container::removeItem(int index) {
178 if (index < 0 || index > size()) 176 if (index < 0 || index > size())
179 return false; 177 return false;
180 178
181 ItemList::iterator it = m_item_list.begin(); 179 ItemList::iterator it = begin();
182 for (; index != 0; ++it, --index) 180 for (; index != 0; ++it, --index)
183 continue; 181 continue;
184 182
@@ -247,12 +245,11 @@ bool Container::tryExposeEvent(XExposeEvent &event) {
247 return true; 245 return true;
248 } 246 }
249 247
250 ItemList::iterator it = find_if(m_item_list.begin(), 248 ItemList::iterator it = find_if(begin(), end(),
251 m_item_list.end(),
252 CompareWindow(&FbWindow::window, 249 CompareWindow(&FbWindow::window,
253 event.window)); 250 event.window));
254 // not found :( 251 // not found :(
255 if (it == m_item_list.end()) 252 if (it == end())
256 return false; 253 return false;
257 254
258 (*it)->exposeEvent(event); 255 (*it)->exposeEvent(event);
@@ -265,12 +262,11 @@ bool Container::tryButtonPressEvent(XButtonEvent &event) {
265 return true; 262 return true;
266 } 263 }
267 264
268 ItemList::iterator it = find_if(m_item_list.begin(), 265 ItemList::iterator it = find_if(begin(), end(),
269 m_item_list.end(),
270 CompareWindow(&FbWindow::window, 266 CompareWindow(&FbWindow::window,
271 event.window)); 267 event.window));
272 // not found :( 268 // not found :(
273 if (it == m_item_list.end()) 269 if (it == end())
274 return false; 270 return false;
275 271
276 (*it)->buttonPressEvent(event); 272 (*it)->buttonPressEvent(event);
@@ -283,12 +279,11 @@ bool Container::tryButtonReleaseEvent(XButtonEvent &event) {
283 return true; 279 return true;
284 } 280 }
285 281
286 ItemList::iterator it = find_if(m_item_list.begin(), 282 ItemList::iterator it = find_if(begin(), end(),
287 m_item_list.end(),
288 CompareWindow(&FbWindow::window, 283 CompareWindow(&FbWindow::window,
289 event.window)); 284 event.window));
290 // not found :( 285 // not found :(
291 if (it == m_item_list.end()) 286 if (it == end())
292 return false; 287 return false;
293 288
294 (*it)->buttonReleaseEvent(event); 289 (*it)->buttonReleaseEvent(event);
@@ -360,8 +355,8 @@ void Container::repositionItems() {
360 } 355 }
361 356
362 357
363 ItemList::iterator it = m_item_list.begin(); 358 ItemList::iterator it = begin();
364 const ItemList::iterator it_end = m_item_list.end(); 359 const ItemList::iterator it_end = end();
365 360
366 int rounding_error = 0; 361 int rounding_error = 0;
367 362
@@ -442,41 +437,26 @@ unsigned int Container::maxWidthPerClient() const {
442} 437}
443 438
444void Container::for_each(std::mem_fun_t<void, FbWindow> function) { 439void Container::for_each(std::mem_fun_t<void, FbWindow> function) {
445 std::for_each(m_item_list.begin(), 440 std::for_each(begin(), end(), function);
446 m_item_list.end(),
447 function);
448} 441}
449 442
450void Container::setAlpha(unsigned char alpha) { 443void Container::setAlpha(unsigned char alpha) {
451 FbWindow::setAlpha(alpha); 444 FbWindow::setAlpha(alpha);
452 ItemList::iterator it = m_item_list.begin(); 445 STLUtil::forAll(m_item_list, std::bind2nd(std::mem_fun(&Button::setAlpha), alpha));
453 ItemList::iterator it_end = m_item_list.end();
454 for (; it != it_end; ++it)
455 (*it)->setAlpha(alpha);
456} 446}
457 447
458void Container::parentMoved() { 448void Container::parentMoved() {
459 FbWindow::parentMoved(); 449 FbWindow::parentMoved();
460 ItemList::iterator it = m_item_list.begin(); 450 STLUtil::forAll(m_item_list, std::mem_fun(&Button::parentMoved));
461 ItemList::iterator it_end = m_item_list.end();
462 for (; it != it_end; ++it)
463 (*it)->parentMoved();
464} 451}
465 452
466void Container::invalidateBackground() { 453void Container::invalidateBackground() {
467 FbWindow::invalidateBackground(); 454 FbWindow::invalidateBackground();
468 ItemList::iterator it = m_item_list.begin(); 455 STLUtil::forAll(m_item_list, std::mem_fun(&Button::invalidateBackground));
469 ItemList::iterator it_end = m_item_list.end();
470 for (; it != it_end; ++it)
471 (*it)->invalidateBackground();
472} 456}
473 457
474void Container::clear() { 458void Container::clear() {
475 ItemList::iterator it = m_item_list.begin(); 459 STLUtil::forAll(m_item_list, std::mem_fun(&Button::clear));
476 ItemList::iterator it_end = m_item_list.end();
477 for (; it != it_end; ++it)
478 (*it)->clear();
479
480} 460}
481 461
482void Container::setOrientation(Orientation orient) { 462void Container::setOrientation(Orientation orient) {
@@ -484,11 +464,7 @@ void Container::setOrientation(Orientation orient) {
484 return; 464 return;
485 465
486 FbWindow::invalidateBackground(); 466 FbWindow::invalidateBackground();
487 467 STLUtil::forAll(m_item_list, std::bind2nd(std::mem_fun(&Button::setOrientation), orient));
488 ItemList::iterator it = m_item_list.begin();
489 ItemList::iterator it_end = m_item_list.end();
490 for (; it != it_end; ++it)
491 (*it)->setOrientation(orient);
492 468
493 if (((m_orientation == ROT0 || m_orientation == ROT180) && 469 if (((m_orientation == ROT0 || m_orientation == ROT180) &&
494 (orient == ROT90 || orient == ROT270)) || 470 (orient == ROT90 || orient == ROT270)) ||
diff --git a/src/FbTk/STLUtil.hh b/src/FbTk/STLUtil.hh
index e08036a..b1007f7 100644
--- a/src/FbTk/STLUtil.hh
+++ b/src/FbTk/STLUtil.hh
@@ -68,6 +68,33 @@ void destroyAndClearSecond(A &a) {
68 a.clear(); 68 a.clear();
69} 69}
70 70
71
72template <typename C, typename F>
73F forAll(C& c, F f) {
74 typedef typename C::iterator iterator;
75 iterator i = c.begin();
76 iterator e = c.end();
77 for (; i != e; i++) {
78 f(*i);
79 }
80 return f;
81}
82
83template <typename C, typename I, typename F>
84F forAllIf(C& c, I i, F f) {
85 typedef typename C::iterator iterator;
86 iterator it = c.begin();
87 iterator end = c.end();
88 for (; it != end; it++) {
89 if (i(*it))
90 f(*it);
91 }
92 return f;
93}
94
95
96
97
71} // end namespace STLUtil 98} // end namespace STLUtil
72} // end namespace FbTk 99} // end namespace FbTk
73 100
diff --git a/src/FbTk/Theme.cc b/src/FbTk/Theme.cc
index cd478fc..c92e563 100644
--- a/src/FbTk/Theme.cc
+++ b/src/FbTk/Theme.cc
@@ -27,6 +27,7 @@
27#include "FileUtil.hh" 27#include "FileUtil.hh"
28#include "I18n.hh" 28#include "I18n.hh"
29#include "Image.hh" 29#include "Image.hh"
30#include "STLUtil.hh"
30 31
31#ifdef HAVE_CSTDIO 32#ifdef HAVE_CSTDIO
32 #include <cstdio> 33 #include <cstdio>
@@ -50,13 +51,11 @@ struct LoadThemeHelper {
50 } 51 }
51 void operator ()(ThemeManager::ThemeList &tmlist) { 52 void operator ()(ThemeManager::ThemeList &tmlist) {
52 53
53 for_each(tmlist.begin(), tmlist.end(), 54 STLUtil::forAll(tmlist, *this);
54 *this);
55 // send reconfiguration signal to theme and listeners 55 // send reconfiguration signal to theme and listeners
56 ThemeManager::ThemeList::iterator it = tmlist.begin(); 56 ThemeManager::ThemeList::iterator it = tmlist.begin();
57 ThemeManager::ThemeList::iterator it_end = tmlist.end(); 57 ThemeManager::ThemeList::iterator it_end = tmlist.end();
58 for (; it != it_end; ++it) { 58 for (; it != it_end; ++it) {
59 (*it)->reconfigTheme();
60 (*it)->reconfigSig().notify(); 59 (*it)->reconfigSig().notify();
61 } 60 }
62 } 61 }
@@ -174,9 +173,7 @@ bool ThemeManager::load(const string &filename,
174 // get list and go throu all the resources and load them 173 // get list and go throu all the resources and load them
175 // and then reconfigure them 174 // and then reconfigure them
176 if (screen_num < 0 || screen_num > m_max_screens) { 175 if (screen_num < 0 || screen_num > m_max_screens) {
177 for_each(m_themes.begin(), 176 STLUtil::forAll(m_themes, load_theme_helper);
178 m_themes.end(),
179 load_theme_helper);
180 } else { 177 } else {
181 load_theme_helper(m_themes[screen_num]); 178 load_theme_helper(m_themes[screen_num]);
182 } 179 }
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc
index 4c56d49..9c35925 100644
--- a/src/FbWinFrame.cc
+++ b/src/FbWinFrame.cc
@@ -29,6 +29,7 @@
29#include "FbTk/Transparent.hh" 29#include "FbTk/Transparent.hh"
30#include "FbTk/CompareEqual.hh" 30#include "FbTk/CompareEqual.hh"
31#include "FbTk/TextUtils.hh" 31#include "FbTk/TextUtils.hh"
32#include "FbTk/STLUtil.hh"
32 33
33#include "FbWinFrameTheme.hh" 34#include "FbWinFrameTheme.hh"
34#include "Screen.hh" 35#include "Screen.hh"
@@ -42,6 +43,8 @@ using std::max;
42using std::mem_fun; 43using std::mem_fun;
43using std::string; 44using std::string;
44 45
46using FbTk::STLUtil::forAll;
47
45FbWinFrame::FbWinFrame(BScreen &screen, WindowState &state, 48FbWinFrame::FbWinFrame(BScreen &screen, WindowState &state,
46 FocusableTheme<FbWinFrameTheme> &theme): 49 FocusableTheme<FbWinFrameTheme> &theme):
47 m_screen(screen), 50 m_screen(screen),
@@ -439,12 +442,8 @@ void FbWinFrame::notifyMoved(bool clear) {
439 442
440 m_titlebar.parentMoved(); 443 m_titlebar.parentMoved();
441 444
442 for_each(m_buttons_left.begin(), 445 forAll(m_buttons_left, mem_fun(&FbTk::Button::parentMoved));
443 m_buttons_left.end(), 446 forAll(m_buttons_right, mem_fun(&FbTk::Button::parentMoved));
444 mem_fun(&FbTk::Button::parentMoved));
445 for_each(m_buttons_right.begin(),
446 m_buttons_right.end(),
447 mem_fun(&FbTk::Button::parentMoved));
448 } 447 }
449 448
450 if (m_use_handle) { 449 if (m_use_handle) {
@@ -463,13 +462,8 @@ void FbWinFrame::clearAll() {
463 462
464 if (m_use_titlebar) { 463 if (m_use_titlebar) {
465 redrawTitlebar(); 464 redrawTitlebar();
466 465 forAll(m_buttons_left, mem_fun(&FbTk::Button::clear));
467 for_each(m_buttons_left.begin(), 466 forAll(m_buttons_right, mem_fun(&FbTk::Button::clear));
468 m_buttons_left.end(),
469 mem_fun(&FbTk::Button::clear));
470 for_each(m_buttons_right.begin(),
471 m_buttons_right.end(),
472 mem_fun(&FbTk::Button::clear));
473 } else if (m_tabmode == EXTERNAL && m_use_tabs) 467 } else if (m_tabmode == EXTERNAL && m_use_tabs)
474 m_tab_container.clear(); 468 m_tab_container.clear();
475 469
diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc
index 14835cb..cd47d45 100644
--- a/src/IconbarTool.cc
+++ b/src/IconbarTool.cc
@@ -48,6 +48,9 @@
48#include "FbTk/MacroCommand.hh" 48#include "FbTk/MacroCommand.hh"
49#include "FbTk/MenuSeparator.hh" 49#include "FbTk/MenuSeparator.hh"
50#include "FbTk/Util.hh" 50#include "FbTk/Util.hh"
51#include "FbTk/STLUtil.hh"
52#include "FbTk/Select2nd.hh"
53#include "FbTk/Compose.hh"
51 54
52#include <typeinfo> 55#include <typeinfo>
53#include <iterator> 56#include <iterator>
@@ -465,10 +468,9 @@ void IconbarTool::updateSizing() {
465 m_icon_container.setBorderWidth(m_theme.border().width()); 468 m_icon_container.setBorderWidth(m_theme.border().width());
466 m_icon_container.setBorderColor(m_theme.border().color()); 469 m_icon_container.setBorderColor(m_theme.border().color());
467 470
468 IconMap::iterator icon_it = m_icons.begin(); 471 FbTk::STLUtil::forAll(m_icons,
469 const IconMap::iterator icon_it_end = m_icons.end(); 472 FbTk::Compose(std::mem_fun(&IconButton::reconfigTheme),
470 for (; icon_it != icon_it_end; ++icon_it) 473 FbTk::Select2nd<IconMap::value_type>()));
471 icon_it->second->reconfigTheme();
472 474
473} 475}
474 476
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index 4d85bc1..61b740a 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.cc
@@ -387,10 +387,7 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name,
387#endif // REMEMBER 387#endif // REMEMBER
388 388
389 // init all "screens" 389 // init all "screens"
390 ScreenList::iterator it = m_screen_list.begin(); 390 STLUtil::forAll(m_screen_list, bind1st(mem_fun(&Fluxbox::initScreen), this));
391 ScreenList::iterator it_end = m_screen_list.end();
392 for(; it != it_end; ++it)
393 initScreen(*it);
394 391
395 XAllowEvents(disp, ReplayPointer, CurrentTime); 392 XAllowEvents(disp, ReplayPointer, CurrentTime);
396 393
@@ -435,11 +432,9 @@ void Fluxbox::initScreen(BScreen *screen) {
435 432
436 // now we can create menus (which needs this screen to be in screen_list) 433 // now we can create menus (which needs this screen to be in screen_list)
437 screen->initMenus(); 434 screen->initMenus();
438
439 screen->initWindows(); 435 screen->initWindows();
440 436
441 // attach screen signals to this 437 // attach screen signals to this
442
443 join(screen->workspaceAreaSig(), 438 join(screen->workspaceAreaSig(),
444 FbTk::MemFun(*this, &Fluxbox::workspaceAreaChanged)); 439 FbTk::MemFun(*this, &Fluxbox::workspaceAreaChanged));
445 440
@@ -458,11 +453,7 @@ void Fluxbox::initScreen(BScreen *screen) {
458 FbTk::MemFun(*this, &Fluxbox::workspaceCountChanged)); 453 FbTk::MemFun(*this, &Fluxbox::workspaceCountChanged));
459 454
460 // initiate atomhandler for screen specific stuff 455 // initiate atomhandler for screen specific stuff
461 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 456 STLUtil::forAll(m_atomhandler, bind2nd(mem_fun(&AtomHandler::initForScreen), *screen));
462 it != m_atomhandler.end();
463 it++) {
464 (*it)->initForScreen(*screen);
465 }
466 457
467 FocusControl::revertFocus(*screen); // make sure focus style is correct 458 FocusControl::revertFocus(*screen); // make sure focus style is correct
468 459
@@ -984,11 +975,9 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
984 } 975 }
985 976
986 if (fbwin && &fbwin->stateSig() == changedsub) { // state signal 977 if (fbwin && &fbwin->stateSig() == changedsub) { // state signal
987 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 978 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
988 it != m_atomhandler.end(); ++it) { 979 bind2nd(mem_fun(&AtomHandler::updateState), *fbwin));
989 if ((*it)->update()) 980
990 (*it)->updateState(*fbwin);
991 }
992 // if window changed to iconic state 981 // if window changed to iconic state
993 // add to icon list 982 // add to icon list
994 if (fbwin->isIconic()) { 983 if (fbwin->isIconic()) {
@@ -1009,17 +998,11 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
1009 } 998 }
1010 } 999 }
1011 } else if (fbwin && &fbwin->layerSig() == changedsub) { // layer signal 1000 } else if (fbwin && &fbwin->layerSig() == changedsub) { // layer signal
1012 AtomHandlerContainerIt it= m_atomhandler.begin(); 1001 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
1013 for (; it != m_atomhandler.end(); ++it) { 1002 bind2nd(mem_fun(&AtomHandler::updateLayer), *fbwin));
1014 if ((*it)->update())
1015 (*it)->updateLayer(*fbwin);
1016 }
1017 } else if (fbwin && &fbwin->dieSig() == changedsub) { // window death signal 1003 } else if (fbwin && &fbwin->dieSig() == changedsub) { // window death signal
1018 AtomHandlerContainerIt it= m_atomhandler.begin(); 1004 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
1019 for (; it != m_atomhandler.end(); ++it) { 1005 bind2nd(mem_fun(&AtomHandler::updateFrameClose), *fbwin));
1020 if ((*it)->update())
1021 (*it)->updateFrameClose(*fbwin);
1022 }
1023 1006
1024 // make sure each workspace get this 1007 // make sure each workspace get this
1025 BScreen &scr = fbwin->screen(); 1008 BScreen &scr = fbwin->screen();
@@ -1027,17 +1010,11 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
1027 if (FocusControl::focusedFbWindow() == fbwin) 1010 if (FocusControl::focusedFbWindow() == fbwin)
1028 FocusControl::setFocusedFbWindow(0); 1011 FocusControl::setFocusedFbWindow(0);
1029 } else if (fbwin && &fbwin->workspaceSig() == changedsub) { // workspace signal 1012 } else if (fbwin && &fbwin->workspaceSig() == changedsub) { // workspace signal
1030 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 1013 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
1031 it != m_atomhandler.end(); ++it) { 1014 bind2nd(mem_fun(&AtomHandler::updateClientClose), *fbwin));
1032 if ((*it)->update())
1033 (*it)->updateWorkspace(*fbwin);
1034 }
1035 } else if (client && &client->dieSig() == changedsub) { // client death 1015 } else if (client && &client->dieSig() == changedsub) { // client death
1036 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 1016 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
1037 it != m_atomhandler.end(); ++it) { 1017 bind2nd(mem_fun(&AtomHandler::updateClientClose), *client));
1038 if ((*it)->update())
1039 (*it)->updateClientClose(*client);
1040 }
1041 1018
1042 BScreen &screen = client->screen(); 1019 BScreen &screen = client->screen();
1043 1020
@@ -1066,19 +1043,12 @@ void Fluxbox::attachSignals(FluxboxWindow &win) {
1066 win.workspaceSig().attach(this); 1043 win.workspaceSig().attach(this);
1067 win.layerSig().attach(this); 1044 win.layerSig().attach(this);
1068 win.dieSig().attach(this); 1045 win.dieSig().attach(this);
1069 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 1046 STLUtil::forAll(m_atomhandler, bind2nd(mem_fun(&AtomHandler::setupFrame), win));
1070 it != m_atomhandler.end(); ++it) {
1071 (*it)->setupFrame(win);
1072 }
1073} 1047}
1074 1048
1075void Fluxbox::attachSignals(WinClient &winclient) { 1049void Fluxbox::attachSignals(WinClient &winclient) {
1076 winclient.dieSig().attach(this); 1050 winclient.dieSig().attach(this);
1077 1051 STLUtil::forAll(m_atomhandler, bind2nd(mem_fun(&AtomHandler::setupClient), winclient));
1078 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1079 it != m_atomhandler.end(); ++it) {
1080 (*it)->setupClient(winclient);
1081 }
1082} 1052}
1083 1053
1084BScreen *Fluxbox::searchScreen(Window window) { 1054BScreen *Fluxbox::searchScreen(Window window) {
@@ -1178,9 +1148,7 @@ void Fluxbox::shutdown() {
1178 1148
1179 XSetInputFocus(FbTk::App::instance()->display(), PointerRoot, None, CurrentTime); 1149 XSetInputFocus(FbTk::App::instance()->display(), PointerRoot, None, CurrentTime);
1180 1150
1181 //send shutdown to all screens 1151 STLUtil::forAll(m_screen_list, mem_fun(&BScreen::shutdown));
1182 for_each(m_screen_list.begin(),
1183 m_screen_list.end(), mem_fun(&BScreen::shutdown));
1184 1152
1185 sync(false); 1153 sync(false);
1186} 1154}
@@ -1353,32 +1321,21 @@ void Fluxbox::real_reconfigure() {
1353 for (; screen_it != screen_it_end; ++screen_it) 1321 for (; screen_it != screen_it_end; ++screen_it)
1354 load_rc(*(*screen_it)); 1322 load_rc(*(*screen_it));
1355 1323
1356 // reconfigure all screens 1324 STLUtil::forAll(m_screen_list, mem_fun(&BScreen::reconfigure));
1357 for_each(m_screen_list.begin(), m_screen_list.end(), mem_fun(&BScreen::reconfigure));
1358
1359 //reconfigure keys
1360 m_key->reconfigure(); 1325 m_key->reconfigure();
1361 1326 STLUtil::forAll(m_atomhandler, mem_fun(&AtomHandler::reconfigure));
1362 // and atomhandlers
1363 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1364 it != m_atomhandler.end();
1365 it++) {
1366 (*it)->reconfigure();
1367 }
1368} 1327}
1369 1328
1370BScreen *Fluxbox::findScreen(int id) { 1329BScreen *Fluxbox::findScreen(int id) {
1371 ScreenList::iterator it = m_screen_list.begin();
1372 ScreenList::iterator it_end = m_screen_list.end();
1373 for (; it != it_end; ++it) {
1374 if ((*it)->screenNumber() == id)
1375 break;
1376 }
1377 1330
1378 if (it == m_screen_list.end()) 1331 BScreen* result = 0;
1379 return 0; 1332 ScreenList::iterator it = find_if(m_screen_list.begin(), m_screen_list.end(),
1333 FbTk::CompareEqual<BScreen>(&BScreen::screenNumber, id));
1334
1335 if (it != m_screen_list.end())
1336 result = *it;
1380 1337
1381 return *it; 1338 return result;
1382} 1339}
1383 1340
1384void Fluxbox::timed_reconfigure() { 1341void Fluxbox::timed_reconfigure() {
@@ -1426,48 +1383,33 @@ bool Fluxbox::validateClient(const WinClient *client) const {
1426} 1383}
1427 1384
1428void Fluxbox::updateFrameExtents(FluxboxWindow &win) { 1385void Fluxbox::updateFrameExtents(FluxboxWindow &win) {
1429 AtomHandlerContainerIt it = m_atomhandler.begin(); 1386 STLUtil::forAll(m_atomhandler, bind2nd(mem_fun(&AtomHandler::updateFrameExtents), win));
1430 AtomHandlerContainerIt it_end = m_atomhandler.end();
1431 for (; it != it_end; ++it ) {
1432 (*it)->updateFrameExtents(win);
1433 }
1434} 1387}
1435 1388
1436void Fluxbox::workspaceCountChanged( BScreen& screen ) { 1389void Fluxbox::workspaceCountChanged( BScreen& screen ) {
1437 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 1390 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
1438 it != m_atomhandler.end(); ++it) { 1391 bind2nd(mem_fun(&AtomHandler::updateWorkspaceCount), screen));
1439 if ((*it)->update())
1440 (*it)->updateWorkspaceCount(screen);
1441 }
1442} 1392}
1443 1393
1444void Fluxbox::workspaceChanged( BScreen& screen ) { 1394void Fluxbox::workspaceChanged( BScreen& screen ) {
1445 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 1395 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
1446 it != m_atomhandler.end(); ++it) { 1396 bind2nd(mem_fun(&AtomHandler::updateCurrentWorkspace), screen));
1447 if ((*it)->update())
1448 (*it)->updateCurrentWorkspace(screen);
1449 }
1450} 1397}
1451 1398
1452void Fluxbox::workspaceNamesChanged(BScreen &screen) { 1399void Fluxbox::workspaceNamesChanged(BScreen &screen) {
1453 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 1400 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
1454 it != m_atomhandler.end(); ++it) { 1401 bind2nd(mem_fun(&AtomHandler::updateWorkspaceNames), screen));
1455 if ((*it)->update())
1456 (*it)->updateWorkspaceNames(screen);
1457 }
1458} 1402}
1459 1403
1460void Fluxbox::clientListChanged(BScreen &screen) { 1404void Fluxbox::clientListChanged(BScreen &screen) {
1461 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 1405 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
1462 it != m_atomhandler.end(); ++it) { 1406 bind2nd(mem_fun(&AtomHandler::updateClientList), screen));
1463 if ((*it)->update())
1464 (*it)->updateClientList(screen);
1465 }
1466} 1407}
1467 1408
1468void Fluxbox::focusedWindowChanged(BScreen &screen, 1409void Fluxbox::focusedWindowChanged(BScreen &screen,
1469 FluxboxWindow* win, 1410 FluxboxWindow* win,
1470 WinClient* client) { 1411 WinClient* client) {
1412
1471 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 1413 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1472 it != m_atomhandler.end(); it++) { 1414 it != m_atomhandler.end(); it++) {
1473 (*it)->updateFocusedWindow(screen, client ? client->window() : 0 ); 1415 (*it)->updateFocusedWindow(screen, client ? client->window() : 0 );
@@ -1475,9 +1417,7 @@ void Fluxbox::focusedWindowChanged(BScreen &screen,
1475} 1417}
1476 1418
1477void Fluxbox::workspaceAreaChanged(BScreen &screen) { 1419void Fluxbox::workspaceAreaChanged(BScreen &screen) {
1478 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 1420 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
1479 it != m_atomhandler.end(); ++it) { 1421 bind2nd(mem_fun(&AtomHandler::updateWorkarea), screen));
1480 if ((*it)->update())
1481 (*it)->updateWorkarea(screen);
1482 }
1483} 1422}
1423