-
- // fall back in case the above execlp doesn't work
- execvp(argv[0], argv);
- execvp(basename(argv[0]), argv);
-}
-
-
-void Openbox::shutdown(void) {
- BaseDisplay::shutdown();
-
- XSetInputFocus(getXDisplay(), PointerRoot, None, CurrentTime);
-
- LinkedListIterator<BScreen> it(screenList);
- for (BScreen *s = it.current(); s; it++, s = it.current())
- s->shutdown();
-
- XSync(getXDisplay(), False);
-
- save_rc();
-}
-
-
-void Openbox::save_rc(void) {
- config.setAutoSave(false);
-
- config.setValue("session.menuFile", getMenuFilename());
- config.setValue("session.colorsPerChannel",
- resource.colors_per_channel);
- config.setValue("session.doubleClickInterval",
- (long)resource.double_click_interval);
- config.setValue("session.autoRaiseDelay",
- ((resource.auto_raise_delay.tv_sec * 1000) +
- (resource.auto_raise_delay.tv_usec / 1000)));
- config.setValue("session.cacheLife", (long)resource.cache_life / 60000);
- config.setValue("session.cacheMax", (long)resource.cache_max);
-
- LinkedListIterator<BScreen> it(screenList);
- for (BScreen *screen = it.current(); screen; it++, screen = it.current()) {
-// ScreenList::iterator it = screenList.begin();
-// for (; it != screenList.end(); ++it) {
-// BScreen *screen = *it;
- char rc_string[1024];
- const int screen_number = screen->getScreenNumber();
-
- char *placement = (char *) 0;
-
- switch (screen->getSlitPlacement()) {
- case Slit::TopLeft: placement = "TopLeft"; break;
- case Slit::CenterLeft: placement = "CenterLeft"; break;
- case Slit::BottomLeft: placement = "BottomLeft"; break;
- case Slit::TopCenter: placement = "TopCenter"; break;
- case Slit::BottomCenter: placement = "BottomCenter"; break;
- case Slit::TopRight: placement = "TopRight"; break;
- case Slit::BottomRight: placement = "BottomRight"; break;
- case Slit::CenterRight: default: placement = "CenterRight"; break;
- }
- sprintf(rc_string, "session.screen%d.slit.placement", screen_number);
- config.setValue(rc_string, placement);
-
- sprintf(rc_string, "session.screen%d.slit.direction", screen_number);
- config.setValue(rc_string,
- screen->getSlitDirection() == Slit::Horizontal ?
- "Horizontal" : "Vertical");
-
- sprintf(rc_string, "session.screen%d.slit.onTop", screen_number);
- config.setValue(rc_string, screen->getSlit()->isOnTop() ? "True" : "False");
-
- sprintf(rc_string, "session.screen%d.slit.autoHide", screen_number);
- config.setValue(rc_string, screen->getSlit()->doAutoHide() ?
- "True" : "False");
-
- config.setValue("session.opaqueMove",
- (screen->doOpaqueMove()) ? "True" : "False");
- config.setValue("session.imageDither",
- (screen->getImageControl()->doDither()) ? "True" : "False");
-
- sprintf(rc_string, "session.screen%d.fullMaximization", screen_number);
- config.setValue(rc_string, screen->doFullMax() ? "True" : "False");
-
- sprintf(rc_string, "session.screen%d.focusNewWindows", screen_number);
- config.setValue(rc_string, screen->doFocusNew() ? "True" : "False");
-
- sprintf(rc_string, "session.screen%d.focusLastWindow", screen_number);
- config.setValue(rc_string, screen->doFocusLast() ? "True" : "False");
-
- sprintf(rc_string, "session.screen%d.rowPlacementDirection", screen_number);
- config.setValue(rc_string,
- screen->getRowPlacementDirection() == BScreen::LeftRight ?
- "LeftToRight" : "RightToLeft");
-
- sprintf(rc_string, "session.screen%d.colPlacementDirection", screen_number);
- config.setValue(rc_string,
- screen->getColPlacementDirection() == BScreen::TopBottom ?
- "TopToBottom" : "BottomToTop");
-
- switch (screen->getPlacementPolicy()) {
- case BScreen::CascadePlacement: placement = "CascadePlacement"; break;
- case BScreen::ColSmartPlacement: placement = "ColSmartPlacement"; break;
- default:
- case BScreen::RowSmartPlacement: placement = "RowSmartPlacement"; break;
- }
- sprintf(rc_string, "session.screen%d.windowPlacement", screen_number);
- config.setValue(rc_string, placement);
-
- sprintf(rc_string, "session.screen%d.focusModel", screen_number);
- config.setValue(rc_string,
- (screen->isSloppyFocus() ?
- (screen->doAutoRaise() ? "AutoRaiseSloppyFocus" :
- "SloppyFocus") : "ClickToFocus"));
-
- sprintf(rc_string, "session.screen%d.workspaces", screen_number);
- config.setValue(rc_string, screen->getWorkspaceCount());
-
- sprintf(rc_string, "session.screen%d.toolbar.onTop", screen_number);
- config.setValue(rc_string, screen->getToolbar()->isOnTop() ?
- "True" : "False");
-
- sprintf(rc_string, "session.screen%d.toolbar.autoHide", screen_number);
- config.setValue(rc_string, screen->getToolbar()->doAutoHide() ?
- "True" : "False");
-
- switch (screen->getToolbarPlacement()) {
- case Toolbar::TopLeft: placement = "TopLeft"; break;
- case Toolbar::BottomLeft: placement = "BottomLeft"; break;
- case Toolbar::TopCenter: placement = "TopCenter"; break;
- case Toolbar::TopRight: placement = "TopRight"; break;
- case Toolbar::BottomRight: placement = "BottomRight"; break;
- default:
- case Toolbar::BottomCenter: placement = "BottomCenter"; break;
- }
-
- sprintf(rc_string, "session.screen%d.toolbar.placement", screen_number);
- config.setValue(rc_string, placement);
-
-#ifdef HAVE_STRFTIME
- sprintf(rc_string, "session.screen%d.strftimeFormat", screen_number);
- config.setValue(rc_string, screen->getStrftimeFormat());
-#else // !HAVE_STRFTIME
- sprintf(rc_string, "session.screen%d.dateFormat", screen_number);
- config.setValue(rc_string, screen->getDateFormat() == B_EuropeanDate ?
- "European" : "American");
-
- sprintf(rc_string, "session.screen%d.clockFormat", screen_number);
- config.setValue(rc_string, screen->isClock24Hour() ? 24 : 12);
-#endif // HAVE_STRFTIME
-
- sprintf(rc_string, "session.screen%d.edgeSnapThreshold", screen_number);
- config.setValue(rc_string, screen->getEdgeSnapThreshold());
-
- sprintf(rc_string, "session.screen%d.toolbar.widthPercent", screen_number);
- config.setValue(rc_string, screen->getToolbarWidthPercent());
-
- // write out the user's workspace names
- int i, len = 0;
- for (i = 0; i < screen->getWorkspaceCount(); i++)
- len += strlen((screen->getWorkspace(i)->getName()) ?
- screen->getWorkspace(i)->getName() : "Null") + 1;
-
- char *resource_string = new char[len + 1024],
- *save_string = new char[len], *save_string_pos = save_string,
- *name_string_pos;
- if (save_string) {
- for (i = 0; i < screen->getWorkspaceCount(); i++) {
- len = strlen((screen->getWorkspace(i)->getName()) ?
- screen->getWorkspace(i)->getName() : "Null") + 1;
- name_string_pos =
- (char *) ((screen->getWorkspace(i)->getName()) ?
- screen->getWorkspace(i)->getName() : "Null");
-
- while (--len) *(save_string_pos++) = *(name_string_pos++);
- *(save_string_pos++) = ',';
- }
- }
-
- *(--save_string_pos) = '\0';
-
- sprintf(resource_string, "session.screen%d.workspaceNames", screen_number);
- config.setValue(resource_string, save_string);
-
- delete [] resource_string;
- delete [] save_string;
-/*
- std::string save_string = screen->getWorkspace(0)->getName();
- for (unsigned int i = 1; i < screen->getWorkspaceCount(); ++i) {
- save_string += ',';
- save_string += screen->getWorkspace(i)->getName();
- }
-
- char *resource_string = new char[save_string.length() + 48];
- sprintf(resource_string, "session.screen%d.workspaceNames", screen_number);
- config.setValue(rc_string, save_string);
-
- delete [] resource_string;*/
- }
-
- config.setAutoSave(true);
- config.save();
-}
-
-void Openbox::load_rc(void) {
- if (!config.load())
- return;
-
- std::string s;
- long l;
-
- if (resource.menu_file)
- delete [] resource.menu_file;
- if (config.getValue("session.menuFile", "Session.MenuFile", s))
- resource.menu_file = bstrdup(s.c_str());
- else
- resource.menu_file = bstrdup(DEFAULTMENU);
-
- if (config.getValue("session.colorsPerChannel", "Session.ColorsPerChannel",
- l))
- resource.colors_per_channel = (l < 2 ? 2 : (l > 6 ? 6 : l)); // >= 2, <= 6
- else
- resource.colors_per_channel = 4;
-
- if (resource.style_file)
- delete [] resource.style_file;
- if (config.getValue("session.styleFile", "Session.StyleFile", s))
- resource.style_file = bstrdup(s.c_str());
- else
- resource.style_file = bstrdup(DEFAULTSTYLE);
-
- if (resource.titlebar_layout)
- delete [] resource.titlebar_layout;
- if (config.getValue("session.titlebarLayout", "Session.TitlebarLayout", s))
- resource.titlebar_layout = bstrdup(s.c_str());
- else
- resource.titlebar_layout = bstrdup("ILMC");
-
- if (config.getValue("session.doubleClickInterval",
- "Session.DoubleClickInterval", l))
- resource.double_click_interval = l;
- else
- resource.double_click_interval = 250;
-
- if (!config.getValue("session.autoRaiseDelay", "Session.AutoRaiseDelay", l))
- resource.auto_raise_delay.tv_usec = l;
- else
- resource.auto_raise_delay.tv_usec = 400;
- resource.auto_raise_delay.tv_sec = resource.auto_raise_delay.tv_usec / 1000;
- resource.auto_raise_delay.tv_usec -=
- (resource.auto_raise_delay.tv_sec * 1000);
- resource.auto_raise_delay.tv_usec *= 1000;
-
- if (config.getValue("session.cacheLife", "Session.CacheLife", l))
- resource.cache_life = l;
- else
- resource.cache_life = 51;
- resource.cache_life *= 60000;
-
- if (config.getValue("session.cacheMax", "Session.CacheMax", l))
- resource.cache_max = l;
- else
- resource.cache_max = 200;
-}
-
-
-void Openbox::load_rc(BScreen *screen) {
- assert (screen != NULL);
- const int screen_number = screen->getScreenNumber();
- assert (screen_number >= 0);
-
- if (!config.load())
- return;
-