]> icculus.org git repositories - dana/openbox.git/blob - src/main.cc
compiles now. uses xft2
[dana/openbox.git] / src / main.cc
1 // -*- mode: C++; indent-tabs-mode: nil; -*-
2 // main.cc for Blackbox - an X11 Window manager
3 // Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
4 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a
7 // copy of this software and associated documentation files (the "Software"),
8 // to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 // and/or sell copies of the Software, and to permit persons to whom the
11 // Software is furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 // DEALINGS IN THE SOFTWARE.
23
24 #include "../version.h"
25
26 #ifdef    HAVE_CONFIG_H
27 #  include "../config.h"
28 #endif // HAVE_CONFIG_H
29
30 extern "C" {
31 #ifdef    HAVE_STDIO_H
32 #  include <stdio.h>
33 #endif // HAVE_STDIO_H
34
35 #ifdef HAVE_STDLIB_H
36 #  include <stdlib.h>
37 #endif // HAVE_STDLIB_H
38
39 #ifdef HAVE_STRING_H
40 #  include <string.h>
41 #endif // HAVE_STRING_H
42
43 #ifdef    HAVE_UNISTD_H
44 #include <sys/types.h>
45 #endif // HAVE_UNISTD_H
46
47 #ifdef    HAVE_SYS_PARAM_H
48 #  include <sys/param.h>
49 #endif // HAVE_SYS_PARAM_H
50 }
51
52 #include <string>
53 using std::string;
54
55 #include "blackbox.hh"
56
57
58 static void showHelp(int exitval) {
59   // print program usage and command line options
60   printf("Openbox %s : (c) 2002 - 2002 Ben Jansens\n"
61          "  -display <string>\t\tuse display connection.\n"
62          "  -rc <string>\t\t\tuse alternate resource file.\n"
63          "  -menu <string>\t\tuse alternate menu file.\n"
64          "  -version\t\t\tdisplay version and exit.\n"
65          "  -help\t\t\t\tdisplay this help text and exit.\n\n",
66          OPENBOX_VERSION);
67
68   // some people have requested that we print out compile options
69   // as well
70   printf("Compile time options:\n"
71          "  Debugging:\t\t\t%s\n"
72          "  Shape:\t\t\t%s\n"
73          "  Xft:\t\t\t\t%s\n"
74          "  Xinerama:\t\t\t%s\n"
75          "  8bpp Ordered Dithering:\t%s\n\n",
76 #ifdef    DEBUG
77          "yes",
78 #else // !DEBUG
79          "no",
80 #endif // DEBUG
81
82 #ifdef    SHAPE
83          "yes",
84 #else // !SHAPE
85          "no",
86 #endif // SHAPE
87
88 #ifdef    XFT
89          "yes",
90 #else // !XFT
91          "no",
92 #endif // XFT
93
94 #ifdef    XINERAMA
95          "yes",
96 #else // !XINERAMA
97          "no",
98 #endif // XINERAMA
99
100 #ifdef    ORDEREDPSEUDO
101          "yes"
102 #else // !ORDEREDPSEUDO
103          "no"
104 #endif // ORDEREDPSEUDO
105           );
106
107   ::exit(exitval);
108 }
109
110 int main(int argc, char **argv) {
111   char *session_display = (char *) 0;
112   char *rc_file = (char *) 0;
113   char *menu_file = (char *) 0;
114
115   for (int i = 1; i < argc; ++i) {
116     if (! strcmp(argv[i], "-rc")) {
117       // look for alternative rc file to use
118
119       if ((++i) >= argc) {
120         fprintf(stderr, "error: '-rc' requires and argument\n");
121
122         ::exit(1);
123       }
124
125       rc_file = argv[i];
126     } else if (! strcmp(argv[i], "-menu")) {
127       // look for alternative menu file to use
128
129       if ((++i) >= argc) {
130         fprintf(stderr, "error: '-menu' requires and argument\n");
131
132         ::exit(1);
133       }
134
135       menu_file = argv[i];
136     } else if (! strcmp(argv[i], "-display")) {
137       // check for -display option... to run on a display other than the one
138       // set by the environment variable DISPLAY
139
140       if ((++i) >= argc) {
141         fprintf(stderr, "error: '-display' requires an argument\n");
142
143         ::exit(1);
144       }
145
146       session_display = argv[i];
147       string dtmp = "DISPLAY=";
148       dtmp += session_display;
149
150       if (putenv(const_cast<char*>(dtmp.c_str()))) {
151         fprintf(stderr,
152                 "warning: couldn't set environment variable 'DISPLAY'\n");
153         perror("putenv()");
154       }
155     } else if (! strcmp(argv[i], "-version")) {
156       // print current version string
157       printf("Openbox %s : (c) 2002 - 2002 Ben Jansens\n",
158              OPENBOX_VERSION);
159
160       ::exit(0);
161     } else if (! strcmp(argv[i], "-help")) {
162       showHelp(0);
163     } else { // invalid command line option
164       showHelp(-1);
165     }
166   }
167
168 #ifdef    __EMX__
169   _chdir2(getenv("X11ROOT"));
170 #endif // __EMX__
171
172   Blackbox blackbox(argv, session_display, rc_file);
173   blackbox.eventLoop();
174
175   return(0);
176 }