diff options
Diffstat (limited to 'src/main.cc')
-rw-r--r-- | src/main.cc | 320 |
1 files changed, 132 insertions, 188 deletions
diff --git a/src/main.cc b/src/main.cc index 19ed631..9317792 100644 --- a/src/main.cc +++ b/src/main.cc | |||
@@ -1,3 +1,6 @@ | |||
1 | // main.cc for Fluxbox Window manager | ||
2 | // Copyright (c) 2001 - 2002 Henrik Kinnunen (fluxgen@linuxmail.org) | ||
3 | // | ||
1 | // main.cc for Blackbox - an X11 Window manager | 4 | // main.cc for Blackbox - an X11 Window manager |
2 | // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) | 5 | // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) |
3 | // | 6 | // |
@@ -19,46 +22,70 @@ | |||
19 | // 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 |
20 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
21 | 24 | ||
22 | // stupid macros needed to access some functions in version 2 of the GNU C | 25 | // $Id: main.cc,v 1.7 2002/08/13 23:56:02 fluxgen Exp $ |
23 | // library | ||
24 | #ifndef _GNU_SOURCE | ||
25 | #define _GNU_SOURCE | ||
26 | #endif // _GNU_SOURCE | ||
27 | 26 | ||
28 | #include "../version.h" | ||
29 | 27 | ||
30 | #ifdef HAVE_CONFIG_H | ||
31 | # include "../config.h" | ||
32 | #endif // HAVE_CONFIG_H | ||
33 | 28 | ||
34 | #include "i18n.hh" | 29 | #include "i18n.hh" |
35 | #include "fluxbox.hh" | 30 | #include "fluxbox.hh" |
36 | 31 | ||
37 | #ifdef HAVE_STDIO_H | 32 | #include "../version.h" |
38 | # include <stdio.h> | ||
39 | #endif // HAVE_STDIO_H | ||
40 | 33 | ||
41 | #ifdef STDC_HEADERS | 34 | #ifdef HAVE_CONFIG_H |
42 | # include <stdlib.h> | 35 | #include "../config.h" |
43 | # include <string.h> | 36 | #endif // HAVE_CONFIG_H |
44 | #endif // STDC_HEADERS | ||
45 | 37 | ||
46 | #ifdef HAVE_UNISTD_H | 38 | //use GNU extensions |
39 | #ifndef _GNU_SOURCE | ||
40 | #define _GNU_SOURCE | ||
41 | #endif // _GNU_SOURCE | ||
42 | |||
43 | #include <cstdio> | ||
44 | #include <cstdlib> | ||
45 | #include <cstring> | ||
46 | |||
47 | #ifdef HAVE_UNISTD_H | ||
47 | #include <sys/types.h> | 48 | #include <sys/types.h> |
48 | #endif // HAVE_UNISTD_H | 49 | #endif // HAVE_UNISTD_H |
49 | 50 | ||
50 | #ifdef HAVE_SYS_PARAM_H | 51 | #ifdef HAVE_SYS_PARAM_H |
51 | # include <sys/param.h> | 52 | #include <sys/param.h> |
52 | #endif // HAVE_SYS_PARAM_H | 53 | #endif // HAVE_SYS_PARAM_H |
53 | 54 | ||
54 | #ifndef MAXPATHLEN | 55 | #ifndef MAXPATHLEN |
55 | #define MAXPATHLEN 255 | 56 | #define MAXPATHLEN 255 |
56 | #endif // MAXPATHLEN | 57 | #endif // MAXPATHLEN |
57 | 58 | ||
58 | #include <iostream> | 59 | #include <iostream> |
59 | using namespace std; | 60 | using namespace std; |
60 | 61 | ||
62 | #ifdef DEBUG_UDS | ||
63 | |||
64 | #include <uds/init.hh> | ||
65 | #include <uds/uds.hh> | ||
66 | |||
67 | // configure UDS | ||
68 | uds::uds_flags_t uds::flags = uds::leak_check; | ||
69 | |||
70 | #endif //!DEBUG_UDS | ||
71 | |||
72 | const char *getNLSYesNoMsg(bool val) { | ||
73 | if (val) { | ||
74 | return I18n::instance()->getMessage( | ||
75 | FBNLS::CommonSet, FBNLS::CommonYes, | ||
76 | "yes"); | ||
77 | } | ||
78 | |||
79 | return I18n::instance()->getMessage( | ||
80 | FBNLS::CommonSet, FBNLS::CommonNo, | ||
81 | "no"); | ||
82 | } | ||
83 | |||
61 | int main(int argc, char **argv) { | 84 | int main(int argc, char **argv) { |
85 | #ifdef DEBUG_UDS | ||
86 | uds::Init uds_init; | ||
87 | #endif //!DEBUG_UDS | ||
88 | |||
62 | char *session_display = (char *) 0; | 89 | char *session_display = (char *) 0; |
63 | char *rc_file = (char *) 0; | 90 | char *rc_file = (char *) 0; |
64 | 91 | ||
@@ -72,192 +99,109 @@ int main(int argc, char **argv) { | |||
72 | 99 | ||
73 | if ((++i) >= argc) { | 100 | if ((++i) >= argc) { |
74 | fprintf(stderr, | 101 | fprintf(stderr, |
75 | i18n->getMessage( | 102 | i18n->getMessage( |
76 | #ifdef NLS | 103 | FBNLS::mainSet, FBNLS::mainRCRequiresArg, |
77 | mainSet, mainRCRequiresArg, | 104 | "error: '-rc' requires and argument\n")); |
78 | #else // !NLS | 105 | exit(1); |
79 | 0, 0, | 106 | } |
80 | #endif // NLS | ||
81 | "error: '-rc' requires and argument\n")); | ||
82 | |||
83 | ::exit(1); | ||
84 | } | ||
85 | 107 | ||
86 | rc_file = argv[i]; | 108 | rc_file = argv[i]; |
87 | } else if (! strcmp(argv[i], "-display")) { | 109 | } else if (! strcmp(argv[i], "-display")) { |
88 | // check for -display option... to run on a display other than the one | 110 | // check for -display option... to run on a display other than the one |
89 | // set by the environment variable DISPLAY | 111 | // set by the environment variable DISPLAY |
90 | 112 | ||
91 | if ((++i) >= argc) { | 113 | if ((++i) >= argc) { |
92 | fprintf(stderr, | 114 | fprintf(stderr, |
93 | i18n->getMessage( | 115 | i18n->getMessage( |
94 | #ifdef NLS | 116 | FBNLS::mainSet, FBNLS::mainDISPLAYRequiresArg, |
95 | mainSet, mainDISPLAYRequiresArg, | 117 | "error: '-display' requires an argument\n")); |
96 | #else // !NLS | 118 | exit(1); |
97 | 0, 0, | 119 | } |
98 | #endif // NLS | ||
99 | "error: '-display' requires an argument\n")); | ||
100 | |||
101 | ::exit(1); | ||
102 | } | ||
103 | 120 | ||
104 | session_display = argv[i]; | 121 | session_display = argv[i]; |
105 | char dtmp[MAXPATHLEN]; | 122 | char dtmp[MAXPATHLEN]; |
106 | sprintf(dtmp, "DISPLAY=%s", session_display); | 123 | sprintf(dtmp, "DISPLAY=%s", session_display); |
107 | 124 | ||
108 | if (putenv(dtmp)) { | 125 | if (putenv(dtmp)) { |
109 | fprintf(stderr, | 126 | fprintf(stderr, |
110 | i18n-> | 127 | i18n-> |
111 | getMessage( | 128 | getMessage( |
112 | #ifdef NLS | 129 | FBNLS::mainSet, FBNLS::mainWarnDisplaySet, |
113 | mainSet, mainWarnDisplaySet, | 130 | "warning: couldn't set environment variable 'DISPLAY'\n")); |
114 | #else // !NLS | ||
115 | 0, 0, | ||
116 | #endif // NLS | ||
117 | "warning: couldn't set environment variable 'DISPLAY'\n")); | ||
118 | perror("putenv()"); | 131 | perror("putenv()"); |
119 | } | 132 | } |
120 | } else if (! strcmp(argv[i], "-version")) { | 133 | } else if (strcmp(argv[i], "-version") == 0) { |
121 | // print current version string | 134 | // print current version string |
122 | printf("Fluxbox %s : (c) 2001 Henrik Kinnunen \n\n", | 135 | printf("Fluxbox %s : (c) 2001-2002 Henrik Kinnunen \n\n", |
123 | __fluxbox_version); | 136 | __fluxbox_version); |
124 | 137 | exit(0); | |
125 | ::exit(0); | 138 | } else if (strcmp(argv[i], "-help") == 0) { |
126 | } else if (! strcmp(argv[i], "-help")) { | 139 | // print program usage and command line options |
127 | // print program usage and command line options | 140 | printf(i18n-> |
128 | printf(i18n-> | 141 | getMessage( |
129 | getMessage( | 142 | FBNLS::mainSet, FBNLS::mainUsage, |
130 | #ifdef NLS | 143 | "Fluxbox %s : (c) 2001-2002 Henrik Kinnunen\n\n" |
131 | mainSet, mainUsage, | 144 | " -display <string>\t\tuse display connection.\n" |
132 | #else // !NLS | 145 | " -rc <string>\t\t\tuse alternate resource file.\n" |
133 | 0, 0, | 146 | " -version\t\t\tdisplay version and exit.\n" |
134 | #endif // NLS | 147 | " -help\t\t\t\tdisplay this help text and exit.\n\n"), |
135 | "Fluxbox %s : (c) 2001 Henrik Kinnunen\n\n" | 148 | __fluxbox_version); |
136 | " -display <string>\t\tuse display connection.\n" | 149 | |
137 | " -rc <string>\t\t\tuse alternate resource file.\n" | 150 | // some people have requested that we print out command line options |
138 | " -version\t\t\tdisplay version and exit.\n" | 151 | // as well |
139 | " -help\t\t\t\tdisplay this help text and exit.\n\n"), | 152 | printf(i18n-> |
140 | __fluxbox_version); | 153 | getMessage( |
141 | 154 | FBNLS::mainSet, FBNLS::mainCompileOptions, | |
142 | // some people have requested that we print out command line options | ||
143 | // as well | ||
144 | printf(i18n-> | ||
145 | getMessage( | ||
146 | #ifdef NLS | ||
147 | mainSet, mainCompileOptions, | ||
148 | #else // !NLS | ||
149 | 0, 0, | ||
150 | #endif // NLS | ||
151 | "Compile time options:\n" | 155 | "Compile time options:\n" |
152 | " Debugging:\t\t\t%s\n" | 156 | " Debugging:\t\t\t%s\n" |
153 | " Interlacing:\t\t\t%s\n" | 157 | " Interlacing:\t\t\t%s\n" |
154 | " Shape:\t\t\t%s\n" | 158 | " Shape:\t\t\t%s\n" |
155 | " Slit:\t\t\t\t%s\n" | 159 | " Slit:\t\t\t\t%s\n" |
156 | " 8bpp Ordered Dithering:\t%s\n\n"), | 160 | " 8bpp Ordered Dithering:\t%s\n\n"), |
157 | #ifdef DEBUG | 161 | #ifdef DEBUG |
158 | i18n->getMessage( | 162 | getNLSYesNoMsg(true), |
159 | #ifdef NLS | 163 | #else // !DEBUG |
160 | CommonSet, CommonYes, | 164 | getNLSYesNoMsg(false), |
161 | #else // !NLS | 165 | #endif // DEBUG |
162 | 0, 0, | 166 | |
163 | #endif // NLS | 167 | #ifdef INTERLACE |
164 | "yes"), | 168 | getNLSYesNoMsg(true), |
165 | #else // !DEBUG | 169 | #else // !INTERLACE |
166 | i18n->getMessage( | 170 | getNLSYesNoMsg(false), |
167 | #ifdef NLS | 171 | #endif // INTERLACE |
168 | CommonSet, CommonNo, | 172 | |
169 | #else // !NLS | 173 | #ifdef SHAPE |
170 | 0, 0, | 174 | getNLSYesNoMsg(true), |
171 | #endif // NLS | 175 | #else // !SHAPE |
172 | "no"), | 176 | getNLSYesNoMsg(false), |
173 | #endif // DEBUG | 177 | #endif // SHAPE |
174 | 178 | ||
175 | #ifdef INTERLACE | 179 | #ifdef SLIT |
176 | i18n->getMessage( | 180 | getNLSYesNoMsg(true), |
177 | #ifdef NLS | 181 | #else // !SLIT |
178 | CommonSet, CommonYes, | 182 | getNLSYesNoMsg(false), |
179 | #else // !NLS | 183 | #endif // SLIT |
180 | 0, 0, | 184 | |
181 | #endif // NLS | 185 | #ifdef ORDEREDPSEUDO |
182 | "yes"), | 186 | getNLSYesNoMsg(true) |
183 | #else // !INTERLACE | 187 | #else // !ORDEREDPSEUDO |
184 | i18n->getMessage( | 188 | getNLSYesNoMsg(false) |
185 | #ifdef NLS | 189 | #endif // ORDEREDPSEUDO |
186 | CommonSet, CommonNo, | 190 | |
187 | #else // !NLS | 191 | ); |
188 | 0, 0, | 192 | |
189 | #endif // NLS | 193 | ::exit(0); |
190 | "no"), | 194 | } |
191 | #endif // INTERLACE | 195 | } |
192 | 196 | ||
193 | #ifdef SHAPE | 197 | #ifdef __EMX__ |
194 | i18n->getMessage( | 198 | _chdir2(getenv("X11ROOT")); |
195 | #ifdef NLS | ||
196 | CommonSet, CommonYes, | ||
197 | #else // !NLS | ||
198 | 0, 0, | ||
199 | #endif // NLS | ||
200 | "yes"), | ||
201 | #else // !SHAPE | ||
202 | i18n->getMessage( | ||
203 | #ifdef NLS | ||
204 | CommonSet, CommonNo, | ||
205 | #else // !NLS | ||
206 | 0, 0, | ||
207 | #endif // NLS | ||
208 | "no"), | ||
209 | #endif // SHAPE | ||
210 | |||
211 | #ifdef SLIT | ||
212 | i18n->getMessage( | ||
213 | #ifdef NLS | ||
214 | CommonSet, CommonYes, | ||
215 | #else // !NLS | ||
216 | 0, 0, | ||
217 | #endif // NLS | ||
218 | "yes"), | ||
219 | #else // !SLIT | ||
220 | i18n->getMessage( | ||
221 | #ifdef NLS | ||
222 | CommonSet, CommonNo, | ||
223 | #else // !NLS | ||
224 | 0, 0, | ||
225 | #endif // NLS | ||
226 | "no"), | ||
227 | #endif // SLIT | ||
228 | |||
229 | #ifdef ORDEREDPSEUDO | ||
230 | i18n->getMessage( | ||
231 | #ifdef NLS | ||
232 | CommonSet, CommonYes, | ||
233 | #else // !NLS | ||
234 | 0, 0, | ||
235 | #endif // NLS | ||
236 | "yes") | ||
237 | #else // !ORDEREDPSEUDO | ||
238 | i18n->getMessage( | ||
239 | #ifdef NLS | ||
240 | CommonSet, CommonNo, | ||
241 | #else // !NLS | ||
242 | 0, 0, | ||
243 | #endif // NLS | ||
244 | "no") | ||
245 | #endif // ORDEREDPSEUDO | ||
246 | |||
247 | ); | ||
248 | |||
249 | ::exit(0); | ||
250 | } | ||
251 | } | ||
252 | |||
253 | #ifdef __EMX__ | ||
254 | _chdir2(getenv("X11ROOT")); | ||
255 | #endif // __EMX__ | 199 | #endif // __EMX__ |
256 | Fluxbox *fluxbox=0; | 200 | Fluxbox *fluxbox=0; |
257 | int exitcode=EXIT_SUCCESS; | 201 | int exitcode=EXIT_SUCCESS; |
258 | try { | 202 | try { |
259 | 203 | ||
260 | fluxbox = new Fluxbox(argc, argv, session_display, rc_file); | 204 | fluxbox = new Fluxbox(argc, argv, session_display, rc_file); |
261 | fluxbox->eventLoop(); | 205 | fluxbox->eventLoop(); |
262 | 206 | ||
263 | } catch (int _exitcode) { | 207 | } catch (int _exitcode) { |
@@ -268,5 +212,5 @@ int main(int argc, char **argv) { | |||
268 | 212 | ||
269 | if (fluxbox) | 213 | if (fluxbox) |
270 | delete fluxbox; | 214 | delete fluxbox; |
271 | exit(exitcode); | 215 | exit(exitcode); |
272 | } | 216 | } |