- }
-}
-
-
-void Openbox::load_rc(BScreen *screen) {
- XrmDatabase database = (XrmDatabase) 0;
-
- database = XrmGetFileDatabase(rc_file);
-
- XrmValue value;
- char *value_type, name_lookup[1024], class_lookup[1024];
- int screen_number = screen->getScreenNumber();
-
- sprintf(name_lookup, "session.screen%d.fullMaximization", screen_number);
- sprintf(class_lookup, "Session.Screen%d.FullMaximization", screen_number);
- if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
- &value)) {
- if (! strncasecmp(value.addr, "true", value.size))
- screen->saveFullMax(True);
- else
- screen->saveFullMax(False);
- } else {
- screen->saveFullMax(False);
- }
- sprintf(name_lookup, "session.screen%d.focusNewWindows", screen_number);
- sprintf(class_lookup, "Session.Screen%d.FocusNewWindows", screen_number);
- if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
- &value)) {
- if (! strncasecmp(value.addr, "true", value.size))
- screen->saveFocusNew(True);
- else
- screen->saveFocusNew(False);
- } else {
- screen->saveFocusNew(False);
- }
- sprintf(name_lookup, "session.screen%d.focusLastWindow", screen_number);
- sprintf(class_lookup, "Session.Screen%d.focusLastWindow", screen_number);
- if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
- &value)) {
- if (! strncasecmp(value.addr, "true", value.size))
- screen->saveFocusLast(True);
- else
- screen->saveFocusLast(False);
- } else {
- screen->saveFocusLast(False);
- }
- sprintf(name_lookup, "session.screen%d.rowPlacementDirection",
- screen_number);
- sprintf(class_lookup, "Session.Screen%d.RowPlacementDirection",
- screen_number);
- if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
- &value)) {
- if (! strncasecmp(value.addr, "righttoleft", value.size))
- screen->saveRowPlacementDirection(BScreen::RightLeft);
- else
- screen->saveRowPlacementDirection(BScreen::LeftRight);
- } else {
- screen->saveRowPlacementDirection(BScreen::LeftRight);
- }
- sprintf(name_lookup, "session.screen%d.colPlacementDirection",
- screen_number);
- sprintf(class_lookup, "Session.Screen%d.ColPlacementDirection",
- screen_number);
- if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
- &value)) {
- if (! strncasecmp(value.addr, "bottomtotop", value.size))
- screen->saveColPlacementDirection(BScreen::BottomTop);
- else
- screen->saveColPlacementDirection(BScreen::TopBottom);
- } else {
- screen->saveColPlacementDirection(BScreen::TopBottom);
- }
- sprintf(name_lookup, "session.screen%d.workspaces", screen_number);
- sprintf(class_lookup, "Session.Screen%d.Workspaces", screen_number);
- if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
- &value)) {
- int i;
- if (sscanf(value.addr, "%d", &i) != 1) i = 1;
- screen->saveWorkspaces(i);
- } else {
- screen->saveWorkspaces(1);
- }
- sprintf(name_lookup, "session.screen%d.toolbar.widthPercent",
- screen_number);
- sprintf(class_lookup, "Session.Screen%d.Toolbar.WidthPercent",
- screen_number);
- if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
- &value)) {
- int i;
- if (sscanf(value.addr, "%d", &i) != 1) i = 66;
-
- if (i <= 0 || i > 100)
- i = 66;
-
- screen->saveToolbarWidthPercent(i);
- } else {
- screen->saveToolbarWidthPercent(66);
- }
- sprintf(name_lookup, "session.screen%d.toolbar.placement", screen_number);
- sprintf(class_lookup, "Session.Screen%d.Toolbar.Placement", screen_number);
- if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
- &value)) {
- if (! strncasecmp(value.addr, "TopLeft", value.size))
- screen->saveToolbarPlacement(Toolbar::TopLeft);
- else if (! strncasecmp(value.addr, "BottomLeft", value.size))
- screen->saveToolbarPlacement(Toolbar::BottomLeft);
- else if (! strncasecmp(value.addr, "TopCenter", value.size))
- screen->saveToolbarPlacement(Toolbar::TopCenter);
- else if (! strncasecmp(value.addr, "TopRight", value.size))
- screen->saveToolbarPlacement(Toolbar::TopRight);
- else if (! strncasecmp(value.addr, "BottomRight", value.size))
- screen->saveToolbarPlacement(Toolbar::BottomRight);
- else
- screen->saveToolbarPlacement(Toolbar::BottomCenter);
- } else {
- screen->saveToolbarPlacement(Toolbar::BottomCenter);
- }
- screen->removeWorkspaceNames();
-
- sprintf(name_lookup, "session.screen%d.workspaceNames", screen_number);
- sprintf(class_lookup, "Session.Screen%d.WorkspaceNames", screen_number);
- if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
- &value)) {
- char *search = bstrdup(value.addr);
-
- for (int i = 0; i < screen->getNumberOfWorkspaces(); i++) {
- char *nn;
-
- if (! i) nn = strtok(search, ",");
- else nn = strtok(NULL, ",");
-
- if (nn) screen->addWorkspaceName(nn);
- else break;
- }
-
- delete [] search;
- }
-
- sprintf(name_lookup, "session.screen%d.toolbar.onTop", screen_number);
- sprintf(class_lookup, "Session.Screen%d.Toolbar.OnTop", screen_number);
- if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
- &value)) {
- if (! strncasecmp(value.addr, "true", value.size))
- screen->saveToolbarOnTop(True);
- else
- screen->saveToolbarOnTop(False);
- } else {
- screen->saveToolbarOnTop(False);
- }
- sprintf(name_lookup, "session.screen%d.toolbar.autoHide", screen_number);
- sprintf(class_lookup, "Session.Screen%d.Toolbar.autoHide", screen_number);
- if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
- &value)) {
- if (! strncasecmp(value.addr, "true", value.size))
- screen->saveToolbarAutoHide(True);
- else
- screen->saveToolbarAutoHide(False);
- } else {
- screen->saveToolbarAutoHide(False);
- }
- sprintf(name_lookup, "session.screen%d.focusModel", screen_number);
- sprintf(class_lookup, "Session.Screen%d.FocusModel", screen_number);
- if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
- &value)) {
- if (! strncasecmp(value.addr, "clicktofocus", value.size)) {
- screen->saveAutoRaise(False);
- screen->saveSloppyFocus(False);
- } else if (! strncasecmp(value.addr, "autoraisesloppyfocus", value.size)) {
- screen->saveSloppyFocus(True);
- screen->saveAutoRaise(True);
- } else {
- screen->saveSloppyFocus(True);
- screen->saveAutoRaise(False);
- }
- } else {
- screen->saveSloppyFocus(True);
- screen->saveAutoRaise(False);
- }
-
- sprintf(name_lookup, "session.screen%d.windowZones", screen_number);
- sprintf(class_lookup, "Session.Screen%d.WindowZones", screen_number);
- if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
- &value)) {
- int i = atoi(value.addr);
- screen->saveWindowZones((i == 1 || i == 2 || i == 4) ? i : 1);
- } else {
- screen->saveWindowZones(1);
- }
-
- sprintf(name_lookup, "session.screen%d.windowPlacement", screen_number);
- sprintf(class_lookup, "Session.Screen%d.WindowPlacement", screen_number);
- if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
- &value)) {
- if (! strncasecmp(value.addr, "RowSmartPlacement", value.size))
- screen->savePlacementPolicy(BScreen::RowSmartPlacement);
- else if (! strncasecmp(value.addr, "ColSmartPlacement", value.size))
- screen->savePlacementPolicy(BScreen::ColSmartPlacement);
- else
- screen->savePlacementPolicy(BScreen::CascadePlacement);
- } else {
- screen->savePlacementPolicy(BScreen::RowSmartPlacement);
- }
-#ifdef SLIT
- sprintf(name_lookup, "session.screen%d.slit.placement", screen_number);
- sprintf(class_lookup, "Session.Screen%d.Slit.Placement", screen_number);
- if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
- &value)) {
- if (! strncasecmp(value.addr, "TopLeft", value.size))
- screen->saveSlitPlacement(Slit::TopLeft);
- else if (! strncasecmp(value.addr, "CenterLeft", value.size))
- screen->saveSlitPlacement(Slit::CenterLeft);
- else if (! strncasecmp(value.addr, "BottomLeft", value.size))
- screen->saveSlitPlacement(Slit::BottomLeft);
- else if (! strncasecmp(value.addr, "TopCenter", value.size))
- screen->saveSlitPlacement(Slit::TopCenter);
- else if (! strncasecmp(value.addr, "BottomCenter", value.size))
- screen->saveSlitPlacement(Slit::BottomCenter);
- else if (! strncasecmp(value.addr, "TopRight", value.size))
- screen->saveSlitPlacement(Slit::TopRight);
- else if (! strncasecmp(value.addr, "BottomRight", value.size))
- screen->saveSlitPlacement(Slit::BottomRight);
- else
- screen->saveSlitPlacement(Slit::CenterRight);
- } else {
- screen->saveSlitPlacement(Slit::CenterRight);
- }
- sprintf(name_lookup, "session.screen%d.slit.direction", screen_number);
- sprintf(class_lookup, "Session.Screen%d.Slit.Direction", screen_number);
- if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
- &value)) {
- if (! strncasecmp(value.addr, "Horizontal", value.size))
- screen->saveSlitDirection(Slit::Horizontal);
- else
- screen->saveSlitDirection(Slit::Vertical);
- } else {
- screen->saveSlitDirection(Slit::Vertical);
- }
- sprintf(name_lookup, "session.screen%d.slit.onTop", screen_number);
- sprintf(class_lookup, "Session.Screen%d.Slit.OnTop", screen_number);
- if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
- &value)) {
- if (! strncasecmp(value.addr, "True", value.size))
- screen->saveSlitOnTop(True);
- else
- screen->saveSlitOnTop(False);
- } else {
- screen->saveSlitOnTop(False);
- }
- sprintf(name_lookup, "session.screen%d.slit.autoHide", screen_number);
- sprintf(class_lookup, "Session.Screen%d.Slit.AutoHide", screen_number);
- if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
- &value)) {
- if (! strncasecmp(value.addr, "True", value.size))
- screen->saveSlitAutoHide(True);
- else
- screen->saveSlitAutoHide(False);
- } else {
- screen->saveSlitAutoHide(False);
- }
-#endif // SLIT
-
-#ifdef HAVE_STRFTIME
- sprintf(name_lookup, "session.screen%d.strftimeFormat", screen_number);
- sprintf(class_lookup, "Session.Screen%d.StrftimeFormat", screen_number);
- if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
- &value)) {
- screen->saveStrftimeFormat(value.addr);
- } else {
- screen->saveStrftimeFormat("%I:%M %p");
- }
-#else // HAVE_STRFTIME
- sprintf(name_lookup, "session.screen%d.dateFormat", screen_number);
- sprintf(class_lookup, "Session.Screen%d.DateFormat", screen_number);
- if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
- &value)) {
- if (strncasecmp(value.addr, "european", value.size))
- screen->saveDateFormat(B_AmericanDate);
- else
- screen->saveDateFormat(B_EuropeanDate);
- } else {
- screen->saveDateFormat(B_AmericanDate);
- }
- sprintf(name_lookup, "session.screen%d.clockFormat", screen_number);
- sprintf(class_lookup, "Session.Screen%d.ClockFormat", screen_number);
- if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
- &value)) {
- int clock;
- if (sscanf(value.addr, "%d", &clock) != 1) screen->saveClock24Hour(False);
- else if (clock == 24) screen->saveClock24Hour(True);
- else screen->saveClock24Hour(False);
- } else {
- screen->saveClock24Hour(False);
- }
-#endif // HAVE_STRFTIME
-
- sprintf(name_lookup, "session.screen%d.edgeSnapThreshold", screen_number);
- sprintf(class_lookup, "Session.Screen%d.EdgeSnapThreshold", screen_number);
- if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
- &value)) {
- int threshold;
- if (sscanf(value.addr, "%d", &threshold) != 1)
- screen->saveEdgeSnapThreshold(0);
- else
- screen->saveEdgeSnapThreshold(threshold);
- } else {
- screen->saveEdgeSnapThreshold(0);
- }
- sprintf(name_lookup, "session.screen%d.imageDither", screen_number);
- sprintf(class_lookup, "Session.Screen%d.ImageDither", screen_number);
- if (XrmGetResource(database, "session.imageDither", "Session.ImageDither",
- &value_type, &value)) {
- if (! strncasecmp("true", value.addr, value.size))
- screen->saveImageDither(True);
- else
- screen->saveImageDither(False);
- } else {
- screen->saveImageDither(True);
- }
-
- sprintf(name_lookup, "session.screen%d.rootCommand", screen_number);
- sprintf(class_lookup, "Session.Screen%d.RootCommand", screen_number);
- if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
- &value)) {
- screen->saveRootCommand(value.addr);
- } else
- screen->saveRootCommand(NULL);
-
- if (XrmGetResource(database, "session.opaqueMove", "Session.OpaqueMove",
- &value_type, &value)) {
- if (! strncasecmp("true", value.addr, value.size))
- screen->saveOpaqueMove(True);
- else
- screen->saveOpaqueMove(False);
- } else {
- screen->saveOpaqueMove(False);
- }
- XrmDestroyDatabase(database);