+Openbox::Openbox(int argc, char **argv)
+ : otk::EventDispatcher(),
+ otk::EventHandler(),
+ _display()
+{
+ struct sigaction action;
+
+ _state = State_Starting; // initializing everything
+
+ openbox = this;
+
+ _displayreq = (char*) 0;
+ _argv = argv;
+ _shutdown = false;
+ _restart = false;
+ _rcfilepath = otk::expandTilde("~/.openbox/rc3");
+ _scriptfilepath = otk::expandTilde("~/.openbox/user.py");
+ _focused_client = 0;
+ _sync = false;
+ _single = false;
+
+ parseCommandLine(argc, argv);
+
+ XSynchronize(**otk::display, _sync);
+
+ // set up the signal handler
+ 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);
+ sigaction(SIGTERM, &action, (struct sigaction *) 0);
+ sigaction(SIGINT, &action, (struct sigaction *) 0);
+ sigaction(SIGHUP, &action, (struct sigaction *) 0);
+ sigaction(SIGCHLD, &action, (struct sigaction *) 0);
+
+ // anything that died while we were restarting won't give us a SIGCHLD
+ while (waitpid(-1, NULL, WNOHANG) > 0);
+
+ otk::RenderColor::initialize();
+ otk::RenderStyle::initialize();
+ otk::Timer::initialize();
+ otk::Property::initialize();
+ _actions = new Actions();
+ _bindings = new Bindings();
+
+ setMasterHandler(_actions); // set as the master event handler
+
+ // create the mouse cursors we'll use
+ _cursors.session = XCreateFontCursor(**otk::display, XC_left_ptr);
+ _cursors.move = XCreateFontCursor(**otk::display, XC_fleur);
+ _cursors.ll_angle = XCreateFontCursor(**otk::display, XC_ll_angle);
+ _cursors.lr_angle = XCreateFontCursor(**otk::display, XC_lr_angle);
+ _cursors.ul_angle = XCreateFontCursor(**otk::display, XC_ul_angle);
+ _cursors.ur_angle = XCreateFontCursor(**otk::display, XC_ur_angle);
+
+ // initialize scripting
+ python_init(argv[0]);
+
+ // load config values
+ //python_exec(SCRIPTDIR"/config.py"); // load openbox config values
+ // run all of the python scripts
+ //python_exec(SCRIPTDIR"/builtins.py"); // builtin callbacks
+ //python_exec(SCRIPTDIR"/focus.py"); // focus helpers
+ // 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
+ _focused_screen = 0;
+
+ for (int i = 0, max = ScreenCount(**otk::display); i < max; ++i) {
+ Screen *screen;
+ // in single mode skip the screens we don't want to manage
+ if (_single && i != DefaultScreen(**otk::display)) {
+ _screens.push_back(0);
+ continue;