summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fluxbox.cc153
-rw-r--r--src/fluxbox.hh11
2 files changed, 99 insertions, 65 deletions
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index aaba63d..9bff0e7 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: fluxbox.cc,v 1.237 2004/04/05 18:31:51 fluxgen Exp $ 25// $Id: fluxbox.cc,v 1.238 2004/04/18 21:16:06 fluxgen Exp $
26 26
27#include "fluxbox.hh" 27#include "fluxbox.hh"
28 28
@@ -478,15 +478,15 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile
478 478
479 // setup atom handlers before we create any windows 479 // setup atom handlers before we create any windows
480#ifdef USE_GNOME 480#ifdef USE_GNOME
481 addAtomHandler(new Gnome()); // for gnome 1 atom support 481 addAtomHandler(new Gnome(), "gnome"); // for gnome 1 atom support
482#endif //USE_GNOME 482#endif //USE_GNOME
483 483
484#ifdef USE_NEWWMSPEC 484#ifdef USE_NEWWMSPEC
485 addAtomHandler(new Ewmh()); // for Extended window manager atom support 485 addAtomHandler(new Ewmh(), "ewmh"); // for Extended window manager atom support
486#endif // USE_NEWWMSPEC 486#endif // USE_NEWWMSPEC
487 487
488#ifdef REMEMBER 488#ifdef REMEMBER
489 addAtomHandler(new Remember()); // for remembering window attribs 489 addAtomHandler(new Remember(), "remember"); // for remembering window attribs
490#endif // REMEMBER 490#endif // REMEMBER
491 491
492 grab(); 492 grab();
@@ -552,8 +552,10 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile
552 screen->clientListSig().attach(this); 552 screen->clientListSig().attach(this);
553 553
554 // initiate atomhandler for screen specific stuff 554 // initiate atomhandler for screen specific stuff
555 for (size_t atomh=0; atomh<m_atomhandler.size(); ++atomh) { 555 for (AtomHandlerContainerIt it= m_atomhandler.begin();
556 m_atomhandler[atomh]->initForScreen(*screen); 556 it != m_atomhandler.end();
557 it++) {
558 (*it).first->initForScreen(*screen);
557 } 559 }
558 560
559 revertFocus(*screen); // make sure focus style is correct 561 revertFocus(*screen); // make sure focus style is correct
@@ -604,9 +606,10 @@ Fluxbox::~Fluxbox() {
604 } 606 }
605 607
606 // destroy atomhandlers 608 // destroy atomhandlers
607 while (!m_atomhandler.empty()) { 609 for (AtomHandlerContainerIt it= m_atomhandler.begin();
608 delete m_atomhandler.back(); 610 it != m_atomhandler.end();
609 m_atomhandler.pop_back(); 611 it++) {
612 delete (*it).first;
610 } 613 }
611 614
612 while (!m_screen_list.empty()) { 615 while (!m_screen_list.empty()) {
@@ -906,8 +909,9 @@ void Fluxbox::handleEvent(XEvent * const e) {
906 break; 909 break;
907 // most of them are handled in FluxboxWindow::handleEvent 910 // most of them are handled in FluxboxWindow::handleEvent
908 // but some special cases like ewmh propertys needs to be checked 911 // but some special cases like ewmh propertys needs to be checked
909 for (size_t i=0; i<m_atomhandler.size(); ++i) { 912 for (AtomHandlerContainerIt it= m_atomhandler.begin();
910 if (m_atomhandler[i]->propertyNotify(*winclient, e->xproperty.atom)) 913 it != m_atomhandler.end(); it++) {
914 if ( (*it).first->propertyNotify(*winclient, e->xproperty.atom))
911 break; 915 break;
912 } 916 }
913 } break; 917 } break;
@@ -1198,8 +1202,9 @@ void Fluxbox::handleClientMessage(XClientMessageEvent &ce) {
1198 BScreen *screen = searchScreen(ce.window); 1202 BScreen *screen = searchScreen(ce.window);
1199 // note: we dont need screen nor winclient to be non-null, 1203 // note: we dont need screen nor winclient to be non-null,
1200 // it's up to the atomhandler to check that 1204 // it's up to the atomhandler to check that
1201 for (size_t i=0; i<m_atomhandler.size(); ++i) { 1205 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1202 m_atomhandler[i]->checkClientMessage(ce, screen, winclient); 1206 it != m_atomhandler.end(); it++) {
1207 (*it).first->checkClientMessage(ce, screen, winclient);
1203 } 1208 }
1204 1209
1205 } 1210 }
@@ -1307,14 +1312,16 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
1307 FluxboxWindow::WinSubject *winsub = dynamic_cast<FluxboxWindow::WinSubject *>(changedsub); 1312 FluxboxWindow::WinSubject *winsub = dynamic_cast<FluxboxWindow::WinSubject *>(changedsub);
1308 FluxboxWindow &win = winsub->win(); 1313 FluxboxWindow &win = winsub->win();
1309 if ((&(win.hintSig())) == changedsub) { // hint signal 1314 if ((&(win.hintSig())) == changedsub) { // hint signal
1310 for (size_t i=0; i<m_atomhandler.size(); ++i) { 1315 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1311 if (m_atomhandler[i]->update()) 1316 it != m_atomhandler.end(); ++it) {
1312 m_atomhandler[i]->updateHints(win); 1317 if ( (*it).first->update())
1318 (*it).first->updateHints(win);
1313 } 1319 }
1314 } else if ((&(win.stateSig())) == changedsub) { // state signal 1320 } else if ((&(win.stateSig())) == changedsub) { // state signal
1315 for (size_t i=0; i<m_atomhandler.size(); ++i) { 1321 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1316 if (m_atomhandler[i]->update()) 1322 it != m_atomhandler.end(); ++it) {
1317 m_atomhandler[i]->updateState(win); 1323 if ((*it).first->update())
1324 (*it).first->updateState(win);
1318 } 1325 }
1319 // if window changed to iconic state 1326 // if window changed to iconic state
1320 // add to icon list 1327 // add to icon list
@@ -1337,14 +1344,16 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
1337 } 1344 }
1338 } else if ((&(win.layerSig())) == changedsub) { // layer signal 1345 } else if ((&(win.layerSig())) == changedsub) { // layer signal
1339 1346
1340 for (size_t i=0; i<m_atomhandler.size(); ++i) { 1347 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1341 if (m_atomhandler[i]->update()) 1348 it != m_atomhandler.end(); ++it) {
1342 m_atomhandler[i]->updateLayer(win); 1349 if ((*it).first->update())
1350 (*it).first->updateLayer(win);
1343 } 1351 }
1344 } else if ((&(win.dieSig())) == changedsub) { // window death signal 1352 } else if ((&(win.dieSig())) == changedsub) { // window death signal
1345 for (size_t i=0; i<m_atomhandler.size(); ++i) { 1353 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1346 if (m_atomhandler[i]->update()) 1354 it != m_atomhandler.end(); ++it) {
1347 m_atomhandler[i]->updateFrameClose(win); 1355 if ((*it).first->update())
1356 (*it).first->updateFrameClose(win);
1348 } 1357 }
1349 // make sure each workspace get this 1358 // make sure each workspace get this
1350 BScreen &scr = win.screen(); 1359 BScreen &scr = win.screen();
@@ -1353,9 +1362,10 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
1353 m_focused_window = 0; 1362 m_focused_window = 0;
1354 1363
1355 } else if ((&(win.workspaceSig())) == changedsub) { // workspace signal 1364 } else if ((&(win.workspaceSig())) == changedsub) { // workspace signal
1356 for (size_t i=0; i<m_atomhandler.size(); ++i) { 1365 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1357 if (m_atomhandler[i]->update()) 1366 it != m_atomhandler.end(); ++it) {
1358 m_atomhandler[i]->updateWorkspace(win); 1367 if ((*it).first->update())
1368 (*it).first->updateWorkspace(win);
1359 } 1369 }
1360 } else { 1370 } else {
1361#ifdef DEBUG 1371#ifdef DEBUG
@@ -1367,29 +1377,34 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
1367 BScreen::ScreenSubject *subj = dynamic_cast<BScreen::ScreenSubject *>(changedsub); 1377 BScreen::ScreenSubject *subj = dynamic_cast<BScreen::ScreenSubject *>(changedsub);
1368 BScreen &screen = subj->screen(); 1378 BScreen &screen = subj->screen();
1369 if ((&(screen.workspaceCountSig())) == changedsub) { 1379 if ((&(screen.workspaceCountSig())) == changedsub) {
1370 for (size_t i=0; i<m_atomhandler.size(); ++i) { 1380 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1371 if (m_atomhandler[i]->update()) 1381 it != m_atomhandler.end(); ++it) {
1372 m_atomhandler[i]->updateWorkspaceCount(screen); 1382 if ((*it).first->update())
1383 (*it).first->updateWorkspaceCount(screen);
1373 } 1384 }
1374 } else if ((&(screen.workspaceNamesSig())) == changedsub) { 1385 } else if ((&(screen.workspaceNamesSig())) == changedsub) {
1375 for (size_t i=0; i<m_atomhandler.size(); ++i) { 1386 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1376 if (m_atomhandler[i]->update()) 1387 it != m_atomhandler.end(); ++it) {
1377 m_atomhandler[i]->updateWorkspaceNames(screen); 1388 if ((*it).first->update())
1389 (*it).first->updateWorkspaceNames(screen);
1378 } 1390 }
1379 } else if ((&(screen.currentWorkspaceSig())) == changedsub) { 1391 } else if ((&(screen.currentWorkspaceSig())) == changedsub) {
1380 for (size_t i=0; i<m_atomhandler.size(); ++i) { 1392 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1381 if (m_atomhandler[i]->update()) 1393 it != m_atomhandler.end(); ++it) {
1382 m_atomhandler[i]->updateCurrentWorkspace(screen); 1394 if ((*it).first->update())
1395 (*it).first->updateCurrentWorkspace(screen);
1383 } 1396 }
1384 } else if ((&(screen.workspaceAreaSig())) == changedsub) { 1397 } else if ((&(screen.workspaceAreaSig())) == changedsub) {
1385 for (size_t i=0; i<m_atomhandler.size(); ++i) { 1398 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1386 if (m_atomhandler[i]->update()) 1399 it != m_atomhandler.end(); ++it) {
1387 m_atomhandler[i]->updateWorkarea(screen); 1400 if ((*it).first->update())
1401 (*it).first->updateWorkarea(screen);
1388 } 1402 }
1389 } else if ((&(screen.clientListSig())) == changedsub) { 1403 } else if ((&(screen.clientListSig())) == changedsub) {
1390 for (size_t i=0; i<m_atomhandler.size(); ++i) { 1404 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1391 if (m_atomhandler[i]->update()) 1405 it != m_atomhandler.end(); ++it) {
1392 m_atomhandler[i]->updateClientList(screen); 1406 if ((*it).first->update())
1407 (*it).first->updateClientList(screen);
1393 } 1408 }
1394 } 1409 }
1395 } else if (typeid(*changedsub) == typeid(WinClient::WinClientSubj)) { 1410 } else if (typeid(*changedsub) == typeid(WinClient::WinClientSubj)) {
@@ -1398,9 +1413,10 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
1398 WinClient &client = subj->winClient(); 1413 WinClient &client = subj->winClient();
1399 1414
1400 // TODO: don't assume it is diesig (need to fix as soon as another signal appears) 1415 // TODO: don't assume it is diesig (need to fix as soon as another signal appears)
1401 for (size_t i=0; i<m_atomhandler.size(); ++i) { 1416 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1402 if (m_atomhandler[i]->update()) 1417 it != m_atomhandler.end(); ++it) {
1403 m_atomhandler[i]->updateClientClose(client); 1418 if ((*it).first->update())
1419 (*it).first->updateClientClose(client);
1404 } 1420 }
1405 1421
1406 BScreen &screen = client.screen(); 1422 BScreen &screen = client.screen();
@@ -1430,16 +1446,18 @@ void Fluxbox::attachSignals(FluxboxWindow &win) {
1430 win.workspaceSig().attach(this); 1446 win.workspaceSig().attach(this);
1431 win.layerSig().attach(this); 1447 win.layerSig().attach(this);
1432 win.dieSig().attach(this); 1448 win.dieSig().attach(this);
1433 for (size_t i=0; i<m_atomhandler.size(); ++i) { 1449 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1434 m_atomhandler[i]->setupFrame(win); 1450 it != m_atomhandler.end(); ++it) {
1451 (*it).first->setupFrame(win);
1435 } 1452 }
1436} 1453}
1437 1454
1438void Fluxbox::attachSignals(WinClient &winclient) { 1455void Fluxbox::attachSignals(WinClient &winclient) {
1439 winclient.dieSig().attach(this); 1456 winclient.dieSig().attach(this);
1440 1457
1441 for (size_t i=0; i<m_atomhandler.size(); ++i) { 1458 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1442 m_atomhandler[i]->setupClient(winclient); 1459 it != m_atomhandler.end(); ++it) {
1460 (*it).first->setupClient(winclient);
1443 } 1461 }
1444} 1462}
1445 1463
@@ -1455,18 +1473,27 @@ BScreen *Fluxbox::searchScreen(Window window) {
1455 return 0; 1473 return 0;
1456} 1474}
1457 1475
1458void Fluxbox::addAtomHandler(AtomHandler *atomh) { 1476
1459 for (unsigned int handler = 0; handler < m_atomhandler.size(); handler++) { 1477const AtomHandler* Fluxbox::getAtomHandler(std::string name) {
1460 if (m_atomhandler[handler] == atomh) 1478 if ( name != "" ) {
1461 return; 1479 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1480 it != m_atomhandler.end(); it++ ) {
1481 if ( name == (*it).second )
1482 return (*it).first;
1483 }
1462 } 1484 }
1463 m_atomhandler.push_back(atomh); 1485 return 0;
1486}
1487void Fluxbox::addAtomHandler(AtomHandler *atomh, std::string name) {
1488 m_atomhandler[atomh]= name;;
1464} 1489}
1465 1490
1466void Fluxbox::removeAtomHandler(AtomHandler *atomh) { 1491void Fluxbox::removeAtomHandler(AtomHandler *atomh) {
1467 std::vector<AtomHandler *>::iterator it = m_atomhandler.begin(); 1492
1468 for (; it != m_atomhandler.end(); ++it) { 1493 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1469 if (*it == atomh) { 1494 it != m_atomhandler.end();
1495 ++it) {
1496 if ((*it).first == atomh) {
1470 m_atomhandler.erase(it); 1497 m_atomhandler.erase(it);
1471 return; 1498 return;
1472 } 1499 }
@@ -1954,9 +1981,10 @@ void Fluxbox::setFocusedWindow(WinClient *client) {
1954 1981
1955 if (screen != 0) { 1982 if (screen != 0) {
1956 screen->updateNetizenWindowFocus(); 1983 screen->updateNetizenWindowFocus();
1957 for (size_t i=0; i < m_atomhandler.size(); ++i) { 1984 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1985 it != m_atomhandler.end(); it++) {
1958 1986
1959 m_atomhandler[i]->updateFocusedWindow(*screen, (m_focused_window ? 1987 (*it).first->updateFocusedWindow(*screen, (m_focused_window ?
1960 m_focused_window->window() : 1988 m_focused_window->window() :
1961 0)); 1989 0));
1962 } 1990 }
@@ -1964,8 +1992,9 @@ void Fluxbox::setFocusedWindow(WinClient *client) {
1964 1992
1965 if (old_screen && old_screen != screen) { 1993 if (old_screen && old_screen != screen) {
1966 old_screen->updateNetizenWindowFocus(); 1994 old_screen->updateNetizenWindowFocus();
1967 for (size_t i=0; i < m_atomhandler.size(); ++i) 1995 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1968 m_atomhandler[i]->updateFocusedWindow(*old_screen, 0); 1996 it != m_atomhandler.end(); it++)
1997 (*it).first->updateFocusedWindow(*old_screen, 0);
1969 } 1998 }
1970 1999
1971} 2000}
diff --git a/src/fluxbox.hh b/src/fluxbox.hh
index f063a1b..8c4630f 100644
--- a/src/fluxbox.hh
+++ b/src/fluxbox.hh
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: fluxbox.hh,v 1.84 2004/03/21 09:00:25 rathnor Exp $ 25// $Id: fluxbox.hh,v 1.85 2004/04/18 21:16:06 fluxgen Exp $
26 26
27#ifndef FLUXBOX_HH 27#ifndef FLUXBOX_HH
28#define FLUXBOX_HH 28#define FLUXBOX_HH
@@ -101,7 +101,8 @@ public:
101 inline unsigned int getUpdateDelayTime() const { return *m_rc_update_delay_time; } 101 inline unsigned int getUpdateDelayTime() const { return *m_rc_update_delay_time; }
102 inline Time getLastTime() const { return m_last_time; } 102 inline Time getLastTime() const { return m_last_time; }
103 103
104 void addAtomHandler(AtomHandler *atomh); 104 const AtomHandler* getAtomHandler(std::string name);
105 void addAtomHandler(AtomHandler *atomh, std::string name= "");
105 void removeAtomHandler(AtomHandler *atomh); 106 void removeAtomHandler(AtomHandler *atomh);
106 107
107 /// obsolete 108 /// obsolete
@@ -292,7 +293,11 @@ private:
292 //default arguments for titlebar left and right 293 //default arguments for titlebar left and right
293 static Fluxbox::Titlebar s_titlebar_left[], s_titlebar_right[]; 294 static Fluxbox::Titlebar s_titlebar_left[], s_titlebar_right[];
294 static Fluxbox *s_singleton; 295 static Fluxbox *s_singleton;
295 std::vector<AtomHandler *> m_atomhandler; 296
297 typedef std::map<AtomHandler *, std::string> AtomHandlerContainer;
298 typedef AtomHandlerContainer::iterator AtomHandlerContainerIt;
299
300 AtomHandlerContainer m_atomhandler;
296 std::vector<Toolbar *> m_toolbars; 301 std::vector<Toolbar *> m_toolbars;
297 302
298 bool m_starting; 303 bool m_starting;