]> Dogcows Code - chaz/openbox/blobdiff - src/openbox.cc
new autoconf shit woowoo
[chaz/openbox] / src / openbox.cc
index e9d1250088d65aa1e71068a1a15f7a4060b8f051..42cc1fefe96a3017c2a93a73bc0a40ab6ec67eec 100644 (file)
@@ -4,7 +4,6 @@
 # include "../config.h"
 #endif
 
-#include "../version.h"
 #include "openbox.hh"
 #include "client.hh"
 #include "screen.hh"
@@ -58,19 +57,19 @@ Openbox *Openbox::instance  = (Openbox *) 0;
 void Openbox::signalHandler(int signal)
 {
   switch (signal) {
-  case SIGHUP:
-    // XXX: Do something with HUP? Really shouldn't, we get this when X shuts
-    //      down and hangs-up on us. we also get a SIGPIPE.
-    printf("Caught HUP signal. Restarting.\n");
+  case SIGUSR1:
+    printf("Caught SIGUSR1 signal. Restarting.\n");
     instance->restart();
     break;
-    
+
+  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);
@@ -110,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);
@@ -138,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"));
@@ -239,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);
@@ -258,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");
 }
 
@@ -271,16 +277,19 @@ void Openbox::showHelp()
   printf(_("Usage: %s [OPTIONS...]\n\
   Options:\n\
   -display <string>  use display connection.\n\
+  -single            run on a single screen (default is to run every one).\n\
   -rc <string>       use alternate resource file.\n\
   -menu <string>     use alternate menu file.\n\
   -script <string>   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
@@ -294,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
     );
 }
 
@@ -305,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
   }
@@ -358,6 +373,10 @@ 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)
This page took 0.027775 seconds and 4 git commands to generate.