SWIG_exception(SWIG_TypeError, "string expected");
}
}
- result = basename((std::string const &)*arg1);
+ result = otk::basename((std::string const &)*arg1);
{
resultobj = PyString_FromString((&result)->c_str());
return tmp;
}
-}
-
-#ifndef HAVE_BASENAME
string basename (const string& path) {
string::size_type slash = path.rfind('/');
if (slash == string::npos)
return path;
return path.substr(slash+1);
}
-#endif // HAVE_BASENAME
+
+}
inline std::string itostring(int i)
{ return itostring((long) i); }
-}
-#ifndef HAVE_BASENAME
std::string basename(const std::string& path);
-#endif
+
+}
#endif
def execute(bin, screen = 0):
Openbox_execute(openbox, screen, bin)
+def restart(data):
+ Openbox_restart(openbox, "")
+
def toggle_shade(data):
print "toggle_shade"
Openbox::instance = this;
_displayreq = (char*) 0;
- _argv0 = argv[0];
- _doshutdown = false;
+ _argv = argv;
+ _shutdown = false;
+ _restart = false;
_rcfilepath = otk::expandTilde("~/.openbox/rc3");
_scriptfilepath = otk::expandTilde("~/.openbox/user.py");
_focused_client = 0;
{
_state = State_Exiting; // time to kill everything
+ int first_screen = _screens.front()->number();
+
std::for_each(_screens.begin(), _screens.end(), otk::PointerAssassin());
delete _bindings;
// the shutdown process unblocks it. blackbox simply did a ::exit(0), so
// all im gunna do is the same.
//otk::OBDisplay::destroy();
+
+ if (_restart) {
+ if (!_restart_prog.empty()) {
+ const std::string &dstr =
+ otk::OBDisplay::screenInfo(first_screen)->displayString();
+ putenv(const_cast<char *>(dstr.c_str()));
+ execlp(_restart_prog.c_str(), _restart_prog.c_str(), NULL);
+ perror(_restart_prog.c_str());
+ }
+
+ // fall back in case the above execlp doesn't work
+ execvp(_argv[0], _argv);
+ execvp(otk::basename(_argv[0]).c_str(), _argv);
+ }
}
-menu <string> use alternate menu file.\n\
-script <string> use alternate startup script file.\n\
-version display version and exit.\n\
- -help display this help text and exit.\n\n"), _argv0);
+ -help display this help text and exit.\n\n"), _argv[0]);
printf(_("Compile time options:\n\
Debugging: %s\n\
void Openbox::eventLoop()
{
- while (!_doshutdown) {
+ while (!_shutdown) {
+ _timermanager.fire();
dispatchEvents(); // from OtkEventDispatcher
XFlush(otk::OBDisplay::display); // flush here before we go wait for timers
- _timermanager.fire();
}
}
std::string _scriptfilepath;
//! The display requested by the user, or null to use the DISPLAY env var
char *_displayreq;
- //! The value of argv[0], i.e. how this application was executed
- char *_argv0;
+ //! The value of argv, i.e. how this application was executed
+ char **_argv;
//! A list of all managed clients
ClientMap _clients;
Cursors _cursors;
//! When set to true, the Openbox::eventLoop function will stop and return
- bool _doshutdown;
+ bool _shutdown;
+
+ //! When set to true, and Openbox is about to exit, it will spawn a new
+ //! process
+ bool _restart;
+
+ //! If this contains anything, a restart will try to execute the program in
+ //! this variable, and will fallback to reexec'ing itself if that fails
+ std::string _restart_prog;
//! The client with input focus
/*!
Causes the Openbox::eventLoop function to stop looping, so that the window
manager can be destroyed.
*/
- inline void shutdown() { _doshutdown = true; }
+ inline void shutdown() { _shutdown = true; }
+
+ inline void restart(const std::string &bin = "") {
+ _shutdown = true; _restart = true; _restart_prog = bin;
+ }
//! Executes a command on a screen
void execute(int screen, const std::string &bin);
}
+static PyObject *_wrap_Openbox_restart(PyObject *self, PyObject *args) {
+ PyObject *resultobj;
+ ob::Openbox *arg1 = (ob::Openbox *) 0 ;
+ std::string const &arg2_defvalue = "" ;
+ std::string *arg2 = (std::string *) &arg2_defvalue ;
+ std::string temp2 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if(!PyArg_ParseTuple(args,(char *)"O|O:Openbox_restart",&obj0,&obj1)) goto fail;
+ if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_ob__Openbox,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
+ if (obj1) {
+ {
+ if (PyString_Check(obj1)) {
+ temp2 = std::string(PyString_AsString(obj1));
+ arg2 = &temp2;
+ }else {
+ SWIG_exception(SWIG_TypeError, "string expected");
+ }
+ }
+ }
+ (arg1)->restart((std::string const &)*arg2);
+
+ Py_INCREF(Py_None); resultobj = Py_None;
+ return resultobj;
+ fail:
+ return NULL;
+}
+
+
static PyObject *_wrap_Openbox_execute(PyObject *self, PyObject *args) {
PyObject *resultobj;
ob::Openbox *arg1 = (ob::Openbox *) 0 ;
}
+static PyObject *_wrap_OBScreen_number(PyObject *self, PyObject *args) {
+ PyObject *resultobj;
+ ob::OBScreen *arg1 = (ob::OBScreen *) 0 ;
+ int result;
+ PyObject * obj0 = 0 ;
+
+ if(!PyArg_ParseTuple(args,(char *)"O:OBScreen_number",&obj0)) goto fail;
+ if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_ob__OBScreen,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
+ result = (int)((ob::OBScreen const *)arg1)->number();
+
+ resultobj = PyInt_FromLong((long)result);
+ return resultobj;
+ fail:
+ return NULL;
+}
+
+
static PyObject *_wrap_OBScreen_managed(PyObject *self, PyObject *args) {
PyObject *resultobj;
ob::OBScreen *arg1 = (ob::OBScreen *) 0 ;
{ (char *)"Openbox_setFocusedClient", _wrap_Openbox_setFocusedClient, METH_VARARGS },
{ (char *)"Openbox_focusedScreen", _wrap_Openbox_focusedScreen, METH_VARARGS },
{ (char *)"Openbox_shutdown", _wrap_Openbox_shutdown, METH_VARARGS },
+ { (char *)"Openbox_restart", _wrap_Openbox_restart, METH_VARARGS },
{ (char *)"Openbox_execute", _wrap_Openbox_execute, METH_VARARGS },
{ (char *)"Openbox_swigregister", Openbox_swigregister, METH_VARARGS },
{ (char *)"OBScreen_client", _wrap_OBScreen_client, METH_VARARGS },
{ (char *)"OBScreen_clientCount", _wrap_OBScreen_clientCount, METH_VARARGS },
+ { (char *)"OBScreen_number", _wrap_OBScreen_number, METH_VARARGS },
{ (char *)"OBScreen_managed", _wrap_OBScreen_managed, METH_VARARGS },
{ (char *)"OBScreen_imageControl", _wrap_OBScreen_imageControl, METH_VARARGS },
{ (char *)"OBScreen_area", _wrap_OBScreen_area, METH_VARARGS },
virtual ~OBScreen();
#endif
+ inline int number() const { return _number; }
+
//! Returns if the screen was successfully managed
/*!
If this is false, then the screen should be deleted and should NOT be