aboutsummaryrefslogtreecommitdiff
path: root/src/fluxbox.cc
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2010-09-13 20:04:24 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2010-09-13 20:04:24 (GMT)
commitdeb6a1ebf43f458b720abbc6a7180e9a8e04771a (patch)
treeecff64e1eb70e43ff15b93de2f98953cfadd0067 /src/fluxbox.cc
parentf6af17aa58701cdb579cca52ac83edf289e118e7 (diff)
downloadfluxbox-deb6a1ebf43f458b720abbc6a7180e9a8e04771a.zip
fluxbox-deb6a1ebf43f458b720abbc6a7180e9a8e04771a.tar.bz2
code simplification
we do not need a std::map just to store an attribute on an AtomHandler, it makes housekeeping just more annoying.
Diffstat (limited to 'src/fluxbox.cc')
-rw-r--r--src/fluxbox.cc101
1 files changed, 42 insertions, 59 deletions
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index aabdb04..1bc0d13 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.cc
@@ -373,17 +373,17 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name,
373 m_keyscreen = m_mousescreen = m_screen_list.front(); 373 m_keyscreen = m_mousescreen = m_screen_list.front();
374 374
375#ifdef USE_NEWWMSPEC 375#ifdef USE_NEWWMSPEC
376 addAtomHandler(new Ewmh(), "ewmh"); // for Extended window manager atom support 376 addAtomHandler(new Ewmh()); // for Extended window manager atom support
377#endif // USE_NEWWMSPEC 377#endif // USE_NEWWMSPEC
378#ifdef USE_GNOME 378#ifdef USE_GNOME
379 addAtomHandler(new Gnome(), "gnome"); // for gnome 1 atom support 379 addAtomHandler(new Gnome()); // for gnome 1 atom support
380#endif //USE_GNOME 380#endif //USE_GNOME
381 // parse apps file after creating screens (so we can tell if it's a restart 381 // parse apps file after creating screens (so we can tell if it's a restart
382 // for [startup] items) but before creating windows 382 // for [startup] items) but before creating windows
383 // this needs to be after ewmh and gnome, so state atoms don't get 383 // this needs to be after ewmh and gnome, so state atoms don't get
384 // overwritten before they're applied 384 // overwritten before they're applied
385#ifdef REMEMBER 385#ifdef REMEMBER
386 addAtomHandler(new Remember(), "remember"); // for remembering window attribs 386 addAtomHandler(new Remember()); // for remembering window attribs
387#endif // REMEMBER 387#endif // REMEMBER
388 388
389 // init all "screens" 389 // init all "screens"
@@ -425,18 +425,9 @@ Fluxbox::~Fluxbox() {
425 leaveAll(); // leave all connections 425 leaveAll(); // leave all connections
426 426
427 // destroy screens (after others, as they may do screen things) 427 // destroy screens (after others, as they may do screen things)
428 while (!m_screen_list.empty()) { 428 FbTk::STLUtil::destroyAndClear(m_screen_list);
429 delete m_screen_list.back();
430 m_screen_list.pop_back();
431 }
432 429
433 // destroy atomhandlers 430 FbTk::STLUtil::destroyAndClear(m_atomhandler);
434 for (AtomHandlerContainerIt it= m_atomhandler.begin();
435 it != m_atomhandler.end();
436 it++) {
437 delete (*it).first;
438 }
439 m_atomhandler.clear();
440} 431}
441 432
442 433
@@ -470,7 +461,7 @@ void Fluxbox::initScreen(BScreen *screen) {
470 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 461 for (AtomHandlerContainerIt it= m_atomhandler.begin();
471 it != m_atomhandler.end(); 462 it != m_atomhandler.end();
472 it++) { 463 it++) {
473 (*it).first->initForScreen(*screen); 464 (*it)->initForScreen(*screen);
474 } 465 }
475 466
476 FocusControl::revertFocus(*screen); // make sure focus style is correct 467 FocusControl::revertFocus(*screen); // make sure focus style is correct
@@ -758,7 +749,7 @@ void Fluxbox::handleEvent(XEvent * const e) {
758 // but some special cases like ewmh propertys needs to be checked 749 // but some special cases like ewmh propertys needs to be checked
759 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 750 for (AtomHandlerContainerIt it= m_atomhandler.begin();
760 it != m_atomhandler.end(); it++) { 751 it != m_atomhandler.end(); it++) {
761 if ( (*it).first->propertyNotify(*winclient, e->xproperty.atom)) 752 if ( (*it)->propertyNotify(*winclient, e->xproperty.atom))
762 break; 753 break;
763 } 754 }
764 } break; 755 } break;
@@ -927,7 +918,7 @@ void Fluxbox::handleClientMessage(XClientMessageEvent &ce) {
927 // it's up to the atomhandler to check that 918 // it's up to the atomhandler to check that
928 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 919 for (AtomHandlerContainerIt it= m_atomhandler.begin();
929 it != m_atomhandler.end(); it++) { 920 it != m_atomhandler.end(); it++) {
930 (*it).first->checkClientMessage(ce, screen, winclient); 921 (*it)->checkClientMessage(ce, screen, winclient);
931 } 922 }
932 923
933 } 924 }
@@ -999,8 +990,8 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
999 if (fbwin && &fbwin->stateSig() == changedsub) { // state signal 990 if (fbwin && &fbwin->stateSig() == changedsub) { // state signal
1000 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 991 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1001 it != m_atomhandler.end(); ++it) { 992 it != m_atomhandler.end(); ++it) {
1002 if ((*it).first->update()) 993 if ((*it)->update())
1003 (*it).first->updateState(*fbwin); 994 (*it)->updateState(*fbwin);
1004 } 995 }
1005 // if window changed to iconic state 996 // if window changed to iconic state
1006 // add to icon list 997 // add to icon list
@@ -1024,14 +1015,14 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
1024 } else if (fbwin && &fbwin->layerSig() == changedsub) { // layer signal 1015 } else if (fbwin && &fbwin->layerSig() == changedsub) { // layer signal
1025 AtomHandlerContainerIt it= m_atomhandler.begin(); 1016 AtomHandlerContainerIt it= m_atomhandler.begin();
1026 for (; it != m_atomhandler.end(); ++it) { 1017 for (; it != m_atomhandler.end(); ++it) {
1027 if ((*it).first->update()) 1018 if ((*it)->update())
1028 (*it).first->updateLayer(*fbwin); 1019 (*it)->updateLayer(*fbwin);
1029 } 1020 }
1030 } else if (fbwin && &fbwin->dieSig() == changedsub) { // window death signal 1021 } else if (fbwin && &fbwin->dieSig() == changedsub) { // window death signal
1031 AtomHandlerContainerIt it= m_atomhandler.begin(); 1022 AtomHandlerContainerIt it= m_atomhandler.begin();
1032 for (; it != m_atomhandler.end(); ++it) { 1023 for (; it != m_atomhandler.end(); ++it) {
1033 if ((*it).first->update()) 1024 if ((*it)->update())
1034 (*it).first->updateFrameClose(*fbwin); 1025 (*it)->updateFrameClose(*fbwin);
1035 } 1026 }
1036 1027
1037 // make sure each workspace get this 1028 // make sure each workspace get this
@@ -1042,14 +1033,14 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
1042 } else if (fbwin && &fbwin->workspaceSig() == changedsub) { // workspace signal 1033 } else if (fbwin && &fbwin->workspaceSig() == changedsub) { // workspace signal
1043 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 1034 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1044 it != m_atomhandler.end(); ++it) { 1035 it != m_atomhandler.end(); ++it) {
1045 if ((*it).first->update()) 1036 if ((*it)->update())
1046 (*it).first->updateWorkspace(*fbwin); 1037 (*it)->updateWorkspace(*fbwin);
1047 } 1038 }
1048 } else if (client && &client->dieSig() == changedsub) { // client death 1039 } else if (client && &client->dieSig() == changedsub) { // client death
1049 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 1040 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1050 it != m_atomhandler.end(); ++it) { 1041 it != m_atomhandler.end(); ++it) {
1051 if ((*it).first->update()) 1042 if ((*it)->update())
1052 (*it).first->updateClientClose(*client); 1043 (*it)->updateClientClose(*client);
1053 } 1044 }
1054 1045
1055 BScreen &screen = client->screen(); 1046 BScreen &screen = client->screen();
@@ -1081,7 +1072,7 @@ void Fluxbox::attachSignals(FluxboxWindow &win) {
1081 win.dieSig().attach(this); 1072 win.dieSig().attach(this);
1082 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 1073 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1083 it != m_atomhandler.end(); ++it) { 1074 it != m_atomhandler.end(); ++it) {
1084 (*it).first->setupFrame(win); 1075 (*it)->setupFrame(win);
1085 } 1076 }
1086} 1077}
1087 1078
@@ -1090,7 +1081,7 @@ void Fluxbox::attachSignals(WinClient &winclient) {
1090 1081
1091 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 1082 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1092 it != m_atomhandler.end(); ++it) { 1083 it != m_atomhandler.end(); ++it) {
1093 (*it).first->setupClient(winclient); 1084 (*it)->setupClient(winclient);
1094 } 1085 }
1095} 1086}
1096 1087
@@ -1109,29 +1100,21 @@ BScreen *Fluxbox::searchScreen(Window window) {
1109 1100
1110AtomHandler* Fluxbox::getAtomHandler(const string &name) { 1101AtomHandler* Fluxbox::getAtomHandler(const string &name) {
1111 if ( name != "" ) { 1102 if ( name != "" ) {
1112 using namespace FbTk; 1103
1113 AtomHandlerContainerIt it = find_if(m_atomhandler.begin(), 1104 AtomHandlerContainerIt it;
1114 m_atomhandler.end(), 1105 for (it = m_atomhandler.begin(); it != m_atomhandler.end(); it++) {
1115 Compose(bind2nd(equal_to<string>(), name), 1106 if (name == (*it)->getName())
1116 Select2nd<AtomHandlerContainer::value_type>())); 1107 return *it;
1117 if (it != m_atomhandler.end()) 1108 }
1118 return (*it).first;
1119 } 1109 }
1120 return 0; 1110 return 0;
1121} 1111}
1122void Fluxbox::addAtomHandler(AtomHandler *atomh, const string &name) { 1112void Fluxbox::addAtomHandler(AtomHandler *atomh) {
1123 m_atomhandler[atomh]= name; 1113 m_atomhandler.insert(atomh);
1124} 1114}
1125 1115
1126void Fluxbox::removeAtomHandler(AtomHandler *atomh) { 1116void Fluxbox::removeAtomHandler(AtomHandler *atomh) {
1127 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 1117 m_atomhandler.erase(atomh);
1128 it != m_atomhandler.end();
1129 ++it) {
1130 if ((*it).first == atomh) {
1131 m_atomhandler.erase(it);
1132 return;
1133 }
1134 }
1135} 1118}
1136 1119
1137WinClient *Fluxbox::searchWindow(Window window) { 1120WinClient *Fluxbox::searchWindow(Window window) {
@@ -1387,7 +1370,7 @@ void Fluxbox::real_reconfigure() {
1387 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 1370 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1388 it != m_atomhandler.end(); 1371 it != m_atomhandler.end();
1389 it++) { 1372 it++) {
1390 (*it).first->reconfigure(); 1373 (*it)->reconfigure();
1391 } 1374 }
1392} 1375}
1393 1376
@@ -1453,39 +1436,39 @@ void Fluxbox::updateFrameExtents(FluxboxWindow &win) {
1453 AtomHandlerContainerIt it = m_atomhandler.begin(); 1436 AtomHandlerContainerIt it = m_atomhandler.begin();
1454 AtomHandlerContainerIt it_end = m_atomhandler.end(); 1437 AtomHandlerContainerIt it_end = m_atomhandler.end();
1455 for (; it != it_end; ++it ) { 1438 for (; it != it_end; ++it ) {
1456 (*it).first->updateFrameExtents(win); 1439 (*it)->updateFrameExtents(win);
1457 } 1440 }
1458} 1441}
1459 1442
1460void Fluxbox::workspaceCountChanged( BScreen& screen ) { 1443void Fluxbox::workspaceCountChanged( BScreen& screen ) {
1461 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 1444 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1462 it != m_atomhandler.end(); ++it) { 1445 it != m_atomhandler.end(); ++it) {
1463 if ((*it).first->update()) 1446 if ((*it)->update())
1464 (*it).first->updateWorkspaceCount(screen); 1447 (*it)->updateWorkspaceCount(screen);
1465 } 1448 }
1466} 1449}
1467 1450
1468void Fluxbox::workspaceChanged( BScreen& screen ) { 1451void Fluxbox::workspaceChanged( BScreen& screen ) {
1469 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 1452 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1470 it != m_atomhandler.end(); ++it) { 1453 it != m_atomhandler.end(); ++it) {
1471 if ((*it).first->update()) 1454 if ((*it)->update())
1472 (*it).first->updateCurrentWorkspace(screen); 1455 (*it)->updateCurrentWorkspace(screen);
1473 } 1456 }
1474} 1457}
1475 1458
1476void Fluxbox::workspaceNamesChanged(BScreen &screen) { 1459void Fluxbox::workspaceNamesChanged(BScreen &screen) {
1477 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 1460 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1478 it != m_atomhandler.end(); ++it) { 1461 it != m_atomhandler.end(); ++it) {
1479 if ((*it).first->update()) 1462 if ((*it)->update())
1480 (*it).first->updateWorkspaceNames(screen); 1463 (*it)->updateWorkspaceNames(screen);
1481 } 1464 }
1482} 1465}
1483 1466
1484void Fluxbox::clientListChanged(BScreen &screen) { 1467void Fluxbox::clientListChanged(BScreen &screen) {
1485 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 1468 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1486 it != m_atomhandler.end(); ++it) { 1469 it != m_atomhandler.end(); ++it) {
1487 if ((*it).first->update()) 1470 if ((*it)->update())
1488 (*it).first->updateClientList(screen); 1471 (*it)->updateClientList(screen);
1489 } 1472 }
1490} 1473}
1491 1474
@@ -1494,14 +1477,14 @@ void Fluxbox::focusedWindowChanged(BScreen &screen,
1494 WinClient* client) { 1477 WinClient* client) {
1495 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 1478 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1496 it != m_atomhandler.end(); it++) { 1479 it != m_atomhandler.end(); it++) {
1497 (*it).first->updateFocusedWindow(screen, client ? client->window() : 0 ); 1480 (*it)->updateFocusedWindow(screen, client ? client->window() : 0 );
1498 } 1481 }
1499} 1482}
1500 1483
1501void Fluxbox::workspaceAreaChanged(BScreen &screen) { 1484void Fluxbox::workspaceAreaChanged(BScreen &screen) {
1502 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 1485 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1503 it != m_atomhandler.end(); ++it) { 1486 it != m_atomhandler.end(); ++it) {
1504 if ((*it).first->update()) 1487 if ((*it)->update())
1505 (*it).first->updateWorkarea(screen); 1488 (*it)->updateWorkarea(screen);
1506 } 1489 }
1507} 1490}