]>
Dogcows Code - chaz/openbox/blob - src/openbox.cc
1 // -*- mode: C++; indent-tabs-mode: nil; -*-
4 # include "../config.h"
7 #include "../version.h"
9 #include "otk/display.hh"
14 #endif // HAVE_STDIO_H
18 #endif // HAVE_STDLIB_H
22 #endif // HAVE_SIGNAL_H
26 #endif // HAVE_FCNTL_H
29 # include <sys/types.h>
31 #endif // HAVE_UNISTD_H
33 #ifdef HAVE_SYS_SELECT_H
34 # include <sys/select.h>
35 #endif // HAVE_SYS_SELECT_H
38 #define _(str) gettext(str)
44 Openbox
*Openbox::instance
= (Openbox
*) 0;
47 void Openbox::signalHandler(int signal
)
51 // XXX: Do something with HUP? Really shouldn't, we get this when X shuts
52 // down and hangs-up on us.
57 printf("Caught signal %d. Exiting.", signal
);
63 printf("Caught signal %d. Aborting and dumping core.", signal
);
69 Openbox::Openbox(int argc
, char **argv
)
71 struct sigaction action
;
73 _state
= State_Starting
; // initializing everything
75 Openbox::instance
= this;
77 _displayreq
= (char*) 0;
80 parseCommandLine(argc
, argv
);
82 // open the X display (and gets some info about it, and its screens)
83 otk::OBDisplay::initialize(_displayreq
);
84 assert(otk::OBDisplay::display
);
86 // set up the signal handler
87 action
.sa_handler
= Openbox::signalHandler
;
88 action
.sa_mask
= sigset_t();
89 action
.sa_flags
= SA_NOCLDSTOP
| SA_NODEFER
;
90 sigaction(SIGPIPE
, &action
, (struct sigaction
*) 0);
91 sigaction(SIGSEGV
, &action
, (struct sigaction
*) 0);
92 sigaction(SIGFPE
, &action
, (struct sigaction
*) 0);
93 sigaction(SIGTERM
, &action
, (struct sigaction
*) 0);
94 sigaction(SIGINT
, &action
, (struct sigaction
*) 0);
95 sigaction(SIGHUP
, &action
, (struct sigaction
*) 0);
99 _state
= State_Normal
; // done starting
105 _state
= State_Exiting
; // time to kill everything
107 // close the X display
108 otk::OBDisplay::destroy();
112 void Openbox::parseCommandLine(int argc
, char **argv
)
116 for (int i
= 1; i
< argc
; ++i
) {
117 std::string
arg(argv
[i
]);
119 if (arg
== "-display") {
123 _displayreq
= argv
[i
];
124 } else if (arg
== "-rc") {
128 _rcfilepath
= argv
[i
];
129 } else if (arg
== "-menu") {
133 _menufilepath
= argv
[i
];
134 } else if (arg
== "-version") {
137 } else if (arg
== "-help") {
151 void Openbox::showVersion()
153 printf(_("Openbox - version %s\n"), OPENBOX_VERSION
);
154 printf(" (c) 2002 - 2002 Ben Jansens\n\n");
158 void Openbox::showHelp()
160 showVersion(); // show the version string and copyright
162 // print program usage and command line options
163 printf(_("Usage: %s [OPTIONS...]\n\
165 -display <string> use display connection.\n\
166 -rc <string> use alternate resource file.\n\
167 -menu <string> use alternate menu file.\n\
168 -version display version and exit.\n\
169 -help display this help text and exit.\n\n"), _argv0
);
171 printf(_("Compile time options:\n\
196 void Openbox::eventLoop()
198 while (!_doshutdown
) {
199 if (XPending(otk::OBDisplay::display
)) {
201 XNextEvent(otk::OBDisplay::display
, &e
);
203 _xeventhandler
.handle(e
);
205 _timermanager
.fire();
This page took 0.050347 seconds and 4 git commands to generate.