rewritten fluxbox-restart code, all destructors are called before the
new program is started. the former method didnt do that.
This commit is contained in:
parent
2760b03b2e
commit
496d73d899
3 changed files with 55 additions and 31 deletions
|
@ -22,7 +22,7 @@
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
// $Id: fluxbox.cc,v 1.258 2004/10/10 16:06:23 akir Exp $
|
// $Id: fluxbox.cc,v 1.259 2004/10/18 01:26:54 akir Exp $
|
||||||
|
|
||||||
#include "fluxbox.hh"
|
#include "fluxbox.hh"
|
||||||
|
|
||||||
|
@ -238,6 +238,7 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile
|
||||||
m_rc_file(rcfilename ? rcfilename : ""),
|
m_rc_file(rcfilename ? rcfilename : ""),
|
||||||
m_argv(argv), m_argc(argc),
|
m_argv(argv), m_argc(argc),
|
||||||
m_starting(true),
|
m_starting(true),
|
||||||
|
m_restarting(false),
|
||||||
m_shutdown(false),
|
m_shutdown(false),
|
||||||
m_server_grabs(0),
|
m_server_grabs(0),
|
||||||
m_randr_event_type(0),
|
m_randr_event_type(0),
|
||||||
|
@ -457,6 +458,7 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile
|
||||||
|
|
||||||
|
|
||||||
Fluxbox::~Fluxbox() {
|
Fluxbox::~Fluxbox() {
|
||||||
|
|
||||||
// destroy toolbars
|
// destroy toolbars
|
||||||
while (!m_toolbars.empty()) {
|
while (!m_toolbars.empty()) {
|
||||||
delete m_toolbars.back();
|
delete m_toolbars.back();
|
||||||
|
@ -1357,14 +1359,11 @@ void Fluxbox::removeGroupSearch(Window window) {
|
||||||
void Fluxbox::restart(const char *prog) {
|
void Fluxbox::restart(const char *prog) {
|
||||||
shutdown();
|
shutdown();
|
||||||
|
|
||||||
if (prog) {
|
m_restarting = true;
|
||||||
execlp(prog, prog, 0);
|
|
||||||
perror(prog);
|
|
||||||
}
|
|
||||||
|
|
||||||
// fall back in case the above execlp doesn't work
|
if (prog) {
|
||||||
execvp(m_argv[0], m_argv);
|
m_restart_argument = prog;
|
||||||
execvp(StringUtil::basename(m_argv[0]).c_str(), m_argv);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// prepares fluxbox for a shutdown
|
/// prepares fluxbox for a shutdown
|
||||||
|
@ -1377,7 +1376,8 @@ void Fluxbox::shutdown() {
|
||||||
XSetInputFocus(FbTk::App::instance()->display(), PointerRoot, None, CurrentTime);
|
XSetInputFocus(FbTk::App::instance()->display(), PointerRoot, None, CurrentTime);
|
||||||
|
|
||||||
//send shutdown to all screens
|
//send shutdown to all screens
|
||||||
for_each(m_screen_list.begin(), m_screen_list.end(), mem_fun(&BScreen::shutdown));
|
for_each(m_screen_list.begin(),
|
||||||
|
m_screen_list.end(), mem_fun(&BScreen::shutdown));
|
||||||
|
|
||||||
sync(false);
|
sync(false);
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
// $Id: fluxbox.hh,v 1.92 2004/10/10 16:06:24 akir Exp $
|
// $Id: fluxbox.hh,v 1.93 2004/10/18 01:26:54 akir Exp $
|
||||||
|
|
||||||
#ifndef FLUXBOX_HH
|
#ifndef FLUXBOX_HH
|
||||||
#define FLUXBOX_HH
|
#define FLUXBOX_HH
|
||||||
|
@ -83,7 +83,7 @@ public:
|
||||||
Fluxbox(int argc, char **argv, const char * dpy_name= 0,
|
Fluxbox(int argc, char **argv, const char * dpy_name= 0,
|
||||||
const char *rcfilename = 0);
|
const char *rcfilename = 0);
|
||||||
virtual ~Fluxbox();
|
virtual ~Fluxbox();
|
||||||
|
|
||||||
static Fluxbox *instance() { return s_singleton; }
|
static Fluxbox *instance() { return s_singleton; }
|
||||||
/// main event loop
|
/// main event loop
|
||||||
void eventLoop();
|
void eventLoop();
|
||||||
|
@ -98,7 +98,7 @@ public:
|
||||||
WinClient *searchWindow(Window);
|
WinClient *searchWindow(Window);
|
||||||
inline WinClient *getFocusedWindow() { return m_focused_window; }
|
inline WinClient *getFocusedWindow() { return m_focused_window; }
|
||||||
|
|
||||||
|
|
||||||
BScreen *searchScreen(Window w);
|
BScreen *searchScreen(Window w);
|
||||||
|
|
||||||
inline unsigned int getDoubleClickInterval() const { return *m_rc_double_click_interval; }
|
inline unsigned int getDoubleClickInterval() const { return *m_rc_double_click_interval; }
|
||||||
|
@ -138,7 +138,7 @@ public:
|
||||||
inline int getNum() const { return m_num; }
|
inline int getNum() const { return m_num; }
|
||||||
|
|
||||||
Layer &operator=(int num) { m_num = num; return *this; }
|
Layer &operator=(int num) { m_num = num; return *this; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_num;
|
int m_num;
|
||||||
};
|
};
|
||||||
|
@ -193,17 +193,20 @@ public:
|
||||||
void checkMenu();
|
void checkMenu();
|
||||||
|
|
||||||
void hideExtraMenus(BScreen &screen);
|
void hideExtraMenus(BScreen &screen);
|
||||||
|
|
||||||
/// handle any system signal sent to the application
|
/// handle any system signal sent to the application
|
||||||
void handleSignal(int signum);
|
void handleSignal(int signum);
|
||||||
void update(FbTk::Subject *changed);
|
void update(FbTk::Subject *changed);
|
||||||
|
|
||||||
void attachSignals(FluxboxWindow &win);
|
void attachSignals(FluxboxWindow &win);
|
||||||
void attachSignals(WinClient &winclient);
|
void attachSignals(WinClient &winclient);
|
||||||
|
|
||||||
void timed_reconfigure();
|
void timed_reconfigure();
|
||||||
|
|
||||||
bool isStartup() const { return m_starting; }
|
bool isStartup() const { return m_starting; }
|
||||||
|
bool isRestarting() const { return m_restarting; }
|
||||||
|
|
||||||
|
const std::string &getRestartArgument() const { return m_restart_argument; }
|
||||||
|
|
||||||
/// get screen from number
|
/// get screen from number
|
||||||
BScreen *findScreen(int num);
|
BScreen *findScreen(int num);
|
||||||
|
@ -221,6 +224,7 @@ public:
|
||||||
// screen we are watching for modifier changes
|
// screen we are watching for modifier changes
|
||||||
BScreen *watchingScreen() { return m_watching_screen; }
|
BScreen *watchingScreen() { return m_watching_screen; }
|
||||||
const XEvent &lastEvent() const { return m_last_event; }
|
const XEvent &lastEvent() const { return m_last_event; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
typedef struct MenuTimestamp {
|
typedef struct MenuTimestamp {
|
||||||
|
@ -232,24 +236,24 @@ private:
|
||||||
|
|
||||||
std::string getRcFilename();
|
std::string getRcFilename();
|
||||||
void load_rc();
|
void load_rc();
|
||||||
|
|
||||||
void reload_rc();
|
void reload_rc();
|
||||||
|
|
||||||
void real_rereadMenu();
|
void real_rereadMenu();
|
||||||
void real_reconfigure();
|
void real_reconfigure();
|
||||||
|
|
||||||
void handleEvent(XEvent *xe);
|
void handleEvent(XEvent *xe);
|
||||||
|
|
||||||
void setupConfigFiles();
|
void setupConfigFiles();
|
||||||
void handleButtonEvent(XButtonEvent &be);
|
void handleButtonEvent(XButtonEvent &be);
|
||||||
void handleUnmapNotify(XUnmapEvent &ue);
|
void handleUnmapNotify(XUnmapEvent &ue);
|
||||||
void handleClientMessage(XClientMessageEvent &ce);
|
void handleClientMessage(XClientMessageEvent &ce);
|
||||||
void handleKeyEvent(XKeyEvent &ke);
|
void handleKeyEvent(XKeyEvent &ke);
|
||||||
void setTitlebar(std::vector<Fluxbox::Titlebar>& dir, const char *arg);
|
void setTitlebar(std::vector<Fluxbox::Titlebar>& dir, const char *arg);
|
||||||
|
|
||||||
std::auto_ptr<FbAtoms> m_fbatoms;
|
std::auto_ptr<FbAtoms> m_fbatoms;
|
||||||
|
|
||||||
FbTk::ResourceManager m_resourcemanager, &m_screen_rm;
|
FbTk::ResourceManager m_resourcemanager, &m_screen_rm;
|
||||||
|
|
||||||
//--- Resources
|
//--- Resources
|
||||||
|
|
||||||
FbTk::Resource<bool> m_rc_tabs, m_rc_ignoreborder;
|
FbTk::Resource<bool> m_rc_tabs, m_rc_ignoreborder;
|
||||||
|
@ -258,11 +262,11 @@ private:
|
||||||
m_rc_double_click_interval, m_rc_update_delay_time,
|
m_rc_double_click_interval, m_rc_update_delay_time,
|
||||||
m_rc_tabs_padding,
|
m_rc_tabs_padding,
|
||||||
m_rc_focused_tab_min_width;
|
m_rc_focused_tab_min_width;
|
||||||
FbTk::Resource<std::string> m_rc_stylefile,
|
FbTk::Resource<std::string> m_rc_stylefile,
|
||||||
m_rc_menufile, m_rc_keyfile, m_rc_slitlistfile,
|
m_rc_menufile, m_rc_keyfile, m_rc_slitlistfile,
|
||||||
m_rc_groupfile;
|
m_rc_groupfile;
|
||||||
|
|
||||||
|
|
||||||
FbTk::Resource<TitlebarList> m_rc_titlebar_left, m_rc_titlebar_right;
|
FbTk::Resource<TitlebarList> m_rc_titlebar_left, m_rc_titlebar_right;
|
||||||
FbTk::Resource<TabsAttachArea> m_rc_tabs_attach_area;
|
FbTk::Resource<TabsAttachArea> m_rc_tabs_attach_area;
|
||||||
FbTk::Resource<unsigned int> m_rc_cache_life, m_rc_cache_max;
|
FbTk::Resource<unsigned int> m_rc_cache_life, m_rc_cache_max;
|
||||||
|
@ -277,7 +281,7 @@ private:
|
||||||
// The group leader (which may not be mapped, so may not have a WinClient)
|
// The group leader (which may not be mapped, so may not have a WinClient)
|
||||||
// will have it's window being the group index
|
// will have it's window being the group index
|
||||||
std::multimap<Window, WinClient *> m_group_search;
|
std::multimap<Window, WinClient *> m_group_search;
|
||||||
|
|
||||||
std::list<MenuTimestamp *> m_menu_timestamps;
|
std::list<MenuTimestamp *> m_menu_timestamps;
|
||||||
typedef std::list<BScreen *> ScreenList;
|
typedef std::list<BScreen *> ScreenList;
|
||||||
ScreenList m_screen_list;
|
ScreenList m_screen_list;
|
||||||
|
@ -297,6 +301,9 @@ private:
|
||||||
std::string m_rc_file; ///< resource filename
|
std::string m_rc_file; ///< resource filename
|
||||||
char **m_argv;
|
char **m_argv;
|
||||||
int m_argc;
|
int m_argc;
|
||||||
|
|
||||||
|
std::string m_restart_argument; ///< what to restart
|
||||||
|
|
||||||
XEvent m_last_event;
|
XEvent m_last_event;
|
||||||
|
|
||||||
FbTk::Timer m_reconfig_timer; ///< when we execute reconfig command we must wait at least to next event round
|
FbTk::Timer m_reconfig_timer; ///< when we execute reconfig command we must wait at least to next event round
|
||||||
|
@ -315,6 +322,7 @@ private:
|
||||||
Toolbars m_toolbars;
|
Toolbars m_toolbars;
|
||||||
|
|
||||||
bool m_starting;
|
bool m_starting;
|
||||||
|
bool m_restarting;
|
||||||
bool m_shutdown;
|
bool m_shutdown;
|
||||||
int m_server_grabs;
|
int m_server_grabs;
|
||||||
int m_randr_event_type; ///< the type number of randr event
|
int m_randr_event_type; ///< the type number of randr event
|
||||||
|
|
34
src/main.cc
34
src/main.cc
|
@ -20,7 +20,7 @@
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
// $Id: main.cc,v 1.32 2004/10/11 22:48:35 rathnor Exp $
|
// $Id: main.cc,v 1.33 2004/10/18 01:26:54 akir Exp $
|
||||||
|
|
||||||
#include "fluxbox.hh"
|
#include "fluxbox.hh"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include "FbTk/Theme.hh"
|
#include "FbTk/Theme.hh"
|
||||||
#include "FbTk/I18n.hh"
|
#include "FbTk/I18n.hh"
|
||||||
|
#include "FbTk/StringUtil.hh"
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -73,10 +74,10 @@ void showInfo(ostream &ostr) {
|
||||||
#endif // __fluxbox_compiler_version
|
#endif // __fluxbox_compiler_version
|
||||||
|
|
||||||
ostr<<endl<<_FBTEXT(Common, Defaults, "Defaults", "Default values compiled in")<<":"<<endl;
|
ostr<<endl<<_FBTEXT(Common, Defaults, "Defaults", "Default values compiled in")<<":"<<endl;
|
||||||
|
|
||||||
ostr<<_FBTEXT(Common, DefaultMenuFile, " menu", "default menu file (right aligned - make sure same width as other default values)")<<": "<<DEFAULTMENU<<endl;
|
ostr<<_FBTEXT(Common, DefaultMenuFile, " menu", "default menu file (right aligned - make sure same width as other default values)")<<": "<<DEFAULTMENU<<endl;
|
||||||
ostr<<_FBTEXT(Common, DefaultStyle, " style", "default style (right aligned - make sure same width as other default values)")<<": "<<DEFAULTSTYLE<<endl;
|
ostr<<_FBTEXT(Common, DefaultStyle, " style", "default style (right aligned - make sure same width as other default values)")<<": "<<DEFAULTSTYLE<<endl;
|
||||||
|
|
||||||
ostr<<_FBTEXT(Common, DefaultKeyFile, " keys", "default key file (right aligned - make sure same width as other default values)")<<": "<<DEFAULTKEYSFILE<<endl;
|
ostr<<_FBTEXT(Common, DefaultKeyFile, " keys", "default key file (right aligned - make sure same width as other default values)")<<": "<<DEFAULTKEYSFILE<<endl;
|
||||||
ostr<<_FBTEXT(Common, DefaultInitFile, " init", "default init file (right aligned - make sure same width as other default values)")<<": "<<DEFAULT_INITFILE<<endl;
|
ostr<<_FBTEXT(Common, DefaultInitFile, " init", "default init file (right aligned - make sure same width as other default values)")<<": "<<DEFAULT_INITFILE<<endl;
|
||||||
|
|
||||||
|
@ -87,7 +88,7 @@ void showInfo(ostream &ostr) {
|
||||||
_FBTEXT(Common, Disabled, "disabled", "option is turned off")<<"): "<<endl<<
|
_FBTEXT(Common, Disabled, "disabled", "option is turned off")<<"): "<<endl<<
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
NOT<<
|
NOT<<
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
"DEBUG"<<endl<<
|
"DEBUG"<<endl<<
|
||||||
|
|
||||||
#ifndef SLIT
|
#ifndef SLIT
|
||||||
|
@ -107,7 +108,7 @@ void showInfo(ostream &ostr) {
|
||||||
|
|
||||||
#ifndef USE_GNOME
|
#ifndef USE_GNOME
|
||||||
NOT<<
|
NOT<<
|
||||||
#endif // USE_GNOME
|
#endif // USE_GNOME
|
||||||
"GNOME"<<endl<<
|
"GNOME"<<endl<<
|
||||||
|
|
||||||
#ifndef KDE
|
#ifndef KDE
|
||||||
|
@ -153,14 +154,14 @@ void showInfo(ostream &ostr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
std::string session_display = "";
|
std::string session_display = "";
|
||||||
std::string rc_file;
|
std::string rc_file;
|
||||||
std::string log_filename;
|
std::string log_filename;
|
||||||
|
|
||||||
FbTk::NLSInit("fluxbox.cat");
|
FbTk::NLSInit("fluxbox.cat");
|
||||||
_FB_USES_NLS;
|
_FB_USES_NLS;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for (i = 1; i < argc; ++i) {
|
for (i = 1; i < argc; ++i) {
|
||||||
if (! strcmp(argv[i], "-rc")) {
|
if (! strcmp(argv[i], "-rc")) {
|
||||||
|
@ -249,11 +250,11 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fluxbox.reset(new Fluxbox(argc, argv, session_display.c_str(), rc_file.c_str()));
|
fluxbox.reset(new Fluxbox(argc, argv, session_display.c_str(), rc_file.c_str()));
|
||||||
fluxbox->eventLoop();
|
fluxbox->eventLoop();
|
||||||
|
|
||||||
exitcode = EXIT_SUCCESS;
|
exitcode = EXIT_SUCCESS;
|
||||||
|
|
||||||
} catch (std::out_of_range &oor) {
|
} catch (std::out_of_range &oor) {
|
||||||
cerr<<"Fluxbox: "<<_FBTEXT(main, ErrorOutOfRange, "Out of range", "Error message")<<": "<<oor.what()<<endl;
|
cerr<<"Fluxbox: "<<_FBTEXT(main, ErrorOutOfRange, "Out of range", "Error message")<<": "<<oor.what()<<endl;
|
||||||
|
@ -271,6 +272,10 @@ int main(int argc, char **argv) {
|
||||||
cerr<<"Fluxbox: "<<_FBTEXT(main, ErrorUnknown, "Unknown error", "Error message")<<"."<<endl;
|
cerr<<"Fluxbox: "<<_FBTEXT(main, ErrorUnknown, "Unknown error", "Error message")<<"."<<endl;
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool restarting = fluxbox->isRestarting();
|
||||||
|
const std::string restart_argument(fluxbox->getRestartArgument());
|
||||||
|
|
||||||
// destroy fluxbox
|
// destroy fluxbox
|
||||||
fluxbox.reset(0);
|
fluxbox.reset(0);
|
||||||
|
|
||||||
|
@ -280,5 +285,16 @@ int main(int argc, char **argv) {
|
||||||
if (errbuf != 0)
|
if (errbuf != 0)
|
||||||
cerr.rdbuf(errbuf);
|
cerr.rdbuf(errbuf);
|
||||||
|
|
||||||
|
if (restarting) {
|
||||||
|
if (restart_argument.c_str()) {
|
||||||
|
execlp(restart_argument.c_str(), restart_argument.c_str(), 0);
|
||||||
|
perror(restart_argument.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
// fall back in case the above execlp doesn't work
|
||||||
|
execvp(argv[0], argv);
|
||||||
|
execvp(FbTk::StringUtil::basename(argv[0]).c_str(), argv);
|
||||||
|
}
|
||||||
|
|
||||||
return exitcode;
|
return exitcode;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue