restart works
This commit is contained in:
parent
a9a5f0d751
commit
06388d73b7
8 changed files with 98 additions and 18 deletions
|
@ -12800,7 +12800,7 @@ static PyObject *_wrap_basename(PyObject *self, PyObject *args) {
|
||||||
SWIG_exception(SWIG_TypeError, "string expected");
|
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());
|
resultobj = PyString_FromString((&result)->c_str());
|
||||||
|
|
|
@ -101,14 +101,12 @@ string itostring(long i) {
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef HAVE_BASENAME
|
|
||||||
string basename (const string& path) {
|
string basename (const string& path) {
|
||||||
string::size_type slash = path.rfind('/');
|
string::size_type slash = path.rfind('/');
|
||||||
if (slash == string::npos)
|
if (slash == string::npos)
|
||||||
return path;
|
return path;
|
||||||
return path.substr(slash+1);
|
return path.substr(slash+1);
|
||||||
}
|
}
|
||||||
#endif // HAVE_BASENAME
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,10 +40,9 @@ inline std::string itostring(unsigned int i)
|
||||||
inline std::string itostring(int i)
|
inline std::string itostring(int i)
|
||||||
{ return itostring((long) i); }
|
{ return itostring((long) i); }
|
||||||
|
|
||||||
|
|
||||||
|
std::string basename(const std::string& path);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HAVE_BASENAME
|
|
||||||
std::string basename(const std::string& path);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -61,6 +61,9 @@ def resize(data):
|
||||||
def execute(bin, screen = 0):
|
def execute(bin, screen = 0):
|
||||||
Openbox_execute(openbox, screen, bin)
|
Openbox_execute(openbox, screen, bin)
|
||||||
|
|
||||||
|
def restart(data):
|
||||||
|
Openbox_restart(openbox, "")
|
||||||
|
|
||||||
def toggle_shade(data):
|
def toggle_shade(data):
|
||||||
print "toggle_shade"
|
print "toggle_shade"
|
||||||
|
|
||||||
|
|
|
@ -88,8 +88,9 @@ Openbox::Openbox(int argc, char **argv)
|
||||||
Openbox::instance = this;
|
Openbox::instance = this;
|
||||||
|
|
||||||
_displayreq = (char*) 0;
|
_displayreq = (char*) 0;
|
||||||
_argv0 = argv[0];
|
_argv = argv;
|
||||||
_doshutdown = false;
|
_shutdown = false;
|
||||||
|
_restart = false;
|
||||||
_rcfilepath = otk::expandTilde("~/.openbox/rc3");
|
_rcfilepath = otk::expandTilde("~/.openbox/rc3");
|
||||||
_scriptfilepath = otk::expandTilde("~/.openbox/user.py");
|
_scriptfilepath = otk::expandTilde("~/.openbox/user.py");
|
||||||
_focused_client = 0;
|
_focused_client = 0;
|
||||||
|
@ -172,6 +173,8 @@ Openbox::~Openbox()
|
||||||
{
|
{
|
||||||
_state = State_Exiting; // time to kill everything
|
_state = State_Exiting; // time to kill everything
|
||||||
|
|
||||||
|
int first_screen = _screens.front()->number();
|
||||||
|
|
||||||
std::for_each(_screens.begin(), _screens.end(), otk::PointerAssassin());
|
std::for_each(_screens.begin(), _screens.end(), otk::PointerAssassin());
|
||||||
|
|
||||||
delete _bindings;
|
delete _bindings;
|
||||||
|
@ -188,6 +191,20 @@ Openbox::~Openbox()
|
||||||
// the shutdown process unblocks it. blackbox simply did a ::exit(0), so
|
// the shutdown process unblocks it. blackbox simply did a ::exit(0), so
|
||||||
// all im gunna do is the same.
|
// all im gunna do is the same.
|
||||||
//otk::OBDisplay::destroy();
|
//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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -256,7 +273,7 @@ void Openbox::showHelp()
|
||||||
-menu <string> use alternate menu file.\n\
|
-menu <string> use alternate menu file.\n\
|
||||||
-script <string> use alternate startup script file.\n\
|
-script <string> use alternate startup script file.\n\
|
||||||
-version display version and exit.\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\
|
printf(_("Compile time options:\n\
|
||||||
Debugging: %s\n\
|
Debugging: %s\n\
|
||||||
|
@ -285,10 +302,10 @@ void Openbox::showHelp()
|
||||||
|
|
||||||
void Openbox::eventLoop()
|
void Openbox::eventLoop()
|
||||||
{
|
{
|
||||||
while (!_doshutdown) {
|
while (!_shutdown) {
|
||||||
|
_timermanager.fire();
|
||||||
dispatchEvents(); // from OtkEventDispatcher
|
dispatchEvents(); // from OtkEventDispatcher
|
||||||
XFlush(otk::OBDisplay::display); // flush here before we go wait for timers
|
XFlush(otk::OBDisplay::display); // flush here before we go wait for timers
|
||||||
_timermanager.fire();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,8 +91,8 @@ private:
|
||||||
std::string _scriptfilepath;
|
std::string _scriptfilepath;
|
||||||
//! The display requested by the user, or null to use the DISPLAY env var
|
//! The display requested by the user, or null to use the DISPLAY env var
|
||||||
char *_displayreq;
|
char *_displayreq;
|
||||||
//! The value of argv[0], i.e. how this application was executed
|
//! The value of argv, i.e. how this application was executed
|
||||||
char *_argv0;
|
char **_argv;
|
||||||
|
|
||||||
//! A list of all managed clients
|
//! A list of all managed clients
|
||||||
ClientMap _clients;
|
ClientMap _clients;
|
||||||
|
@ -131,7 +131,15 @@ private:
|
||||||
Cursors _cursors;
|
Cursors _cursors;
|
||||||
|
|
||||||
//! When set to true, the Openbox::eventLoop function will stop and return
|
//! 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
|
//! The client with input focus
|
||||||
/*!
|
/*!
|
||||||
|
@ -239,7 +247,11 @@ public:
|
||||||
Causes the Openbox::eventLoop function to stop looping, so that the window
|
Causes the Openbox::eventLoop function to stop looping, so that the window
|
||||||
manager can be destroyed.
|
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
|
//! Executes a command on a screen
|
||||||
void execute(int screen, const std::string &bin);
|
void execute(int screen, const std::string &bin);
|
||||||
|
|
|
@ -1309,6 +1309,36 @@ static PyObject *_wrap_Openbox_shutdown(PyObject *self, PyObject *args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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) {
|
static PyObject *_wrap_Openbox_execute(PyObject *self, PyObject *args) {
|
||||||
PyObject *resultobj;
|
PyObject *resultobj;
|
||||||
ob::Openbox *arg1 = (ob::Openbox *) 0 ;
|
ob::Openbox *arg1 = (ob::Openbox *) 0 ;
|
||||||
|
@ -1379,6 +1409,23 @@ static PyObject *_wrap_OBScreen_clientCount(PyObject *self, PyObject *args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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) {
|
static PyObject *_wrap_OBScreen_managed(PyObject *self, PyObject *args) {
|
||||||
PyObject *resultobj;
|
PyObject *resultobj;
|
||||||
ob::OBScreen *arg1 = (ob::OBScreen *) 0 ;
|
ob::OBScreen *arg1 = (ob::OBScreen *) 0 ;
|
||||||
|
@ -2626,10 +2673,12 @@ static PyMethodDef SwigMethods[] = {
|
||||||
{ (char *)"Openbox_setFocusedClient", _wrap_Openbox_setFocusedClient, METH_VARARGS },
|
{ (char *)"Openbox_setFocusedClient", _wrap_Openbox_setFocusedClient, METH_VARARGS },
|
||||||
{ (char *)"Openbox_focusedScreen", _wrap_Openbox_focusedScreen, METH_VARARGS },
|
{ (char *)"Openbox_focusedScreen", _wrap_Openbox_focusedScreen, METH_VARARGS },
|
||||||
{ (char *)"Openbox_shutdown", _wrap_Openbox_shutdown, 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_execute", _wrap_Openbox_execute, METH_VARARGS },
|
||||||
{ (char *)"Openbox_swigregister", Openbox_swigregister, METH_VARARGS },
|
{ (char *)"Openbox_swigregister", Openbox_swigregister, METH_VARARGS },
|
||||||
{ (char *)"OBScreen_client", _wrap_OBScreen_client, METH_VARARGS },
|
{ (char *)"OBScreen_client", _wrap_OBScreen_client, METH_VARARGS },
|
||||||
{ (char *)"OBScreen_clientCount", _wrap_OBScreen_clientCount, 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_managed", _wrap_OBScreen_managed, METH_VARARGS },
|
||||||
{ (char *)"OBScreen_imageControl", _wrap_OBScreen_imageControl, METH_VARARGS },
|
{ (char *)"OBScreen_imageControl", _wrap_OBScreen_imageControl, METH_VARARGS },
|
||||||
{ (char *)"OBScreen_area", _wrap_OBScreen_area, METH_VARARGS },
|
{ (char *)"OBScreen_area", _wrap_OBScreen_area, METH_VARARGS },
|
||||||
|
|
|
@ -119,6 +119,8 @@ public:
|
||||||
virtual ~OBScreen();
|
virtual ~OBScreen();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
inline int number() const { return _number; }
|
||||||
|
|
||||||
//! Returns if the screen was successfully managed
|
//! Returns if the screen was successfully managed
|
||||||
/*!
|
/*!
|
||||||
If this is false, then the screen should be deleted and should NOT be
|
If this is false, then the screen should be deleted and should NOT be
|
||||||
|
|
Loading…
Reference in a new issue