]>
Dogcows Code - chaz/openbox/blob - openbox/openbox.c
8 #include "extensions.h"
15 #include "clientwrap.h"
16 #include "openboxwrap.h"
19 #include "../render/render.h"
24 #ifdef HAVE_SYS_SELECT_H
25 # include <sys/select.h>
33 #ifdef HAVE_SYS_WAIT_H
34 # include <sys/types.h>
35 # include <sys/wait.h>
41 #include <X11/cursorfont.h>
43 Display
*ob_display
= NULL
;
47 gboolean ob_shutdown
= FALSE
;
48 gboolean ob_restart
= FALSE
;
49 char *ob_restart_path
= NULL
;
50 gboolean ob_remote
= FALSE
;
51 gboolean ob_sync
= TRUE
;
54 void signal_handler(int signal
);
56 int main(int argc
, char **argv
)
58 struct sigaction action
;
61 ob_state
= State_Starting
;
63 /* initialize the locale */
64 if (!setlocale(LC_ALL
, ""))
65 g_warning("Couldn't set locale from environment.\n");
66 bindtextdomain(PACKAGE
, LOCALEDIR
);
67 bind_textdomain_codeset(PACKAGE
, "UTF-8");
70 /* set up signal handler */
72 action
.sa_handler
= signal_handler
;
73 action
.sa_mask
= sigset
;
74 action
.sa_flags
= SA_NOCLDSTOP
| SA_NODEFER
;
75 sigaction(SIGUSR1
, &action
, (struct sigaction
*) NULL
);
76 sigaction(SIGPIPE
, &action
, (struct sigaction
*) NULL
);
77 sigaction(SIGSEGV
, &action
, (struct sigaction
*) NULL
);
78 sigaction(SIGFPE
, &action
, (struct sigaction
*) NULL
);
79 sigaction(SIGTERM
, &action
, (struct sigaction
*) NULL
);
80 sigaction(SIGINT
, &action
, (struct sigaction
*) NULL
);
81 sigaction(SIGHUP
, &action
, (struct sigaction
*) NULL
);
82 sigaction(SIGCHLD
, &action
, (struct sigaction
*) NULL
);
84 /* anything that died while we were restarting won't give us a SIGCHLD */
85 while (waitpid(-1, NULL
, WNOHANG
) > 0);
87 /* XXX parse out command line args */
88 (void)argc
;(void)argv
;
90 ob_display
= XOpenDisplay(NULL
);
91 if (ob_display
== NULL
) {
92 /* print a message and exit */
93 g_critical("Failed to open the display.");
96 if (fcntl(ConnectionNumber(ob_display
), F_SETFD
, 1) == -1) {
97 /* print a message and exit */
98 g_critical("Failed to set display as close-on-exec.");
102 ob_screen
= DefaultScreen(ob_display
);
103 ob_root
= RootWindow(ob_display
, ob_screen
);
105 /* XXX fork self onto other screens */
107 XSynchronize(ob_display
, ob_sync
);
109 /* check for locale support */
110 if (!XSupportsLocale())
111 g_warning("X server does not support locale.");
112 if (!XSetLocaleModifiers(""))
113 g_warning("Cannot set locale modifiers for the X server.");
115 /* set our error handler */
116 XSetErrorHandler(xerror_handler
);
118 /* set the DISPLAY environment variable for any lauched children, to the
119 display we're using, so they open in the right place. */
120 putenv(g_strdup_printf("DISPLAY=%s", DisplayString(ob_display
)));
122 ob_cursors
.left_ptr
= XCreateFontCursor(ob_display
, XC_left_ptr
);
123 ob_cursors
.ll_angle
= XCreateFontCursor(ob_display
, XC_ll_angle
);
124 ob_cursors
.lr_angle
= XCreateFontCursor(ob_display
, XC_lr_angle
);
126 prop_startup(); /* get atoms values for the display */
127 extensions_query_all(); /* find which extensions are present */
129 if (screen_annex()) { /* it will be ours! */
133 engine_startup(themerc_engine
);
135 openboxwrap_startup();
136 clientwrap_startup();
145 /* load the user's settings */
146 if (!python_import("rc"))
147 g_warning("ERROR LOADING RC FILE");
149 HOOKFIRE(startup
, "()");
151 /* get all the existing windows */
154 ob_state
= State_Running
;
155 while (!ob_shutdown
) {
158 ob_state
= State_Exiting
;
160 client_unmanage_all();
162 HOOKFIRE(shutdown
, "()");
170 clientwrap_shutdown();
171 openboxwrap_shutdown();
179 XCloseDisplay(ob_display
);
181 /* XXX if (ob_restart) */
186 void signal_handler(int signal
)
190 g_message("Caught SIGUSR1 signal. Restarting.");
191 ob_shutdown
= ob_restart
= TRUE
;
202 g_message("Caught signal %d. Exiting.", signal
);
208 g_error("Caught signal %d. Aborting and dumping core.", signal
);
This page took 0.040019 seconds and 4 git commands to generate.