X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fopenbox.cc;h=600c9d8d90bcfdf372080c4b32d1ecd376e4c3e1;hb=8f8acc24933830d4f5784616b9b0c5896bde0b93;hp=aa7fc9f66fd4e44a5b2a8ac786ab297de5d0a8c3;hpb=180cdd0e91799458552f581327a67be745909134;p=chaz%2Fopenbox diff --git a/src/openbox.cc b/src/openbox.cc index aa7fc9f6..600c9d8d 100644 --- a/src/openbox.cc +++ b/src/openbox.cc @@ -4,7 +4,6 @@ # include "../config.h" #endif -#include "../version.h" #include "openbox.hh" #include "client.hh" #include "screen.hh" @@ -14,7 +13,7 @@ #include "otk/property.hh" #include "otk/display.hh" #include "otk/assassin.hh" -#include "otk/util.hh" // TEMPORARY +#include "otk/util.hh" extern "C" { #include @@ -63,13 +62,14 @@ void Openbox::signalHandler(int signal) instance->restart(); break; - case SUGHUP: + case SIGHUP: case SIGINT: case SIGTERM: case SIGPIPE: printf("Caught signal %d. Exiting.\n", signal); instance->shutdown(); break; + case SIGFPE: case SIGSEGV: printf("Caught signal %d. Aborting and dumping core.\n", signal); @@ -109,6 +109,7 @@ Openbox::Openbox(int argc, char **argv) action.sa_handler = Openbox::signalHandler; action.sa_mask = sigset_t(); action.sa_flags = SA_NOCLDSTOP | SA_NODEFER; + sigaction(SIGUSR1, &action, (struct sigaction *) 0); sigaction(SIGPIPE, &action, (struct sigaction *) 0); sigaction(SIGSEGV, &action, (struct sigaction *) 0); sigaction(SIGFPE, &action, (struct sigaction *) 0); @@ -137,17 +138,21 @@ Openbox::Openbox(int argc, char **argv) python_exec(SCRIPTDIR"/config.py"); // load openbox config values // run all of the python scripts python_exec(SCRIPTDIR"/builtins.py"); // builtin callbacks - // run the user's script - python_exec(_scriptfilepath.c_str()); + // run the user's script or the system defaults if that fails + if (!python_exec(_scriptfilepath.c_str())) + python_exec(SCRIPTDIR"/defaults.py"); // system default bahaviors // initialize all the screens OBScreen *screen; - screen = new OBScreen(0); - if (screen->managed()) { - _screens.push_back(screen); - // XXX: "change to" the first workspace on the screen to initialize stuff - } else - delete screen; + int i = _single ? DefaultScreen(otk::OBDisplay::display) : 0; + int max = _single ? i + 1 : ScreenCount(otk::OBDisplay::display); + for (; i < max; ++i) { + screen = new OBScreen(i); + if (screen->managed()) + _screens.push_back(screen); + else + delete screen; + } if (_screens.empty()) { printf(_("No screens were found without a window manager. Exiting.\n")); @@ -197,7 +202,7 @@ Openbox::~Openbox() if (!_restart_prog.empty()) { const std::string &dstr = otk::OBDisplay::screenInfo(first_screen)->displayString(); - putenv(const_cast(dstr.c_str())); + otk::putenv(const_cast(dstr.c_str())); execlp(_restart_prog.c_str(), _restart_prog.c_str(), NULL); perror(_restart_prog.c_str()); } @@ -238,6 +243,8 @@ void Openbox::parseCommandLine(int argc, char **argv) _scriptfilepath = argv[i]; } else if (arg == "-sync") { _sync = true; + } else if (arg == "-single") { + _single = true; } else if (arg == "-version") { showVersion(); ::exit(0); @@ -257,7 +264,7 @@ void Openbox::parseCommandLine(int argc, char **argv) void Openbox::showVersion() { - printf(_("Openbox - version %s\n"), OPENBOX_VERSION); + printf(_("Openbox - version %s\n"), VERSION); printf(" (c) 2002 - 2002 Ben Jansens\n\n"); } @@ -270,16 +277,19 @@ void Openbox::showHelp() printf(_("Usage: %s [OPTIONS...]\n\ Options:\n\ -display use display connection.\n\ + -single run on a single screen (default is to run every one).\n\ -rc use alternate resource file.\n\ -menu use alternate menu file.\n\ -script use alternate startup script file.\n\ + -sync run in synchronous mode (for debugging).\n\ -version display version and exit.\n\ -help display this help text and exit.\n\n"), _argv[0]); printf(_("Compile time options:\n\ Debugging: %s\n\ Shape: %s\n\ - Xinerama: %s\n"), + Xinerama: %s\n\ + Xkb: %s\n"), #ifdef DEBUG _("yes"), #else // !DEBUG @@ -293,10 +303,16 @@ void Openbox::showHelp() #endif // SHAPE #ifdef XINERAMA - _("yes") + _("yes"), #else // !XINERAMA - _("no") + _("no"), #endif // XINERAMA + +#ifdef XKB + _("yes") +#else // !XKB + _("no") +#endif // XKB ); } @@ -304,7 +320,7 @@ void Openbox::showHelp() void Openbox::eventLoop() { while (!_shutdown) { - _timermanager.fire(); + _timermanager.fire(!_sync); // wait if not in sync mode dispatchEvents(); // from OtkEventDispatcher XFlush(otk::OBDisplay::display); // flush here before we go wait for timers } @@ -357,27 +373,17 @@ void Openbox::setFocusedClient(OBClient *c) otk::OBProperty::Atom_Window, (c && _focused_screen == *it) ? c->window() : None); } + + // call the python Focus callbacks + EventData data(_focused_screen->number(), c, EventFocus, 0); + Openbox::instance->bindings()->fireEvent(&data); } void Openbox::execute(int screen, const std::string &bin) { -#ifdef __EMX__ - // XXX: whats this for? windows? - spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", bin.c_str(), NULL); -#else // __EMX__ if (screen >= ScreenCount(otk::OBDisplay::display)) screen = 0; - const std::string &dstr = - otk::OBDisplay::screenInfo(screen)->displayString(); - - if (! fork()) { - setsid(); - int ret = putenv(const_cast(dstr.c_str())); - assert(ret != -1); - ret = execl("/bin/sh", "/bin/sh", "-c", bin.c_str(), NULL); - exit(ret); - } -#endif // __EMX__ + otk::bexec(bin, otk::OBDisplay::screenInfo(screen)->displayString()); } }