diff options
Diffstat (limited to 'src/fluxbox.cc')
-rw-r--r-- | src/fluxbox.cc | 103 |
1 files changed, 16 insertions, 87 deletions
diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 78a482e..ac18281 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc | |||
@@ -185,13 +185,17 @@ int handleXErrors(Display *d, XErrorEvent *e) { | |||
185 | //static singleton var | 185 | //static singleton var |
186 | Fluxbox *Fluxbox::s_singleton=0; | 186 | Fluxbox *Fluxbox::s_singleton=0; |
187 | 187 | ||
188 | Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, | 188 | Fluxbox::Fluxbox(int argc, char **argv, |
189 | const char *rcfilename, bool xsync) | 189 | const std::string& dpy_name, |
190 | : FbTk::App(dpy_name), | 190 | const std::string& rc_path, const std::string& rc_filename, bool xsync) |
191 | : FbTk::App(dpy_name.c_str()), | ||
191 | m_fbatoms(FbAtoms::instance()), | 192 | m_fbatoms(FbAtoms::instance()), |
192 | m_resourcemanager(rcfilename, true), | 193 | m_resourcemanager(rc_filename.c_str(), true), |
193 | // TODO: shouldn't need a separate one for screen | 194 | // TODO: shouldn't need a separate one for screen |
194 | m_screen_rm(m_resourcemanager), | 195 | m_screen_rm(m_resourcemanager), |
196 | |||
197 | m_RC_PATH(rc_path), | ||
198 | m_RC_INIT_FILE("init"), | ||
195 | m_rc_ignoreborder(m_resourcemanager, false, "session.ignoreBorder", "Session.IgnoreBorder"), | 199 | m_rc_ignoreborder(m_resourcemanager, false, "session.ignoreBorder", "Session.IgnoreBorder"), |
196 | m_rc_pseudotrans(m_resourcemanager, false, "session.forcePseudoTransparency", "Session.forcePseudoTransparency"), | 200 | m_rc_pseudotrans(m_resourcemanager, false, "session.forcePseudoTransparency", "Session.forcePseudoTransparency"), |
197 | m_rc_colors_per_channel(m_resourcemanager, 4, | 201 | m_rc_colors_per_channel(m_resourcemanager, 4, |
@@ -199,11 +203,11 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, | |||
199 | m_rc_double_click_interval(m_resourcemanager, 250, "session.doubleClickInterval", "Session.DoubleClickInterval"), | 203 | m_rc_double_click_interval(m_resourcemanager, 250, "session.doubleClickInterval", "Session.DoubleClickInterval"), |
200 | m_rc_tabs_padding(m_resourcemanager, 0, "session.tabPadding", "Session.TabPadding"), | 204 | m_rc_tabs_padding(m_resourcemanager, 0, "session.tabPadding", "Session.TabPadding"), |
201 | m_rc_stylefile(m_resourcemanager, DEFAULTSTYLE, "session.styleFile", "Session.StyleFile"), | 205 | m_rc_stylefile(m_resourcemanager, DEFAULTSTYLE, "session.styleFile", "Session.StyleFile"), |
202 | m_rc_styleoverlayfile(m_resourcemanager, "~/." + realProgramName("fluxbox") + "/overlay", "session.styleOverlay", "Session.StyleOverlay"), | 206 | m_rc_styleoverlayfile(m_resourcemanager, m_RC_PATH + "/overlay", "session.styleOverlay", "Session.StyleOverlay"), |
203 | m_rc_menufile(m_resourcemanager, DEFAULTMENU, "session.menuFile", "Session.MenuFile"), | 207 | m_rc_menufile(m_resourcemanager, m_RC_PATH + "/menu", "session.menuFile", "Session.MenuFile"), |
204 | m_rc_keyfile(m_resourcemanager, DEFAULTKEYSFILE, "session.keyFile", "Session.KeyFile"), | 208 | m_rc_keyfile(m_resourcemanager, m_RC_PATH + "/keys", "session.keyFile", "Session.KeyFile"), |
205 | m_rc_slitlistfile(m_resourcemanager, "~/." + realProgramName("fluxbox") + "/slitlist", "session.slitlistFile", "Session.SlitlistFile"), | 209 | m_rc_slitlistfile(m_resourcemanager, m_RC_PATH + "/slitlist", "session.slitlistFile", "Session.SlitlistFile"), |
206 | m_rc_appsfile(m_resourcemanager, "~/." + realProgramName("fluxbox") + "/apps", "session.appsFile", "Session.AppsFile"), | 210 | m_rc_appsfile(m_resourcemanager, m_RC_PATH + "/apps", "session.appsFile", "Session.AppsFile"), |
207 | m_rc_tabs_attach_area(m_resourcemanager, ATTACH_AREA_WINDOW, "session.tabsAttachArea", "Session.TabsAttachArea"), | 211 | m_rc_tabs_attach_area(m_resourcemanager, ATTACH_AREA_WINDOW, "session.tabsAttachArea", "Session.TabsAttachArea"), |
208 | m_rc_cache_life(m_resourcemanager, 5, "session.cacheLife", "Session.CacheLife"), | 212 | m_rc_cache_life(m_resourcemanager, 5, "session.cacheLife", "Session.CacheLife"), |
209 | m_rc_cache_max(m_resourcemanager, 200, "session.cacheMax", "Session.CacheMax"), | 213 | m_rc_cache_max(m_resourcemanager, 200, "session.cacheMax", "Session.CacheMax"), |
@@ -213,16 +217,14 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, | |||
213 | m_keyscreen(0), | 217 | m_keyscreen(0), |
214 | m_last_time(0), | 218 | m_last_time(0), |
215 | m_masked(0), | 219 | m_masked(0), |
216 | m_rc_file(rcfilename ? rcfilename : ""), | 220 | m_rc_file(rc_filename), |
217 | m_argv(argv), m_argc(argc), | 221 | m_argv(argv), m_argc(argc), |
218 | m_showing_dialog(false), | 222 | m_showing_dialog(false), |
219 | m_starting(true), | 223 | m_starting(true), |
220 | m_restarting(false), | 224 | m_restarting(false), |
221 | m_shutdown(false), | 225 | m_shutdown(false), |
222 | m_server_grabs(0), | 226 | m_server_grabs(0), |
223 | m_randr_event_type(0), | 227 | m_randr_event_type(0) { |
224 | m_RC_PATH(realProgramName("fluxbox")), | ||
225 | m_RC_INIT_FILE("init") { | ||
226 | 228 | ||
227 | _FB_USES_NLS; | 229 | _FB_USES_NLS; |
228 | if (s_singleton != 0) | 230 | if (s_singleton != 0) |
@@ -288,8 +290,6 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, | |||
288 | 290 | ||
289 | grab(); | 291 | grab(); |
290 | 292 | ||
291 | setupConfigFiles(); | ||
292 | |||
293 | if (! XSupportsLocale()) | 293 | if (! XSupportsLocale()) |
294 | cerr<<_FB_CONSOLETEXT(Fluxbox, WarningLocale, | 294 | cerr<<_FB_CONSOLETEXT(Fluxbox, WarningLocale, |
295 | "Warning: X server does not support locale", | 295 | "Warning: X server does not support locale", |
@@ -512,76 +512,6 @@ void Fluxbox::ungrab() { | |||
512 | m_server_grabs = 0; | 512 | m_server_grabs = 0; |
513 | } | 513 | } |
514 | 514 | ||
515 | /** | ||
516 | setup the configutation files in | ||
517 | home directory | ||
518 | */ | ||
519 | void Fluxbox::setupConfigFiles() { | ||
520 | |||
521 | string dirname = getDefaultDataFilename(""); | ||
522 | |||
523 | // is file/dir already there? | ||
524 | const bool create_dir = FbTk::FileUtil::isDirectory(dirname.c_str()); | ||
525 | |||
526 | struct CFInfo { | ||
527 | bool create_file; | ||
528 | const char* default_name; | ||
529 | const std::string filename; | ||
530 | } cfiles[] = { | ||
531 | { create_dir, DEFAULT_INITFILE, getDefaultDataFilename(m_RC_INIT_FILE) }, | ||
532 | { create_dir, DEFAULTKEYSFILE, getDefaultDataFilename("keys") }, | ||
533 | { create_dir, DEFAULTMENU, getDefaultDataFilename("menu") }, | ||
534 | { create_dir, DEFAULT_APPSFILE, getDefaultDataFilename("apps") }, | ||
535 | { create_dir, DEFAULT_OVERLAY, getDefaultDataFilename("overlay") }, | ||
536 | { create_dir, DEFAULT_WINDOWMENU, getDefaultDataFilename("windowmenu") } | ||
537 | }; | ||
538 | const size_t nr_of_cfiles = sizeof(cfiles)/sizeof(CFInfo); | ||
539 | |||
540 | if (create_dir) { // check if anything with those name exists, if not create new | ||
541 | for (size_t i = 0; i < nr_of_cfiles; ++i) { | ||
542 | cfiles[i].create_file = access(cfiles[i].filename.c_str(), F_OK); | ||
543 | } | ||
544 | } else{ | ||
545 | fbdbg<<"Creating dir: " << dirname.c_str() << endl; | ||
546 | _FB_USES_NLS; | ||
547 | // create directory with perm 700 | ||
548 | if (mkdir(dirname.c_str(), 0700)) { | ||
549 | fprintf(stderr, _FB_CONSOLETEXT(Fluxbox, ErrorCreatingDirectory, | ||
550 | "Can't create %s directory", | ||
551 | "Can't create a directory, one %s for directory name").c_str(), | ||
552 | dirname.c_str()); | ||
553 | cerr<<endl; | ||
554 | return; | ||
555 | } | ||
556 | } | ||
557 | |||
558 | // copy default files if needed | ||
559 | for (size_t i = 0; i < nr_of_cfiles; ++i) { | ||
560 | if (cfiles[i].create_file) { | ||
561 | FbTk::FileUtil::copyFile(cfiles[i].default_name, cfiles[i].filename.c_str()); | ||
562 | } | ||
563 | } | ||
564 | |||
565 | #define CONFIG_VERSION 13 | ||
566 | FbTk::Resource<int> config_version(m_resourcemanager, 0, | ||
567 | "session.configVersion", "Session.ConfigVersion"); | ||
568 | if (*config_version < CONFIG_VERSION) { | ||
569 | // configs are out of date, so run fluxbox-update_configs | ||
570 | |||
571 | string commandargs = realProgramName("fluxbox-update_configs"); | ||
572 | commandargs += " -rc " + cfiles[0].filename; | ||
573 | |||
574 | #ifdef HAVE_GETPID | ||
575 | // add the fluxbox pid so fbuc can have us reload rc if necessary | ||
576 | commandargs += " -pid "; | ||
577 | commandargs += FbTk::StringUtil::number2String(getpid()); | ||
578 | #endif // HAVE_GETPID | ||
579 | |||
580 | FbCommands::ExecuteCmd fbuc(commandargs, 0); | ||
581 | fbuc.execute(); | ||
582 | } | ||
583 | } | ||
584 | |||
585 | void Fluxbox::handleEvent(XEvent * const e) { | 515 | void Fluxbox::handleEvent(XEvent * const e) { |
586 | _FB_USES_NLS; | 516 | _FB_USES_NLS; |
587 | m_last_event = *e; | 517 | m_last_event = *e; |
@@ -1216,7 +1146,7 @@ string Fluxbox::getRcFilename() { | |||
1216 | 1146 | ||
1217 | /// Provides default filename of data file | 1147 | /// Provides default filename of data file |
1218 | string Fluxbox::getDefaultDataFilename(const char *name) const { | 1148 | string Fluxbox::getDefaultDataFilename(const char *name) const { |
1219 | return (getenv("HOME") + string("/.") + m_RC_PATH + string("/") + name); | 1149 | return m_RC_PATH + string("/") + name; |
1220 | } | 1150 | } |
1221 | 1151 | ||
1222 | /// loads resources | 1152 | /// loads resources |
@@ -1311,7 +1241,6 @@ void Fluxbox::load_rc(BScreen &screen) { | |||
1311 | } | 1241 | } |
1312 | 1242 | ||
1313 | void Fluxbox::reconfigure() { | 1243 | void Fluxbox::reconfigure() { |
1314 | setupConfigFiles(); | ||
1315 | load_rc(); | 1244 | load_rc(); |
1316 | m_reconfigure_wait = true; | 1245 | m_reconfigure_wait = true; |
1317 | m_reconfig_timer.start(); | 1246 | m_reconfig_timer.start(); |