aboutsummaryrefslogtreecommitdiff
path: root/src
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
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')
-rw-r--r--src/AtomHandler.hh6
-rw-r--r--src/Ewmh.cc1
-rw-r--r--src/Gnome.cc1
-rw-r--r--src/Remember.cc2
-rw-r--r--src/SystemTray.cc3
-rw-r--r--src/fluxbox.cc101
-rw-r--r--src/fluxbox.hh4
7 files changed, 56 insertions, 62 deletions
diff --git a/src/AtomHandler.hh b/src/AtomHandler.hh
index aa38ed2..6e517d0 100644
--- a/src/AtomHandler.hh
+++ b/src/AtomHandler.hh
@@ -23,6 +23,7 @@
23#ifndef ATOMHANDLER_HH 23#ifndef ATOMHANDLER_HH
24#define ATOMHANDLER_HH 24#define ATOMHANDLER_HH
25 25
26#include <string>
26#include <X11/Xlib.h> 27#include <X11/Xlib.h>
27 28
28class FluxboxWindow; 29class FluxboxWindow;
@@ -61,6 +62,10 @@ public:
61 62
62 /// should this object be updated or not? 63 /// should this object be updated or not?
63 bool update() const { return m_update; } 64 bool update() const { return m_update; }
65
66 void setName(const std::string& name) { m_name = name; }
67 const std::string& getName() const { return m_name; }
68
64protected: 69protected:
65 AtomHandler():m_update(true) { } 70 AtomHandler():m_update(true) { }
66 71
@@ -68,6 +73,7 @@ protected:
68 void enableUpdate() { m_update = true; } 73 void enableUpdate() { m_update = true; }
69private: 74private:
70 bool m_update; ///< do we get update or not 75 bool m_update; ///< do we get update or not
76 std::string m_name; ///< name of atomhandler
71}; 77};
72 78
73#endif // ATOMHANDLER_HH 79#endif // ATOMHANDLER_HH
diff --git a/src/Ewmh.cc b/src/Ewmh.cc
index c09154d..77581b8 100644
--- a/src/Ewmh.cc
+++ b/src/Ewmh.cc
@@ -477,6 +477,7 @@ enum EwmhMoveResizeDirection {
477}; 477};
478 478
479Ewmh::Ewmh() { 479Ewmh::Ewmh() {
480 setName("ewmh");
480 m_net = new EwmhAtoms; 481 m_net = new EwmhAtoms;
481} 482}
482 483
diff --git a/src/Gnome.cc b/src/Gnome.cc
index 3c84942..78e8a2f 100644
--- a/src/Gnome.cc
+++ b/src/Gnome.cc
@@ -44,6 +44,7 @@ using std::hex;
44using std::dec; 44using std::dec;
45 45
46Gnome::Gnome() { 46Gnome::Gnome() {
47 setName("gnome");
47 createAtoms(); 48 createAtoms();
48 enableUpdate(); 49 enableUpdate();
49} 50}
diff --git a/src/Remember.cc b/src/Remember.cc
index 54b5b0d..ef5e7d9 100644
--- a/src/Remember.cc
+++ b/src/Remember.cc
@@ -617,6 +617,8 @@ Remember::Remember():
617 m_pats(new Patterns()), 617 m_pats(new Patterns()),
618 m_reloader(new FbTk::AutoReloadHelper()) { 618 m_reloader(new FbTk::AutoReloadHelper()) {
619 619
620 setName("remember");
621
620 if (s_instance != 0) 622 if (s_instance != 0)
621 throw string("Can not create more than one instance of Remember"); 623 throw string("Can not create more than one instance of Remember");
622 624
diff --git a/src/SystemTray.cc b/src/SystemTray.cc
index 73d8c0d..c145351 100644
--- a/src/SystemTray.cc
+++ b/src/SystemTray.cc
@@ -195,7 +195,8 @@ SystemTray::SystemTray(const FbTk::FbWindow& parent,
195 195
196 m_handler.reset(new SystemTrayHandler(*this)); 196 m_handler.reset(new SystemTrayHandler(*this));
197 197
198 fluxbox->addAtomHandler(m_handler.get(), atom_name); 198 m_handler.get()->setName(atom_name);
199 fluxbox->addAtomHandler(m_handler.get());
199 200
200 201
201 // send selection owner msg 202 // send selection owner msg
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}
diff --git a/src/fluxbox.hh b/src/fluxbox.hh
index 6082b25..75b868f 100644
--- a/src/fluxbox.hh
+++ b/src/fluxbox.hh
@@ -106,7 +106,7 @@ public:
106 Time getLastTime() const { return m_last_time; } 106 Time getLastTime() const { return m_last_time; }
107 107
108 AtomHandler *getAtomHandler(const std::string &name); 108 AtomHandler *getAtomHandler(const std::string &name);
109 void addAtomHandler(AtomHandler *atomh, const std::string &name); 109 void addAtomHandler(AtomHandler *atomh);
110 void removeAtomHandler(AtomHandler *atomh); 110 void removeAtomHandler(AtomHandler *atomh);
111 111
112 /// obsolete 112 /// obsolete
@@ -277,7 +277,7 @@ private:
277 //default arguments for titlebar left and right 277 //default arguments for titlebar left and right
278 static Fluxbox *s_singleton; 278 static Fluxbox *s_singleton;
279 279
280 typedef std::map<AtomHandler *, std::string> AtomHandlerContainer; 280 typedef std::set<AtomHandler *> AtomHandlerContainer;
281 typedef AtomHandlerContainer::iterator AtomHandlerContainerIt; 281 typedef AtomHandlerContainer::iterator AtomHandlerContainerIt;
282 282
283 AtomHandlerContainer m_atomhandler; 283 AtomHandlerContainer m_atomhandler;