aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorakir <akir>2004-10-18 01:26:54 (GMT)
committerakir <akir>2004-10-18 01:26:54 (GMT)
commit496d73d89994d868f5dc45a5ea6cefe40a74f148 (patch)
treef8a9b4102403e4d58082d17d7dbc406ea3360f81 /src
parent2760b03b2e0a7ee93e4ce70daf73faa609076dff (diff)
downloadfluxbox_paul-496d73d89994d868f5dc45a5ea6cefe40a74f148.zip
fluxbox_paul-496d73d89994d868f5dc45a5ea6cefe40a74f148.tar.bz2
rewritten fluxbox-restart code, all destructors are called before the
new program is started. the former method didnt do that.
Diffstat (limited to 'src')
-rw-r--r--src/fluxbox.cc16
-rw-r--r--src/fluxbox.hh34
-rw-r--r--src/main.cc34
3 files changed, 54 insertions, 30 deletions
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index 3563c8c..cfceaf7 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: fluxbox.cc,v 1.258 2004/10/10 16:06:23 akir Exp $ 25// $Id: fluxbox.cc,v 1.259 2004/10/18 01:26:54 akir Exp $
26 26
27#include "fluxbox.hh" 27#include "fluxbox.hh"
28 28
@@ -238,6 +238,7 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile
238 m_rc_file(rcfilename ? rcfilename : ""), 238 m_rc_file(rcfilename ? rcfilename : ""),
239 m_argv(argv), m_argc(argc), 239 m_argv(argv), m_argc(argc),
240 m_starting(true), 240 m_starting(true),
241 m_restarting(false),
241 m_shutdown(false), 242 m_shutdown(false),
242 m_server_grabs(0), 243 m_server_grabs(0),
243 m_randr_event_type(0), 244 m_randr_event_type(0),
@@ -457,6 +458,7 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile
457 458
458 459
459Fluxbox::~Fluxbox() { 460Fluxbox::~Fluxbox() {
461
460 // destroy toolbars 462 // destroy toolbars
461 while (!m_toolbars.empty()) { 463 while (!m_toolbars.empty()) {
462 delete m_toolbars.back(); 464 delete m_toolbars.back();
@@ -1357,14 +1359,11 @@ void Fluxbox::removeGroupSearch(Window window) {
1357void Fluxbox::restart(const char *prog) { 1359void Fluxbox::restart(const char *prog) {
1358 shutdown(); 1360 shutdown();
1359 1361
1362 m_restarting = true;
1363
1360 if (prog) { 1364 if (prog) {
1361 execlp(prog, prog, 0); 1365 m_restart_argument = prog;
1362 perror(prog);
1363 } 1366 }
1364
1365 // fall back in case the above execlp doesn't work
1366 execvp(m_argv[0], m_argv);
1367 execvp(StringUtil::basename(m_argv[0]).c_str(), m_argv);
1368} 1367}
1369 1368
1370/// prepares fluxbox for a shutdown 1369/// prepares fluxbox for a shutdown
@@ -1377,7 +1376,8 @@ void Fluxbox::shutdown() {
1377 XSetInputFocus(FbTk::App::instance()->display(), PointerRoot, None, CurrentTime); 1376 XSetInputFocus(FbTk::App::instance()->display(), PointerRoot, None, CurrentTime);
1378 1377
1379 //send shutdown to all screens 1378 //send shutdown to all screens
1380 for_each(m_screen_list.begin(), m_screen_list.end(), mem_fun(&BScreen::shutdown)); 1379 for_each(m_screen_list.begin(),
1380 m_screen_list.end(), mem_fun(&BScreen::shutdown));
1381 1381
1382 sync(false); 1382 sync(false);
1383 1383
diff --git a/src/fluxbox.hh b/src/fluxbox.hh
index 0b67b44..021619b 100644
--- a/src/fluxbox.hh
+++ b/src/fluxbox.hh
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: fluxbox.hh,v 1.92 2004/10/10 16:06:24 akir Exp $ 25// $Id: fluxbox.hh,v 1.93 2004/10/18 01:26:54 akir Exp $
26 26
27#ifndef FLUXBOX_HH 27#ifndef FLUXBOX_HH
28#define FLUXBOX_HH 28#define FLUXBOX_HH
@@ -83,7 +83,7 @@ public:
83 Fluxbox(int argc, char **argv, const char * dpy_name= 0, 83 Fluxbox(int argc, char **argv, const char * dpy_name= 0,
84 const char *rcfilename = 0); 84 const char *rcfilename = 0);
85 virtual ~Fluxbox(); 85 virtual ~Fluxbox();
86 86
87 static Fluxbox *instance() { return s_singleton; } 87 static Fluxbox *instance() { return s_singleton; }
88 /// main event loop 88 /// main event loop
89 void eventLoop(); 89 void eventLoop();
@@ -98,7 +98,7 @@ public:
98 WinClient *searchWindow(Window); 98 WinClient *searchWindow(Window);
99 inline WinClient *getFocusedWindow() { return m_focused_window; } 99 inline WinClient *getFocusedWindow() { return m_focused_window; }
100 100
101 101
102 BScreen *searchScreen(Window w); 102 BScreen *searchScreen(Window w);
103 103
104 inline unsigned int getDoubleClickInterval() const { return *m_rc_double_click_interval; } 104 inline unsigned int getDoubleClickInterval() const { return *m_rc_double_click_interval; }
@@ -138,7 +138,7 @@ public:
138 inline int getNum() const { return m_num; } 138 inline int getNum() const { return m_num; }
139 139
140 Layer &operator=(int num) { m_num = num; return *this; } 140 Layer &operator=(int num) { m_num = num; return *this; }
141 141
142 private: 142 private:
143 int m_num; 143 int m_num;
144 }; 144 };
@@ -193,17 +193,20 @@ public:
193 void checkMenu(); 193 void checkMenu();
194 194
195 void hideExtraMenus(BScreen &screen); 195 void hideExtraMenus(BScreen &screen);
196 196
197 /// handle any system signal sent to the application 197 /// handle any system signal sent to the application
198 void handleSignal(int signum); 198 void handleSignal(int signum);
199 void update(FbTk::Subject *changed); 199 void update(FbTk::Subject *changed);
200 200
201 void attachSignals(FluxboxWindow &win); 201 void attachSignals(FluxboxWindow &win);
202 void attachSignals(WinClient &winclient); 202 void attachSignals(WinClient &winclient);
203 203
204 void timed_reconfigure(); 204 void timed_reconfigure();
205 205
206 bool isStartup() const { return m_starting; } 206 bool isStartup() const { return m_starting; }
207 bool isRestarting() const { return m_restarting; }
208
209 const std::string &getRestartArgument() const { return m_restart_argument; }
207 210
208 /// get screen from number 211 /// get screen from number
209 BScreen *findScreen(int num); 212 BScreen *findScreen(int num);
@@ -221,6 +224,7 @@ public:
221 // screen we are watching for modifier changes 224 // screen we are watching for modifier changes
222 BScreen *watchingScreen() { return m_watching_screen; } 225 BScreen *watchingScreen() { return m_watching_screen; }
223 const XEvent &lastEvent() const { return m_last_event; } 226 const XEvent &lastEvent() const { return m_last_event; }
227
224private: 228private:
225 229
226 typedef struct MenuTimestamp { 230 typedef struct MenuTimestamp {
@@ -232,24 +236,24 @@ private:
232 236
233 std::string getRcFilename(); 237 std::string getRcFilename();
234 void load_rc(); 238 void load_rc();
235
236 void reload_rc(); 239 void reload_rc();
240
237 void real_rereadMenu(); 241 void real_rereadMenu();
238 void real_reconfigure(); 242 void real_reconfigure();
239 243
240 void handleEvent(XEvent *xe); 244 void handleEvent(XEvent *xe);
241 245
242 void setupConfigFiles(); 246 void setupConfigFiles();
243 void handleButtonEvent(XButtonEvent &be); 247 void handleButtonEvent(XButtonEvent &be);
244 void handleUnmapNotify(XUnmapEvent &ue); 248 void handleUnmapNotify(XUnmapEvent &ue);
245 void handleClientMessage(XClientMessageEvent &ce); 249 void handleClientMessage(XClientMessageEvent &ce);
246 void handleKeyEvent(XKeyEvent &ke); 250 void handleKeyEvent(XKeyEvent &ke);
247 void setTitlebar(std::vector<Fluxbox::Titlebar>& dir, const char *arg); 251 void setTitlebar(std::vector<Fluxbox::Titlebar>& dir, const char *arg);
248 252
249 std::auto_ptr<FbAtoms> m_fbatoms; 253 std::auto_ptr<FbAtoms> m_fbatoms;
250 254
251 FbTk::ResourceManager m_resourcemanager, &m_screen_rm; 255 FbTk::ResourceManager m_resourcemanager, &m_screen_rm;
252 256
253 //--- Resources 257 //--- Resources
254 258
255 FbTk::Resource<bool> m_rc_tabs, m_rc_ignoreborder; 259 FbTk::Resource<bool> m_rc_tabs, m_rc_ignoreborder;
@@ -258,11 +262,11 @@ private:
258 m_rc_double_click_interval, m_rc_update_delay_time, 262 m_rc_double_click_interval, m_rc_update_delay_time,
259 m_rc_tabs_padding, 263 m_rc_tabs_padding,
260 m_rc_focused_tab_min_width; 264 m_rc_focused_tab_min_width;
261 FbTk::Resource<std::string> m_rc_stylefile, 265 FbTk::Resource<std::string> m_rc_stylefile,
262 m_rc_menufile, m_rc_keyfile, m_rc_slitlistfile, 266 m_rc_menufile, m_rc_keyfile, m_rc_slitlistfile,
263 m_rc_groupfile; 267 m_rc_groupfile;
264 268
265 269
266 FbTk::Resource<TitlebarList> m_rc_titlebar_left, m_rc_titlebar_right; 270 FbTk::Resource<TitlebarList> m_rc_titlebar_left, m_rc_titlebar_right;
267 FbTk::Resource<TabsAttachArea> m_rc_tabs_attach_area; 271 FbTk::Resource<TabsAttachArea> m_rc_tabs_attach_area;
268 FbTk::Resource<unsigned int> m_rc_cache_life, m_rc_cache_max; 272 FbTk::Resource<unsigned int> m_rc_cache_life, m_rc_cache_max;
@@ -277,7 +281,7 @@ private:
277 // The group leader (which may not be mapped, so may not have a WinClient) 281 // The group leader (which may not be mapped, so may not have a WinClient)
278 // will have it's window being the group index 282 // will have it's window being the group index
279 std::multimap<Window, WinClient *> m_group_search; 283 std::multimap<Window, WinClient *> m_group_search;
280 284
281 std::list<MenuTimestamp *> m_menu_timestamps; 285 std::list<MenuTimestamp *> m_menu_timestamps;
282 typedef std::list<BScreen *> ScreenList; 286 typedef std::list<BScreen *> ScreenList;
283 ScreenList m_screen_list; 287 ScreenList m_screen_list;
@@ -297,6 +301,9 @@ private:
297 std::string m_rc_file; ///< resource filename 301 std::string m_rc_file; ///< resource filename
298 char **m_argv; 302 char **m_argv;
299 int m_argc; 303 int m_argc;
304
305 std::string m_restart_argument; ///< what to restart
306
300 XEvent m_last_event; 307 XEvent m_last_event;
301 308
302 FbTk::Timer m_reconfig_timer; ///< when we execute reconfig command we must wait at least to next event round 309 FbTk::Timer m_reconfig_timer; ///< when we execute reconfig command we must wait at least to next event round
@@ -315,6 +322,7 @@ private:
315 Toolbars m_toolbars; 322 Toolbars m_toolbars;
316 323
317 bool m_starting; 324 bool m_starting;
325 bool m_restarting;
318 bool m_shutdown; 326 bool m_shutdown;
319 int m_server_grabs; 327 int m_server_grabs;
320 int m_randr_event_type; ///< the type number of randr event 328 int m_randr_event_type; ///< the type number of randr event
diff --git a/src/main.cc b/src/main.cc
index b7fb949..137d1de 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -20,7 +20,7 @@
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE. 21// DEALINGS IN THE SOFTWARE.
22 22
23// $Id: main.cc,v 1.32 2004/10/11 22:48:35 rathnor Exp $ 23// $Id: main.cc,v 1.33 2004/10/18 01:26:54 akir Exp $
24 24
25#include "fluxbox.hh" 25#include "fluxbox.hh"
26#include "version.h" 26#include "version.h"
@@ -28,6 +28,7 @@
28 28
29#include "FbTk/Theme.hh" 29#include "FbTk/Theme.hh"
30#include "FbTk/I18n.hh" 30#include "FbTk/I18n.hh"
31#include "FbTk/StringUtil.hh"
31 32
32#ifdef HAVE_CONFIG_H 33#ifdef HAVE_CONFIG_H
33#include "config.h" 34#include "config.h"
@@ -73,10 +74,10 @@ void showInfo(ostream &ostr) {
73#endif // __fluxbox_compiler_version 74#endif // __fluxbox_compiler_version
74 75
75 ostr<<endl<<_FBTEXT(Common, Defaults, "Defaults", "Default values compiled in")<<":"<<endl; 76 ostr<<endl<<_FBTEXT(Common, Defaults, "Defaults", "Default values compiled in")<<":"<<endl;
76 77
77 ostr<<_FBTEXT(Common, DefaultMenuFile, " menu", "default menu file (right aligned - make sure same width as other default values)")<<": "<<DEFAULTMENU<<endl; 78 ostr<<_FBTEXT(Common, DefaultMenuFile, " menu", "default menu file (right aligned - make sure same width as other default values)")<<": "<<DEFAULTMENU<<endl;
78 ostr<<_FBTEXT(Common, DefaultStyle, " style", "default style (right aligned - make sure same width as other default values)")<<": "<<DEFAULTSTYLE<<endl; 79 ostr<<_FBTEXT(Common, DefaultStyle, " style", "default style (right aligned - make sure same width as other default values)")<<": "<<DEFAULTSTYLE<<endl;
79 80
80 ostr<<_FBTEXT(Common, DefaultKeyFile, " keys", "default key file (right aligned - make sure same width as other default values)")<<": "<<DEFAULTKEYSFILE<<endl; 81 ostr<<_FBTEXT(Common, DefaultKeyFile, " keys", "default key file (right aligned - make sure same width as other default values)")<<": "<<DEFAULTKEYSFILE<<endl;
81 ostr<<_FBTEXT(Common, DefaultInitFile, " init", "default init file (right aligned - make sure same width as other default values)")<<": "<<DEFAULT_INITFILE<<endl; 82 ostr<<_FBTEXT(Common, DefaultInitFile, " init", "default init file (right aligned - make sure same width as other default values)")<<": "<<DEFAULT_INITFILE<<endl;
82 83
@@ -87,7 +88,7 @@ void showInfo(ostream &ostr) {
87 _FBTEXT(Common, Disabled, "disabled", "option is turned off")<<"): "<<endl<< 88 _FBTEXT(Common, Disabled, "disabled", "option is turned off")<<"): "<<endl<<
88#ifndef DEBUG 89#ifndef DEBUG
89 NOT<< 90 NOT<<
90#endif // DEBUG 91#endif // DEBUG
91 "DEBUG"<<endl<< 92 "DEBUG"<<endl<<
92 93
93#ifndef SLIT 94#ifndef SLIT
@@ -107,7 +108,7 @@ void showInfo(ostream &ostr) {
107 108
108#ifndef USE_GNOME 109#ifndef USE_GNOME
109 NOT<< 110 NOT<<
110#endif // USE_GNOME 111#endif // USE_GNOME
111 "GNOME"<<endl<< 112 "GNOME"<<endl<<
112 113
113#ifndef KDE 114#ifndef KDE
@@ -153,14 +154,14 @@ void showInfo(ostream &ostr) {
153} 154}
154 155
155int main(int argc, char **argv) { 156int main(int argc, char **argv) {
156 157
157 std::string session_display = ""; 158 std::string session_display = "";
158 std::string rc_file; 159 std::string rc_file;
159 std::string log_filename; 160 std::string log_filename;
160 161
161 FbTk::NLSInit("fluxbox.cat"); 162 FbTk::NLSInit("fluxbox.cat");
162 _FB_USES_NLS; 163 _FB_USES_NLS;
163 164
164 int i; 165 int i;
165 for (i = 1; i < argc; ++i) { 166 for (i = 1; i < argc; ++i) {
166 if (! strcmp(argv[i], "-rc")) { 167 if (! strcmp(argv[i], "-rc")) {
@@ -249,11 +250,11 @@ int main(int argc, char **argv) {
249 } 250 }
250 251
251 try { 252 try {
252 253
253 fluxbox.reset(new Fluxbox(argc, argv, session_display.c_str(), rc_file.c_str())); 254 fluxbox.reset(new Fluxbox(argc, argv, session_display.c_str(), rc_file.c_str()));
254 fluxbox->eventLoop(); 255 fluxbox->eventLoop();
255 256
256 exitcode = EXIT_SUCCESS; 257 exitcode = EXIT_SUCCESS;
257 258
258 } catch (std::out_of_range &oor) { 259 } catch (std::out_of_range &oor) {
259 cerr<<"Fluxbox: "<<_FBTEXT(main, ErrorOutOfRange, "Out of range", "Error message")<<": "<<oor.what()<<endl; 260 cerr<<"Fluxbox: "<<_FBTEXT(main, ErrorOutOfRange, "Out of range", "Error message")<<": "<<oor.what()<<endl;
@@ -271,6 +272,10 @@ int main(int argc, char **argv) {
271 cerr<<"Fluxbox: "<<_FBTEXT(main, ErrorUnknown, "Unknown error", "Error message")<<"."<<endl; 272 cerr<<"Fluxbox: "<<_FBTEXT(main, ErrorUnknown, "Unknown error", "Error message")<<"."<<endl;
272 abort(); 273 abort();
273 } 274 }
275
276 bool restarting = fluxbox->isRestarting();
277 const std::string restart_argument(fluxbox->getRestartArgument());
278
274 // destroy fluxbox 279 // destroy fluxbox
275 fluxbox.reset(0); 280 fluxbox.reset(0);
276 281
@@ -280,5 +285,16 @@ int main(int argc, char **argv) {
280 if (errbuf != 0) 285 if (errbuf != 0)
281 cerr.rdbuf(errbuf); 286 cerr.rdbuf(errbuf);
282 287
288 if (restarting) {
289 if (restart_argument.c_str()) {
290 execlp(restart_argument.c_str(), restart_argument.c_str(), 0);
291 perror(restart_argument.c_str());
292 }
293
294 // fall back in case the above execlp doesn't work
295 execvp(argv[0], argv);
296 execvp(FbTk::StringUtil::basename(argv[0]).c_str(), argv);
297 }
298
283 return exitcode; 299 return exitcode;
284} 300}