aboutsummaryrefslogtreecommitdiff
path: root/src/fluxbox.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/fluxbox.cc')
-rw-r--r--src/fluxbox.cc64
1 files changed, 25 insertions, 39 deletions
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index b5e7828..3d82eb5 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.cc
@@ -38,6 +38,7 @@
38 38
39#include "FbTk/I18n.hh" 39#include "FbTk/I18n.hh"
40#include "FbTk/Image.hh" 40#include "FbTk/Image.hh"
41#include "FbTk/FileUtil.hh"
41#include "FbTk/KeyUtil.hh" 42#include "FbTk/KeyUtil.hh"
42#include "FbTk/ImageControl.hh" 43#include "FbTk/ImageControl.hh"
43#include "FbTk/EventManager.hh" 44#include "FbTk/EventManager.hh"
@@ -151,24 +152,11 @@ class Toolbar { };
151using namespace std; 152using namespace std;
152using namespace FbTk; 153using namespace FbTk;
153 154
154static Window last_bad_window = None;
155namespace { 155namespace {
156void copyFile(const std::string &from, const std::string &to) {
157 ifstream from_file(from.c_str());
158 ofstream to_file(to.c_str());
159
160 if (! to_file.good()) {
161 cerr<<"Can't write file: "<<to<<endl;
162 } else if (from_file.good()) {
163 to_file<<from_file.rdbuf(); //copy file
164 } else {
165 cerr<<"Can't copy from "<<from<<" to "<<to<<endl;
166 }
167}
168
169} // end anonymous
170 156
171static int handleXErrors(Display *d, XErrorEvent *e) { 157Window last_bad_window = None;
158
159int handleXErrors(Display *d, XErrorEvent *e) {
172 if (e->error_code == BadWindow) 160 if (e->error_code == BadWindow)
173 last_bad_window = e->resourceid; 161 last_bad_window = e->resourceid;
174#ifdef DEBUG 162#ifdef DEBUG
@@ -183,10 +171,10 @@ static int handleXErrors(Display *d, XErrorEvent *e) {
183 } 171 }
184#endif // !DEBUG 172#endif // !DEBUG
185 173
186
187 return False; 174 return False;
188} 175}
189 176
177} // end anonymous
190 178
191//static singleton var 179//static singleton var
192Fluxbox *Fluxbox::s_singleton=0; 180Fluxbox *Fluxbox::s_singleton=0;
@@ -573,15 +561,15 @@ void Fluxbox::setupConfigFiles() {
573 561
574 // copy key configuration 562 // copy key configuration
575 if (create_keys) 563 if (create_keys)
576 copyFile(DEFAULTKEYSFILE, keys_file); 564 FbTk::FileUtil::copyFile(DEFAULTKEYSFILE, keys_file.c_str());
577 565
578 // copy menu configuration 566 // copy menu configuration
579 if (create_menu) 567 if (create_menu)
580 copyFile(DEFAULTMENU, menu_file); 568 FbTk::FileUtil::copyFile(DEFAULTMENU, menu_file.c_str());
581 569
582 // copy init file 570 // copy init file
583 if (create_init) 571 if (create_init)
584 copyFile(DEFAULT_INITFILE, init_file); 572 FbTk::FileUtil::copyFile(DEFAULT_INITFILE, init_file.c_str());
585 573
586} 574}
587 575
@@ -1644,10 +1632,11 @@ bool Fluxbox::menuTimestampsChanged() const {
1644 std::list<MenuTimestamp *>::const_iterator it = m_menu_timestamps.begin(); 1632 std::list<MenuTimestamp *>::const_iterator it = m_menu_timestamps.begin();
1645 std::list<MenuTimestamp *>::const_iterator it_end = m_menu_timestamps.end(); 1633 std::list<MenuTimestamp *>::const_iterator it_end = m_menu_timestamps.end();
1646 for (; it != it_end; ++it) { 1634 for (; it != it_end; ++it) {
1647 struct stat buf; 1635
1636 time_t timestamp = FbTk::FileUtil::getLastStatusChangeTimestamp((*it)->filename.c_str());
1648 1637
1649 if (! stat((*it)->filename.c_str(), &buf)) { 1638 if (timestamp >= 0) {
1650 if ((*it)->timestamp != buf.st_ctime) 1639 if (timestamp != (*it)->timestamp)
1651 return true; 1640 return true;
1652 } else 1641 } else
1653 return true; 1642 return true;
@@ -1683,13 +1672,12 @@ void Fluxbox::rereadMenu(bool show_after_reread) {
1683 1672
1684 1673
1685void Fluxbox::real_rereadMenu() { 1674void Fluxbox::real_rereadMenu() {
1686 std::list<MenuTimestamp *>::iterator it = m_menu_timestamps.begin(); 1675
1687 std::list<MenuTimestamp *>::iterator it_end = m_menu_timestamps.end(); 1676 clearMenuFilenames();
1688 for (; it != it_end; ++it) 1677
1689 delete *it; 1678 for_each(m_screen_list.begin(),
1690 1679 m_screen_list.end(),
1691 m_menu_timestamps.erase(m_menu_timestamps.begin(), m_menu_timestamps.end()); 1680 mem_fun(&BScreen::rereadMenu));
1692 for_each(m_screen_list.begin(), m_screen_list.end(), mem_fun(&BScreen::rereadMenu));
1693 1681
1694 if(m_show_menu_after_reread) { 1682 if(m_show_menu_after_reread) {
1695 1683
@@ -1716,13 +1704,13 @@ void Fluxbox::saveMenuFilename(const char *filename) {
1716 } 1704 }
1717 1705
1718 if (! found) { 1706 if (! found) {
1719 struct stat buf; 1707 time_t timestamp = FbTk::FileUtil::getLastStatusChangeTimestamp(filename);
1720 1708
1721 if (! stat(filename, &buf)) { 1709 if (timestamp >= 0) {
1722 MenuTimestamp *ts = new MenuTimestamp; 1710 MenuTimestamp *ts = new MenuTimestamp;
1723 1711
1724 ts->filename = filename; 1712 ts->filename = filename;
1725 ts->timestamp = buf.st_ctime; 1713 ts->timestamp = timestamp;
1726 1714
1727 m_menu_timestamps.push_back(ts); 1715 m_menu_timestamps.push_back(ts);
1728 } 1716 }
@@ -1730,12 +1718,10 @@ void Fluxbox::saveMenuFilename(const char *filename) {
1730} 1718}
1731 1719
1732void Fluxbox::clearMenuFilenames() { 1720void Fluxbox::clearMenuFilenames() {
1733 std::list<MenuTimestamp *>::iterator it = m_menu_timestamps.begin(); 1721 while(!m_menu_timestamps.empty()) {
1734 std::list<MenuTimestamp *>::iterator it_end = m_menu_timestamps.end(); 1722 delete m_menu_timestamps.back();
1735 for (; it != it_end; ++it) 1723 m_menu_timestamps.pop_back();
1736 delete *it; 1724 }
1737
1738 m_menu_timestamps.erase(m_menu_timestamps.begin(), m_menu_timestamps.end());
1739} 1725}
1740 1726
1741void Fluxbox::timed_reconfigure() { 1727void Fluxbox::timed_reconfigure() {