aboutsummaryrefslogtreecommitdiff
path: root/src/Remember.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Remember.cc')
-rw-r--r--src/Remember.cc35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/Remember.cc b/src/Remember.cc
index 8e133b8..2bd691f 100644
--- a/src/Remember.cc
+++ b/src/Remember.cc
@@ -120,7 +120,7 @@ public:
120 120
121 void click(int button, int time, unsigned int mods) { 121 void click(int button, int time, unsigned int mods) {
122 // reconfigure only does stuff if the apps file has changed 122 // reconfigure only does stuff if the apps file has changed
123 Remember::instance().reconfigure(); 123 Remember::instance().checkReload();
124 if (WindowCmd<void>::window() != 0) { 124 if (WindowCmd<void>::window() != 0) {
125 if (isSelected()) { 125 if (isSelected()) {
126 Remember::instance().forgetAttrib(WindowCmd<void>::window()->winClient(), m_attrib); 126 Remember::instance().forgetAttrib(WindowCmd<void>::window()->winClient(), m_attrib);
@@ -281,14 +281,14 @@ void Application::reset() {
281Remember *Remember::s_instance = 0; 281Remember *Remember::s_instance = 0;
282 282
283Remember::Remember(): 283Remember::Remember():
284 m_pats(new Patterns()), 284 m_pats(new Patterns()) {
285 m_last_timestamp(0)
286{
287 if (s_instance != 0) 285 if (s_instance != 0)
288 throw string("Can not create more than one instance of Remember"); 286 throw string("Can not create more than one instance of Remember");
289 287
290 s_instance = this; 288 s_instance = this;
291 enableUpdate(); 289 enableUpdate();
290
291 m_reloader.setReloadCmd(FbTk::RefCount<FbTk::Command<void> >(new FbTk::SimpleCommand<Remember>(*this, &Remember::reload)));
292 reconfigure(); 292 reconfigure();
293} 293}
294 294
@@ -579,11 +579,15 @@ Application *Remember::findMatchingPatterns(ClientPattern *pat, Patterns *patlis
579 579
580 580
581void Remember::reconfigure() { 581void Remember::reconfigure() {
582 string apps_string = FbTk::StringUtil::expandFilename(Fluxbox::instance()->getAppsFilename()); 582 m_reloader.setMainFile(Fluxbox::instance()->getAppsFilename());
583}
583 584
584 time_t timestamp = FbTk::FileUtil::getLastStatusChangeTimestamp(apps_string.c_str()); 585void Remember::checkReload() {
585 if (m_last_timestamp > 0 && m_last_timestamp == timestamp) 586 m_reloader.checkReload();
586 return; 587}
588
589void Remember::reload() {
590 string apps_string = FbTk::StringUtil::expandFilename(Fluxbox::instance()->getAppsFilename());
587 591
588#ifdef DEBUG 592#ifdef DEBUG
589 cerr<<__FILE__<<"("<<__FUNCTION__<<"): Loading apps file ["<<apps_string<<"]"<<endl; 593 cerr<<__FILE__<<"("<<__FUNCTION__<<"): Loading apps file ["<<apps_string<<"]"<<endl;
@@ -598,7 +602,6 @@ void Remember::reconfigure() {
598 m_startups.clear(); 602 m_startups.clear();
599 603
600 if (!apps_file.fail()) { 604 if (!apps_file.fail()) {
601 m_last_timestamp = timestamp;
602 if (!apps_file.eof()) { 605 if (!apps_file.eof()) {
603 string line; 606 string line;
604 int row = 0; 607 int row = 0;
@@ -687,7 +690,7 @@ void Remember::reconfigure() {
687#endif 690#endif
688 } 691 }
689 } else { 692 } else {
690 cerr << "apps file failure" << endl; 693 cerr << "failed to open apps file" << endl;
691 } 694 }
692 695
693 // Clean up old state 696 // Clean up old state
@@ -895,11 +898,8 @@ void Remember::save() {
895 apps_file << "[end]" << endl; 898 apps_file << "[end]" << endl;
896 } 899 }
897 apps_file.close(); 900 apps_file.close();
898 901 // update timestamp to avoid unnecessary reload
899 time_t timestamp = FbTk::FileUtil::getLastStatusChangeTimestamp(apps_string.c_str()); 902 m_reloader.addFile(Fluxbox::instance()->getAppsFilename());
900 if (timestamp > 0)
901 m_last_timestamp = timestamp;
902
903} 903}
904 904
905bool Remember::isRemembered(WinClient &winclient, Attribute attrib) { 905bool Remember::isRemembered(WinClient &winclient, Attribute attrib) {
@@ -1216,6 +1216,9 @@ void Remember::setupClient(WinClient &winclient) {
1216 if (winclient.screen().isRestart()) 1216 if (winclient.screen().isRestart())
1217 return; 1217 return;
1218 1218
1219 // check if apps file has changed
1220 checkReload();
1221
1219 Application *app = find(winclient); 1222 Application *app = find(winclient);
1220 if (app == 0) 1223 if (app == 0)
1221 return; // nothing to do 1224 return; // nothing to do
@@ -1249,7 +1252,7 @@ FluxboxWindow *Remember::findGroup(Application *app, BScreen &screen) {
1249} 1252}
1250 1253
1251void Remember::updateClientClose(WinClient &winclient) { 1254void Remember::updateClientClose(WinClient &winclient) {
1252 reconfigure(); // reload if it's changed 1255 checkReload(); // reload if it's changed
1253 Application *app = find(winclient); 1256 Application *app = find(winclient);
1254 1257
1255 if (app && (app->save_on_close_remember && app->save_on_close)) { 1258 if (app && (app->save_on_close_remember && app->save_on_close)) {