diff options
author | fluxgen <fluxgen> | 2002-09-07 20:25:39 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2002-09-07 20:25:39 (GMT) |
commit | c89591388be97519732c8d0738c9501db0957afd (patch) | |
tree | 746ad0cb7d16190aed227eeac7ba8c082532c773 /src/fluxbox.cc | |
parent | 314c3116f0778f8a91c4aa605f7d3ffe57246e80 (diff) | |
download | fluxbox-c89591388be97519732c8d0738c9501db0957afd.zip fluxbox-c89591388be97519732c8d0738c9501db0957afd.tar.bz2 |
added AtomHandler, fixed observer and removed gnome stuff
Diffstat (limited to 'src/fluxbox.cc')
-rw-r--r-- | src/fluxbox.cc | 209 |
1 files changed, 114 insertions, 95 deletions
diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 01e2c3f..345cde8 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.73 2002/08/30 14:07:38 fluxgen Exp $ | 25 | // $Id: fluxbox.cc,v 1.74 2002/09/07 20:25:39 fluxgen Exp $ |
26 | 26 | ||
27 | 27 | ||
28 | #include "fluxbox.hh" | 28 | #include "fluxbox.hh" |
@@ -39,6 +39,10 @@ | |||
39 | #include "StringUtil.hh" | 39 | #include "StringUtil.hh" |
40 | #include "Resource.hh" | 40 | #include "Resource.hh" |
41 | #include "XrmDatabaseHelper.hh" | 41 | #include "XrmDatabaseHelper.hh" |
42 | #include "AtomHandler.hh" | ||
43 | #include "Gnome.hh" | ||
44 | //#include "Ewmh.hh" | ||
45 | |||
42 | #ifdef SLIT | 46 | #ifdef SLIT |
43 | #include "Slit.hh" | 47 | #include "Slit.hh" |
44 | #endif // SLIT | 48 | #endif // SLIT |
@@ -118,6 +122,7 @@ | |||
118 | #include <string> | 122 | #include <string> |
119 | #include <memory> | 123 | #include <memory> |
120 | #include <algorithm> | 124 | #include <algorithm> |
125 | #include <typeinfo> | ||
121 | 126 | ||
122 | using namespace std; | 127 | using namespace std; |
123 | using namespace FbTk; | 128 | using namespace FbTk; |
@@ -336,6 +341,10 @@ key(0) | |||
336 | cursor.move = XCreateFontCursor(getXDisplay(), XC_fleur); | 341 | cursor.move = XCreateFontCursor(getXDisplay(), XC_fleur); |
337 | cursor.ll_angle = XCreateFontCursor(getXDisplay(), XC_ll_angle); | 342 | cursor.ll_angle = XCreateFontCursor(getXDisplay(), XC_ll_angle); |
338 | cursor.lr_angle = XCreateFontCursor(getXDisplay(), XC_lr_angle); | 343 | cursor.lr_angle = XCreateFontCursor(getXDisplay(), XC_lr_angle); |
344 | |||
345 | // setup atom handlers | ||
346 | m_atomhandler.push_back(new Gnome()); | ||
347 | // m_atomhandler.push_back(new Ewmh()); // TODO | ||
339 | 348 | ||
340 | //singleton pointer | 349 | //singleton pointer |
341 | singleton = this; | 350 | singleton = this; |
@@ -376,11 +385,20 @@ key(0) | |||
376 | sprintf(scrname, "session.screen%d", i); | 385 | sprintf(scrname, "session.screen%d", i); |
377 | sprintf(altscrname, "session.Screen%d", i); | 386 | sprintf(altscrname, "session.Screen%d", i); |
378 | BScreen *screen = new BScreen(m_screen_rm, this, scrname, altscrname, i); | 387 | BScreen *screen = new BScreen(m_screen_rm, this, scrname, altscrname, i); |
379 | |||
380 | if (! screen->isScreenManaged()) { | 388 | if (! screen->isScreenManaged()) { |
381 | delete screen; | 389 | delete screen; |
382 | continue; | 390 | continue; |
383 | } | 391 | } |
392 | // attach screen signals to this | ||
393 | screen->currentWorkspaceSig().attach(this); | ||
394 | screen->workspaceCountSig().attach(this); | ||
395 | screen->workspaceNamesSig().attach(this); | ||
396 | screen->clientListSig().attach(this); | ||
397 | |||
398 | // initiate atomhandler for screen specific stuff | ||
399 | for (size_t atomh=0; atomh<m_atomhandler.size(); ++atomh) { | ||
400 | m_atomhandler[i]->initForScreen(*screen); | ||
401 | } | ||
384 | 402 | ||
385 | screenList.push_back(screen); | 403 | screenList.push_back(screen); |
386 | } | 404 | } |
@@ -411,7 +429,13 @@ key(0) | |||
411 | } | 429 | } |
412 | 430 | ||
413 | 431 | ||
414 | Fluxbox::~Fluxbox(void) { | 432 | Fluxbox::~Fluxbox() { |
433 | // destroy atomhandlers | ||
434 | while (!m_atomhandler.empty()) { | ||
435 | delete m_atomhandler.back(); | ||
436 | m_atomhandler.pop_back(); | ||
437 | } | ||
438 | |||
415 | std::list<MenuTimestamp *>::iterator it = menuTimestamps.begin(); | 439 | std::list<MenuTimestamp *>::iterator it = menuTimestamps.begin(); |
416 | std::list<MenuTimestamp *>::iterator it_end = menuTimestamps.end(); | 440 | std::list<MenuTimestamp *>::iterator it_end = menuTimestamps.end(); |
417 | for (; it != it_end; ++it) { | 441 | for (; it != it_end; ++it) { |
@@ -645,7 +669,10 @@ void Fluxbox::handleEvent(XEvent * const e) { | |||
645 | win = new FluxboxWindow(e->xmaprequest.window); | 669 | win = new FluxboxWindow(e->xmaprequest.window); |
646 | if (!win->isManaged()) { | 670 | if (!win->isManaged()) { |
647 | delete win; | 671 | delete win; |
648 | win = 0; | 672 | win = 0; |
673 | } else { | ||
674 | // attach signals | ||
675 | attachSignals(*win); | ||
649 | } | 676 | } |
650 | } | 677 | } |
651 | 678 | ||
@@ -884,9 +911,9 @@ void Fluxbox::handleButtonEvent(XButtonEvent &be) { | |||
884 | FluxboxWindow *win = (FluxboxWindow *) 0; | 911 | FluxboxWindow *win = (FluxboxWindow *) 0; |
885 | Basemenu *menu = (Basemenu *) 0; | 912 | Basemenu *menu = (Basemenu *) 0; |
886 | 913 | ||
887 | #ifdef SLIT | 914 | #ifdef SLIT |
888 | Slit *slit = (Slit *) 0; | 915 | Slit *slit = (Slit *) 0; |
889 | #endif // SLIT | 916 | #endif // SLIT |
890 | 917 | ||
891 | Toolbar *tbar = (Toolbar *) 0; | 918 | Toolbar *tbar = (Toolbar *) 0; |
892 | Tab *tab = 0; | 919 | Tab *tab = 0; |
@@ -901,10 +928,10 @@ void Fluxbox::handleButtonEvent(XButtonEvent &be) { | |||
901 | } else if ((menu = searchMenu(be.window))) { | 928 | } else if ((menu = searchMenu(be.window))) { |
902 | menu->buttonPressEvent(&be); | 929 | menu->buttonPressEvent(&be); |
903 | 930 | ||
904 | #ifdef SLIT | 931 | #ifdef SLIT |
905 | } else if ((slit = searchSlit(be.window))) { | 932 | } else if ((slit = searchSlit(be.window))) { |
906 | slit->buttonPressEvent(&be); | 933 | slit->buttonPressEvent(&be); |
907 | #endif // SLIT | 934 | #endif // SLIT |
908 | 935 | ||
909 | } else if ((tbar = searchToolbar(be.window))) { | 936 | } else if ((tbar = searchToolbar(be.window))) { |
910 | tbar->buttonPressEvent(&be); | 937 | tbar->buttonPressEvent(&be); |
@@ -1107,17 +1134,12 @@ void Fluxbox::handleClientMessage(XClientMessageEvent &ce) { | |||
1107 | win->changeBlackboxHints(&net); | 1134 | win->changeBlackboxHints(&net); |
1108 | } | 1135 | } |
1109 | } else { | 1136 | } else { |
1110 | bool val = false; | 1137 | FluxboxWindow *win = searchWindow(ce.window); |
1111 | #ifdef GNOME | 1138 | BScreen *screen = searchScreen(ce.window); |
1112 | val = checkGnomeAtoms(ce); | 1139 | |
1113 | #endif //!GNOME | 1140 | for (size_t i=0; i<m_atomhandler.size(); ++i) { |
1114 | 1141 | m_atomhandler[i]->checkClientMessage(ce, screen, win); | |
1115 | #ifdef NEWWMSPEC | 1142 | } |
1116 | if (!val) | ||
1117 | val = checkNETWMAtoms(ce); | ||
1118 | #endif //!NEWWMSPEC | ||
1119 | //disable `unused`-warning | ||
1120 | val = true; | ||
1121 | } | 1143 | } |
1122 | } | 1144 | } |
1123 | //----------- handleKeyEvent --------------- | 1145 | //----------- handleKeyEvent --------------- |
@@ -1531,80 +1553,6 @@ void Fluxbox::doWindowAction(Keys::KeyAction action, const int param) { | |||
1531 | } | 1553 | } |
1532 | 1554 | ||
1533 | } | 1555 | } |
1534 | #ifdef GNOME | ||
1535 | //---------------- checkGnomeAtoms --------------- | ||
1536 | // Tries to find Gnome atoms in message | ||
1537 | // Returns true on success else false | ||
1538 | //--------------------------------------------- | ||
1539 | bool Fluxbox::checkGnomeAtoms(XClientMessageEvent &ce) { | ||
1540 | BScreen *screen = 0; | ||
1541 | FluxboxWindow *win = 0; | ||
1542 | win = searchWindow(ce.window); | ||
1543 | screen = searchScreen(ce.window); | ||
1544 | |||
1545 | if (ce.message_type == getGnomeWorkspaceAtom()) { | ||
1546 | #ifdef DEBUG | ||
1547 | cerr<<__FILE__<<"("<<__LINE__<<"): Got workspace atom="<<ce.data.l[0]<<endl; | ||
1548 | #endif//!DEBUG | ||
1549 | if ( win !=0 && // the message sent to client window? | ||
1550 | win->getScreen() && ce.data.l[0] >= 0 && | ||
1551 | ce.data.l[0] < (signed)win->getScreen()->getCount()) { | ||
1552 | win->getScreen()->changeWorkspaceID(ce.data.l[0]); | ||
1553 | |||
1554 | } else if (screen!=0 && //the message sent to root window? | ||
1555 | ce.data.l[0] >= 0 && | ||
1556 | ce.data.l[0] < (signed)screen->getCount()) | ||
1557 | screen->changeWorkspaceID(ce.data.l[0]); | ||
1558 | return true; | ||
1559 | } else if (win) { | ||
1560 | if (ce.message_type == getGnomeStateAtom()) { | ||
1561 | #ifdef DEBUG | ||
1562 | cerr<<__FILE__<<"("<<__LINE__<<"): _WIN_STATE"<<endl; | ||
1563 | #endif // DEBUG | ||
1564 | |||
1565 | #ifdef DEBUG | ||
1566 | cerr<<__FILE__<<"("<<__LINE__<<"): Mask of members to change:"<< | ||
1567 | hex<<ce.data.l[0]<<dec<<endl; // mask_of_members_to_change | ||
1568 | cerr<<"New members:"<<ce.data.l[1]<<endl; | ||
1569 | #endif // DEBUG | ||
1570 | |||
1571 | //get new states | ||
1572 | int flag = ce.data.l[0] & ce.data.l[1]; | ||
1573 | //set states | ||
1574 | win->setGnomeState(flag); | ||
1575 | |||
1576 | } else if (ce.message_type == getGnomeHintsAtom()) { | ||
1577 | #ifdef DEBUG | ||
1578 | cerr<<__FILE__<<"("<<__LINE__<<"): _WIN_HINTS"<<endl; | ||
1579 | #endif // DEBUG | ||
1580 | |||
1581 | } else | ||
1582 | return false; //the gnome atom wasn't found or not supported | ||
1583 | } else | ||
1584 | return false; //no gnome atom | ||
1585 | |||
1586 | return true; | ||
1587 | } | ||
1588 | #endif //!GNOME | ||
1589 | |||
1590 | #ifdef NEWWMSPEC | ||
1591 | //----------- checkNETWMAtoms ------------------- | ||
1592 | // Tries to find NEWWM atom in clientmessage | ||
1593 | // Returns true on success else false | ||
1594 | //----------------------------------------------- | ||
1595 | bool Fluxbox::checkNETWMAtoms(XClientMessageEvent &ce) { | ||
1596 | |||
1597 | if (ce.message_type == getNETWMDesktopAtom()) { //_NET_WM_DESKTOP | ||
1598 | BScreen *screen = searchScreen(ce.window); | ||
1599 | |||
1600 | if (screen && ce.data.l[0] >= 0 && | ||
1601 | ce.data.l[0] < screen->getCount()) | ||
1602 | screen->changeWorkspaceID(ce.data.l[0]); | ||
1603 | } else return false; | ||
1604 | |||
1605 | return true; | ||
1606 | } | ||
1607 | #endif //!NEWWMSPEC | ||
1608 | 1556 | ||
1609 | void Fluxbox::handleEvent(SignalEvent * const sig) { | 1557 | void Fluxbox::handleEvent(SignalEvent * const sig) { |
1610 | I18n *i18n = I18n::instance(); | 1558 | I18n *i18n = I18n::instance(); |
@@ -1655,9 +1603,80 @@ void Fluxbox::handleEvent(SignalEvent * const sig) { | |||
1655 | abort(); | 1603 | abort(); |
1656 | break; | 1604 | break; |
1657 | } | 1605 | } |
1606 | } | ||
1658 | 1607 | ||
1659 | |||
1660 | 1608 | ||
1609 | void Fluxbox::update(FbTk::Subject *changedsub) { | ||
1610 | |||
1611 | if (typeid(*changedsub) == typeid(FluxboxWindow)) { | ||
1612 | FluxboxWindow::WinSubject *winsub = dynamic_cast<FluxboxWindow::WinSubject *>(changedsub); | ||
1613 | FluxboxWindow &win = winsub->win(); | ||
1614 | if ((&(win.hintSig())) == changedsub) { // hint signal | ||
1615 | #ifdef DEBUG | ||
1616 | cerr<<__FILE__<<"("<<__LINE__<<") hint signal from "<<&win<<endl; | ||
1617 | #endif // DEBUG | ||
1618 | for (size_t i=0; i<m_atomhandler.size(); ++i) { | ||
1619 | if (m_atomhandler[i]->update()) | ||
1620 | m_atomhandler[i]->updateHints(&win); | ||
1621 | } | ||
1622 | } else if ((&(win.stateSig())) == changedsub) { // state signal | ||
1623 | #ifdef DEBUG | ||
1624 | cerr<<__FILE__<<"("<<__LINE__<<") state signal from "<<&win<<endl; | ||
1625 | #endif // DEBUG | ||
1626 | for (size_t i=0; i<m_atomhandler.size(); ++i) { | ||
1627 | if (m_atomhandler[i]->update()) | ||
1628 | m_atomhandler[i]->updateState(&win); | ||
1629 | } | ||
1630 | } else if ((&(win.workspaceSig())) == changedsub) { // workspace signal | ||
1631 | #ifdef DEBUG | ||
1632 | cerr<<__FILE__<<"("<<__LINE__<<") workspace signal from "<<&win<<endl; | ||
1633 | #endif // DEBUG | ||
1634 | |||
1635 | } | ||
1636 | |||
1637 | } else if (typeid(*changedsub) == typeid(BScreen::ScreenSubject)) { | ||
1638 | BScreen::ScreenSubject *subj = dynamic_cast<BScreen::ScreenSubject *>(changedsub); | ||
1639 | BScreen &screen = subj->screen(); | ||
1640 | if ((&(screen.workspaceCountSig())) == changedsub) { | ||
1641 | #ifdef DEBUG | ||
1642 | cerr<<__FILE__<<"("<<__LINE__<<"): workspace count signal"<<endl; | ||
1643 | #endif // DEBUG | ||
1644 | for (size_t i=0; i<m_atomhandler.size(); ++i) { | ||
1645 | if (m_atomhandler[i]->update()) | ||
1646 | m_atomhandler[i]->updateWorkspaceCount(screen); | ||
1647 | } | ||
1648 | } else if ((&(screen.workspaceNamesSig())) == changedsub) { | ||
1649 | #ifdef DEBUG | ||
1650 | cerr<<__FILE__<<"("<<__LINE__<<"): workspace names signal"<<endl; | ||
1651 | #endif // DEBUG | ||
1652 | for (size_t i=0; i<m_atomhandler.size(); ++i) { | ||
1653 | if (m_atomhandler[i]->update()) | ||
1654 | m_atomhandler[i]->updateWorkspaceNames(screen); | ||
1655 | } | ||
1656 | } else if ((&(screen.currentWorkspaceSig())) == changedsub) { | ||
1657 | #ifdef DEBUG | ||
1658 | cerr<<__FILE__<<"("<<__LINE__<<"): current workspace signal"<<endl; | ||
1659 | #endif // DEBUG | ||
1660 | for (size_t i=0; i<m_atomhandler.size(); ++i) { | ||
1661 | if (m_atomhandler[i]->update()) | ||
1662 | m_atomhandler[i]->updateCurrentWorkspace(screen); | ||
1663 | } | ||
1664 | } else if ((&(screen.clientListSig())) == changedsub) { | ||
1665 | #ifdef DEBUG | ||
1666 | cerr<<__FILE__<<"("<<__LINE__<<"): client list signal"<<endl; | ||
1667 | #endif // DEBUG | ||
1668 | for (size_t i=0; i<m_atomhandler.size(); ++i) { | ||
1669 | if (m_atomhandler[i]->update()) | ||
1670 | m_atomhandler[i]->updateClientList(screen); | ||
1671 | } | ||
1672 | } | ||
1673 | } | ||
1674 | } | ||
1675 | |||
1676 | void Fluxbox::attachSignals(FluxboxWindow &win) { | ||
1677 | win.hintSig().attach(this); | ||
1678 | win.stateSig().attach(this); | ||
1679 | win.workspaceSig().attach(this); | ||
1661 | } | 1680 | } |
1662 | 1681 | ||
1663 | 1682 | ||