aboutsummaryrefslogtreecommitdiff
path: root/src/fluxbox.cc
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 /src/fluxbox.cc
parentba316aa18a8813958cedea1cc4d54452e40c4b59 (diff)
downloadfluxbox-12e1ef78265a621dc51f7b9af245d81431835dcc.zip
fluxbox-12e1ef78265a621dc51f7b9af245d81431835dcc.tar.bz2
code deduplication by using <algorithm> and FbTk/STLUtil.hh
Diffstat (limited to 'src/fluxbox.cc')
-rw-r--r--src/fluxbox.cc136
1 files changed, 38 insertions, 98 deletions
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