summaryrefslogtreecommitdiff
path: root/src/Remember.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Remember.cc')
-rw-r--r--src/Remember.cc58
1 files changed, 22 insertions, 36 deletions
diff --git a/src/Remember.cc b/src/Remember.cc
index 8e133b8..f76fe9b 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
@@ -411,24 +411,8 @@ int Remember::parseApp(ifstream &file, Application &app, string *first_line) {
411 else 411 else
412 had_error = true; 412 had_error = true;
413 } else if (strcasecmp(str_key.c_str(), "Layer") == 0) { 413 } else if (strcasecmp(str_key.c_str(), "Layer") == 0) {
414 unsigned int l; 414 int l = Layer::getNumFromString(str_label);
415 if (strcasecmp(str_label.c_str(), "DESKTOP") == 0) { 415 had_error = (l == -1);
416 l = Layer::DESKTOP;
417 } else if (strcasecmp(str_label.c_str(), "BOTTOM") == 0) {
418 l = Layer::BOTTOM;
419 } else if (strcasecmp(str_label.c_str(), "NORMAL") == 0) {
420 l = Layer::NORMAL;
421 } else if (strcasecmp(str_label.c_str(), "TOP") == 0) {
422 l = Layer::TOP;
423 } else if (strcasecmp(str_label.c_str(), "DOCK") == 0) {
424 l = Layer::DOCK;
425 } else if (strcasecmp(str_label.c_str(), "ABOVEDOCK") == 0) {
426 l = Layer::ABOVE_DOCK;
427 } else if (strcasecmp(str_label.c_str(), "MENU") == 0) {
428 l = Layer::MENU;
429 } else if (!getuint(str_label.c_str(), l)) {
430 had_error = true;
431 }
432 if (!had_error) 416 if (!had_error)
433 app.rememberLayer(l); 417 app.rememberLayer(l);
434 } else if (strcasecmp(str_key.c_str(), "Dimensions") == 0) { 418 } else if (strcasecmp(str_key.c_str(), "Dimensions") == 0) {
@@ -579,11 +563,15 @@ Application *Remember::findMatchingPatterns(ClientPattern *pat, Patterns *patlis
579 563
580 564
581void Remember::reconfigure() { 565void Remember::reconfigure() {
582 string apps_string = FbTk::StringUtil::expandFilename(Fluxbox::instance()->getAppsFilename()); 566 m_reloader.setMainFile(Fluxbox::instance()->getAppsFilename());
567}
583 568
584 time_t timestamp = FbTk::FileUtil::getLastStatusChangeTimestamp(apps_string.c_str()); 569void Remember::checkReload() {
585 if (m_last_timestamp > 0 && m_last_timestamp == timestamp) 570 m_reloader.checkReload();
586 return; 571}
572
573void Remember::reload() {
574 string apps_string = FbTk::StringUtil::expandFilename(Fluxbox::instance()->getAppsFilename());
587 575
588#ifdef DEBUG 576#ifdef DEBUG
589 cerr<<__FILE__<<"("<<__FUNCTION__<<"): Loading apps file ["<<apps_string<<"]"<<endl; 577 cerr<<__FILE__<<"("<<__FUNCTION__<<"): Loading apps file ["<<apps_string<<"]"<<endl;
@@ -598,7 +586,6 @@ void Remember::reconfigure() {
598 m_startups.clear(); 586 m_startups.clear();
599 587
600 if (!apps_file.fail()) { 588 if (!apps_file.fail()) {
601 m_last_timestamp = timestamp;
602 if (!apps_file.eof()) { 589 if (!apps_file.eof()) {
603 string line; 590 string line;
604 int row = 0; 591 int row = 0;
@@ -687,7 +674,7 @@ void Remember::reconfigure() {
687#endif 674#endif
688 } 675 }
689 } else { 676 } else {
690 cerr << "apps file failure" << endl; 677 cerr << "failed to open apps file" << endl;
691 } 678 }
692 679
693 // Clean up old state 680 // Clean up old state
@@ -895,11 +882,8 @@ void Remember::save() {
895 apps_file << "[end]" << endl; 882 apps_file << "[end]" << endl;
896 } 883 }
897 apps_file.close(); 884 apps_file.close();
898 885 // update timestamp to avoid unnecessary reload
899 time_t timestamp = FbTk::FileUtil::getLastStatusChangeTimestamp(apps_string.c_str()); 886 m_reloader.addFile(Fluxbox::instance()->getAppsFilename());
900 if (timestamp > 0)
901 m_last_timestamp = timestamp;
902
903} 887}
904 888
905bool Remember::isRemembered(WinClient &winclient, Attribute attrib) { 889bool Remember::isRemembered(WinClient &winclient, Attribute attrib) {
@@ -978,8 +962,7 @@ void Remember::rememberAttrib(WinClient &winclient, Attribute attrib) {
978 app->rememberHead(win->screen().getHead(win->fbWindow())); 962 app->rememberHead(win->screen().getHead(win->fbWindow()));
979 break; 963 break;
980 case REM_DIMENSIONS: 964 case REM_DIMENSIONS:
981 //!! Note: This is odd, why dont we need to substract border width on win->width() ? 965 app->rememberDimensions(win->normalWidth(), win->normalHeight());
982 app->rememberDimensions(win->normalWidth(), win->normalHeight() - 2 * win->fbWindow().borderWidth());
983 break; 966 break;
984 case REM_POSITION: { 967 case REM_POSITION: {
985 int head = win->screen().getHead(win->fbWindow()); 968 int head = win->screen().getHead(win->fbWindow());
@@ -1216,6 +1199,9 @@ void Remember::setupClient(WinClient &winclient) {
1216 if (winclient.screen().isRestart()) 1199 if (winclient.screen().isRestart())
1217 return; 1200 return;
1218 1201
1202 // check if apps file has changed
1203 checkReload();
1204
1219 Application *app = find(winclient); 1205 Application *app = find(winclient);
1220 if (app == 0) 1206 if (app == 0)
1221 return; // nothing to do 1207 return; // nothing to do
@@ -1249,7 +1235,7 @@ FluxboxWindow *Remember::findGroup(Application *app, BScreen &screen) {
1249} 1235}
1250 1236
1251void Remember::updateClientClose(WinClient &winclient) { 1237void Remember::updateClientClose(WinClient &winclient) {
1252 reconfigure(); // reload if it's changed 1238 checkReload(); // reload if it's changed
1253 Application *app = find(winclient); 1239 Application *app = find(winclient);
1254 1240
1255 if (app && (app->save_on_close_remember && app->save_on_close)) { 1241 if (app && (app->save_on_close_remember && app->save_on_close)) {