aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fluxbox.cc121
1 files changed, 113 insertions, 8 deletions
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index 5690b6e..fbeb860 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.35 2002/02/20 23:12:07 fluxgen Exp $ 25// $Id: fluxbox.cc,v 1.36 2002/02/26 22:42:23 fluxgen Exp $
26 26
27//Use some GNU extensions 27//Use some GNU extensions
28#ifndef _GNU_SOURCE 28#ifndef _GNU_SOURCE
@@ -315,7 +315,9 @@ key(0)
315 singleton = this; 315 singleton = this;
316 BaseDisplay::GrabGuard gg(*this); 316 BaseDisplay::GrabGuard gg(*this);
317 gg.grab(); 317 gg.grab();
318 318
319 setupConfigFiles();
320
319 if (! XSupportsLocale()) 321 if (! XSupportsLocale())
320 fprintf(stderr, "X server does not support locale\n"); 322 fprintf(stderr, "X server does not support locale\n");
321 323
@@ -331,7 +333,7 @@ key(0)
331 windowSearchList = new LinkedList<WindowSearch>; 333 windowSearchList = new LinkedList<WindowSearch>;
332 menuSearchList = new LinkedList<MenuSearch>; 334 menuSearchList = new LinkedList<MenuSearch>;
333 335
334#ifdef SLIT 336 #ifdef SLIT
335 slitSearchList = new LinkedList<SlitSearch>; 337 slitSearchList = new LinkedList<SlitSearch>;
336 #ifdef KDE 338 #ifdef KDE
337 //For KDE dock applets 339 //For KDE dock applets
@@ -339,7 +341,7 @@ key(0)
339 kwm2_dockwindow = XInternAtom(getXDisplay(), "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR", False); //KDE v2.x 341 kwm2_dockwindow = XInternAtom(getXDisplay(), "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR", False); //KDE v2.x
340 #endif //KDE 342 #endif //KDE
341 343
342#endif // SLIT 344 #endif // SLIT
343 345
344 toolbarSearchList = new LinkedList<ToolbarSearch>; 346 toolbarSearchList = new LinkedList<ToolbarSearch>;
345 tabSearchList = new LinkedList<TabSearch>; 347 tabSearchList = new LinkedList<TabSearch>;
@@ -434,6 +436,109 @@ Fluxbox::~Fluxbox(void) {
434#endif // SLIT 436#endif // SLIT
435} 437}
436 438
439//---------- setupConfigFiles -----------
440// setup the configutation files in
441// home directory
442//---------------------------------------
443void Fluxbox::setupConfigFiles() {
444
445 bool createInit, createKeys, createMenu;
446 createInit = createKeys = createMenu = false;
447
448 string dirname = getenv("HOME")+string("/.")+string(RC_PATH) + "/";
449 string initFile, keysFile, menuFile;
450 initFile = dirname+RC_INIT_FILE;
451 keysFile = dirname+"keys";
452 menuFile = dirname+"menu";
453
454 struct stat buf;
455
456 // is file/dir already there?
457 if (! stat(dirname.c_str(), &buf)) {
458 /*TODO: this
459 if (! (buf.st_mode & S_IFDIR)) {
460 cerr << dirname.c_str() << "!" << endl;
461 return 1;
462 }
463 */
464
465 // check if anything with those name exists, if not create new
466 if (stat(initFile.c_str(), &buf))
467 createInit = true;
468 if (stat(keysFile.c_str(), &buf))
469 createKeys = true;
470 if (stat(menuFile.c_str(), &buf))
471 createMenu = true;
472
473 } else {
474 #ifdef DEBUG
475 cerr <<__FILE__<<"("<<__LINE__<<"): Creating dir: " << dirname.c_str() << endl;
476 #endif // DEBUG
477
478 // create directory with perm 700
479 if (mkdir(dirname.c_str(), 0700)) {
480 cerr << "Can't create " << dirname << " directory!" << endl;
481 return;
482 }
483
484 //mark creation of files
485 createInit = createKeys = createMenu = true;
486 }
487
488
489 // should we copy key configuraion?
490 if (createKeys) {
491 ifstream from(DEFAULTKEYSFILE);
492 ofstream to(keysFile.c_str());
493
494 if (! to.good()) {
495 cerr << "Can't write file" << endl;
496 } else if (from.good()) {
497 #ifdef DEBUG
498 cerr << "Copying file: " << DEFAULTKEYSFILE << endl;
499 #endif // DEBUG
500 to<<from.rdbuf(); //copy file
501
502 } else {
503 cerr<<"Can't copy default keys file."<<endl;
504 }
505 }
506
507 // should we copy menu configuraion?
508 if (createMenu) {
509 ifstream from(DEFAULTMENU);
510 ofstream to(menuFile.c_str());
511
512 if (! to.good()) {
513 cerr << "Can't open " << menuFile.c_str() << "for writing" << endl;
514 } else if (from.good()) {
515 #ifdef DEBUG
516 cerr << "Copying file: " << DEFAULTMENU << endl;
517 #endif // DEBUG
518 to<<from.rdbuf(); //copy file
519
520 } else {
521 cerr<<"Can't copy default menu file."<<endl;
522 }
523 }
524
525 // should we copy default init file?
526 if (createInit) {
527 ifstream from(DEFAULT_INITFILE);
528 ofstream to(initFile.c_str());
529
530 if (! to.good()) {
531 cerr << "Can't open " << initFile.c_str() << "for writing" << endl;
532 } else if (from.good()) {
533 #ifdef DEBUG
534 cerr << "Copying file: " << DEFAULT_INITFILE << endl;
535 #endif // DEBUG
536 to<<from.rdbuf(); //copy file
537 } else {
538 cerr<<"Can't copy default init file."<<endl;
539 }
540 }
541}
437 542
438void Fluxbox::process_event(XEvent *e) { 543void Fluxbox::process_event(XEvent *e) {
439 544
@@ -935,10 +1040,6 @@ void Fluxbox::handleUnmapNotify(XUnmapEvent &ue) {
935 1040
936 1041
937 FluxboxWindow *win = 0; 1042 FluxboxWindow *win = 0;
938 #ifdef DEBUG
939 cerr<<__FILE__<<"("<<__LINE__<<"): Unmapnotify 0x"<<hex<<
940 ue.window<<dec<<endl;
941 #endif
942 1043
943 #ifdef SLIT 1044 #ifdef SLIT
944 Slit *slit = (Slit *) 0; 1045 Slit *slit = (Slit *) 0;
@@ -1063,6 +1164,10 @@ void Fluxbox::handleKeyEvent(XKeyEvent &ke) {
1063 // Workspace1 has id 0, hence -1 1164 // Workspace1 has id 0, hence -1
1064 screen->changeWorkspaceID(key->getParam()-1); 1165 screen->changeWorkspaceID(key->getParam()-1);
1065 break; 1166 break;
1167 case Keys::SENDTOWORKSPACE:
1168 // Workspace1 has id 0, hence -1
1169 screen->sendToWorkspace(key->getParam()-1);
1170 break;
1066 // NOTE!!! The WORKSPACEn commands are not needed anymore 1171 // NOTE!!! The WORKSPACEn commands are not needed anymore
1067 case Keys::WORKSPACE1: 1172 case Keys::WORKSPACE1:
1068 screen->changeWorkspaceID(0); 1173 screen->changeWorkspaceID(0);