-#ifdef HAVE_SYS_SIGNAL_H
-# include <sys/signal.h>
-#endif // HAVE_SYS_SIGNAL_H
-
-#ifdef HAVE_SYS_STAT_H
-# include <sys/types.h>
-# include <sys/stat.h>
-#endif // HAVE_SYS_STAT_H
-
-#ifdef TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else // !TIME_WITH_SYS_TIME
-# ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-# else // !HAVE_SYS_TIME_H
-# include <time.h>
-# endif // HAVE_SYS_TIME_H
-#endif // TIME_WITH_SYS_TIME
-
-#ifdef HAVE_LIBGEN_H
-# include <libgen.h>
-#endif // HAVE_LIBGEN_H
-
-#ifndef HAVE_BASENAME
-static inline char *basename (char *s) {
- char *save = s;
-
- while (*s) if (*s++ == '/') save = s;
-
- return save;
-}
-#endif // HAVE_BASENAME
-
-
-// X event scanner for enter/leave notifies - adapted from twm
-typedef struct scanargs {
- Window w;
- Bool leave, inferior, enter;
-} scanargs;
-
-static Bool queueScanner(Display *, XEvent *e, char *args) {
- if ((e->type == LeaveNotify) &&
- (e->xcrossing.window == ((scanargs *) args)->w) &&
- (e->xcrossing.mode == NotifyNormal)) {
- ((scanargs *) args)->leave = True;
- ((scanargs *) args)->inferior = (e->xcrossing.detail == NotifyInferior);
- } else if ((e->type == EnterNotify) &&
- (e->xcrossing.mode == NotifyUngrab)) {
- ((scanargs *) args)->enter = True;
- }
-
- return False;
-}
-
-Openbox *openbox;
-
-
-Openbox::Openbox(int m_argc, char **m_argv, char *dpy_name, char *rc)
- : BaseDisplay(m_argv[0], dpy_name) {
- grab();
-
- if (! XSupportsLocale())
- fprintf(stderr, "X server does not support locale\n");
-
- if (XSetLocaleModifiers("") == NULL)
- fprintf(stderr, "cannot set locale modifiers\n");
-
- ::openbox = this;
- argc = m_argc;
- argv = m_argv;
- if (rc == NULL) {
- char *homedir = getenv("HOME");
-
- rc_file = new char[strlen(homedir) + strlen("/.openbox/rc") + 1];
- sprintf(rc_file, "%s/.openbox", homedir);
-
- // try to make sure the ~/.openbox directory exists
- mkdir(rc_file, S_IREAD | S_IWRITE | S_IEXEC | S_IRGRP | S_IWGRP | S_IXGRP |
- S_IROTH | S_IWOTH | S_IXOTH);
-
- sprintf(rc_file, "%s/.openbox/rc", homedir);
- } else {
- rc_file = bstrdup(rc);
- }
- config.setFile(rc_file);
-
- no_focus = False;
-
- resource.menu_file = resource.style_file = NULL;
- resource.titlebar_layout = NULL;
- resource.auto_raise_delay.tv_sec = resource.auto_raise_delay.tv_usec = 0;
-
- current_screen = (BScreen *) 0;
- masked_window = (OpenboxWindow *) 0;
- masked = None;
-
- load();
-
-#ifdef HAVE_GETPID
- openbox_pid = XInternAtom(getXDisplay(), "_BLACKBOX_PID", False);
-#endif // HAVE_GETPID
-
- for (unsigned int s = 0; s < getNumberOfScreens(); s++) {
- BScreen *screen = new BScreen(*this, s, config);
-
- if (! screen->isScreenManaged()) {
- delete screen;
- continue;
- }
-
- screenList.push_back(screen);
- }
-
- if (screenList.empty()) {
- fprintf(stderr,
- i18n->getMessage(openboxSet, openboxNoManagableScreens,
- "Openbox::Openbox: no managable screens found, aborting.\n"));
- ::exit(3);
- }
- current_screen = screenList.front();
-
- // save current settings and default values
- save();
-
- XSynchronize(getXDisplay(), False);
- XSync(getXDisplay(), False);
-
- reconfigure_wait = reread_menu_wait = False;
-
- timer = new BTimer(*this, *this);
- timer->setTimeout(0);
- timer->fireOnce(True);
-
- ungrab();
-
- focusWindow(0);
-}
-
-
-Openbox::~Openbox() {
- for_each(screenList.begin(), screenList.end(),
- PointerAssassin());
-
- for_each(menuTimestamps.begin(), menuTimestamps.end(),
- PointerAssassin());
-
- if (resource.menu_file)
- delete [] resource.menu_file;
-
- if (resource.style_file)
- delete [] resource.style_file;
-
- if (resource.titlebar_layout)
- delete [] resource.titlebar_layout;