on start, the config file is read entirely off the disc, and missing values are assigned defaults.
the config file is immediately written back to the disk to populate missing defaults in the file.
any time a config option is changed the control, the config file is re-written with the change.
choosing reconfig will reload the current config file on the disc.
on shutdown, nothing is written to the config file.
Changelog for Openbox:
1.0.0:
+ * better handling of teh rc file and its configuration
+ options. The file is written each time an option in
+ the file is changed, instead of being written at
+ shutdown. This means that you can edit the file by
+ hand while in Openbox, and then choose reconfig or
+ restart to have it use the new rc file. (Ben Jansens)
+
* added a runtime option for hiding the toolbar. (Scott Moynes)
* made shaded windows edge-snap correctly to the
update();
setItemSelected(2, screen.getImageControl()->doDither());
- setItemSelected(3, screen.doOpaqueMove());
- setItemSelected(4, screen.doFullMax());
- setItemSelected(5, screen.doFocusNew());
- setItemSelected(6, screen.doFocusLast());
+ setItemSelected(3, screen.opaqueMove());
+ setItemSelected(4, screen.fullMax());
+ setItemSelected(5, screen.focusNew());
+ setItemSelected(6, screen.focusLast());
setItemSelected(7, screen.hideToolbar());
}
}
case 2: { // opaque move
- screen.saveOpaqueMove((! screen.doOpaqueMove()));
+ screen.setOpaqueMove(!screen.opaqueMove());
- setItemSelected(index, screen.doOpaqueMove());
+ setItemSelected(index, screen.opaqueMove());
break;
}
case 3: { // full maximization
- screen.saveFullMax((! screen.doFullMax()));
+ screen.setFullMax(!screen.fullMax());
- setItemSelected(index, screen.doFullMax());
+ setItemSelected(index, screen.fullMax());
break;
}
case 4: { // focus new windows
- screen.saveFocusNew((! screen.doFocusNew()));
+ screen.setFocusNew(!screen.focusNew());
- setItemSelected(index, screen.doFocusNew());
+ setItemSelected(index, screen.focusNew());
break;
}
case 5: { // focus last window on workspace
- screen.saveFocusLast(!(screen.doFocusLast()));
- setItemSelected(index, screen.doFocusLast());
+ screen.setFocusLast(!screen.focusLast());
+ setItemSelected(index, screen.focusLast());
break;
}
case 6:{ //toggle toolbar hide
"Auto Raise"), 3);
update();
- setItemSelected(0, (! configmenu->screen.isSloppyFocus()));
- setItemSelected(1, configmenu->screen.isSloppyFocus());
- setItemEnabled(2, configmenu->screen.isSloppyFocus());
- setItemSelected(2, configmenu->screen.doAutoRaise());
+ setItemSelected(0, !configmenu->screen.sloppyFocus());
+ setItemSelected(1, configmenu->screen.sloppyFocus());
+ setItemEnabled(2, configmenu->screen.sloppyFocus());
+ setItemSelected(2, configmenu->screen.autoRaise());
}
void Configmenu::Focusmenu::itemSelected(int button, int index) {
switch (item->function()) {
case 1: // click to focus
- configmenu->screen.saveSloppyFocus(False);
- configmenu->screen.saveAutoRaise(False);
+ configmenu->screen.setSloppyFocus(false);
+ configmenu->screen.setAutoRaise(false);
if (! configmenu->screen.getOpenbox().getFocusedWindow())
XSetInputFocus(configmenu->screen.getOpenbox().getXDisplay(),
break;
case 2: // sloppy focus
- configmenu->screen.saveSloppyFocus(True);
+ configmenu->screen.setSloppyFocus(true);
configmenu->screen.reconfigure();
break;
case 3: // auto raise with sloppy focus
- Bool change = ((configmenu->screen.doAutoRaise()) ? False : True);
- configmenu->screen.saveAutoRaise(change);
+ bool change = ((configmenu->screen.autoRaise()) ? false : true);
+ configmenu->screen.setAutoRaise(change);
break;
}
- setItemSelected(0, (! configmenu->screen.isSloppyFocus()));
- setItemSelected(1, configmenu->screen.isSloppyFocus());
- setItemEnabled(2, configmenu->screen.isSloppyFocus());
- setItemSelected(2, configmenu->screen.doAutoRaise());
+ setItemSelected(0, !configmenu->screen.sloppyFocus());
+ setItemSelected(1, configmenu->screen.sloppyFocus());
+ setItemEnabled(2, configmenu->screen.sloppyFocus());
+ setItemSelected(2, configmenu->screen.autoRaise());
}
Configmenu::Placementmenu::Placementmenu(Configmenu *cm) :
"Bottom to Top"), BScreen::BottomTop);
update();
- switch (configmenu->screen.getPlacementPolicy()) {
+ switch (configmenu->screen.placementPolicy()) {
case BScreen::RowSmartPlacement:
setItemSelected(0, True);
break;
break;
}
- Bool rl = (configmenu->screen.getRowPlacementDirection() ==
+ Bool rl = (configmenu->screen.rowPlacementDirection() ==
BScreen::LeftRight),
- tb = (configmenu->screen.getColPlacementDirection() ==
+ tb = (configmenu->screen.colPlacementDirection() ==
BScreen::TopBottom);
setItemSelected(4, rl);
- setItemSelected(5, ! rl);
+ setItemSelected(5, !rl);
setItemSelected(6, tb);
- setItemSelected(7, ! tb);
+ setItemSelected(7, !tb);
}
void Configmenu::Placementmenu::itemSelected(int button, int index) {
switch (item->function()) {
case BScreen::RowSmartPlacement:
- configmenu->screen.savePlacementPolicy(item->function());
+ configmenu->screen.setPlacementPolicy(item->function());
setItemSelected(0, True);
setItemSelected(1, False);
break;
case BScreen::ColSmartPlacement:
- configmenu->screen.savePlacementPolicy(item->function());
+ configmenu->screen.setPlacementPolicy(item->function());
setItemSelected(0, False);
setItemSelected(1, True);
break;
case BScreen::CascadePlacement:
- configmenu->screen.savePlacementPolicy(item->function());
+ configmenu->screen.setPlacementPolicy(item->function());
setItemSelected(0, False);
setItemSelected(1, False);
break;
case BScreen::BestFitPlacement:
- configmenu->screen.savePlacementPolicy(item->function());
+ configmenu->screen.setPlacementPolicy(item->function());
setItemSelected(0, False);
setItemSelected(1, False);
break;
case BScreen::LeftRight:
- configmenu->screen.saveRowPlacementDirection(BScreen::LeftRight);
+ configmenu->screen.setRowPlacementDirection(BScreen::LeftRight);
setItemSelected(4, True);
setItemSelected(5, False);
break;
case BScreen::RightLeft:
- configmenu->screen.saveRowPlacementDirection(BScreen::RightLeft);
+ configmenu->screen.setRowPlacementDirection(BScreen::RightLeft);
setItemSelected(4, False);
setItemSelected(5, True);
break;
case BScreen::TopBottom:
- configmenu->screen.saveColPlacementDirection(BScreen::TopBottom);
+ configmenu->screen.setColPlacementDirection(BScreen::TopBottom);
setItemSelected(5, True);
setItemSelected(6, False);
break;
case BScreen::BottomTop:
- configmenu->screen.saveColPlacementDirection(BScreen::BottomTop);
+ configmenu->screen.setColPlacementDirection(BScreen::BottomTop);
setItemSelected(5, False);
setItemSelected(6, True);
BScreen::BScreen(Openbox &ob, int scrn, Resource &conf) : ScreenInfo(ob, scrn),
openbox(ob), config(conf)
{
+ // default values
+ resource.full_max = false;
+ resource.focus_new = false;
+ resource.focus_last = false;
+ resource.row_direction = LeftRight;
+ resource.col_direction = TopBottom;
+ resource.workspaces = 1;
+ resource.sloppy_focus = true;
+ resource.auto_raise = false;
+ resource.zones = 1;
+ resource.placement_policy = CascadePlacement;
+#ifdef HAVE_STRFTIME
+ resource.strftime_format = bstrdup("%I:%M %p");
+#else // !have_strftime
+ resource.date_format = B_AmericanDate;
+ resource.clock24hour = false;
+#endif // HAVE_STRFTIME
+ resource.edge_snap_threshold = 4;
+ resource.image_dither = true;
+ resource.root_command = NULL;
+ resource.opaque_move = false;
+
event_mask = ColormapChangeMask | EnterWindowMask | PropertyChangeMask |
SubstructureRedirectMask | KeyPressMask | KeyReleaseMask |
ButtonPressMask | ButtonReleaseMask;
resource.tstyle.fontset = resource.wstyle.fontset = (XFontSet) 0;
resource.mstyle.t_font = resource.mstyle.f_font = resource.tstyle.font =
resource.wstyle.font = (XFontStruct *) 0;
- resource.root_command = NULL;
-
-#ifdef HAVE_STRFTIME
- resource.strftime_format = 0;
-#endif // HAVE_STRFTIME
#ifdef HAVE_GETPID
pid_t bpid = getpid();
openbox.getSessionCursor());
workspaceNames = new LinkedList<char>;
+
+ load(); // load config options from Resources
+
workspacesList = new LinkedList<Workspace>;
rootmenuList = new LinkedList<Rootmenu>;
netizenList = new LinkedList<Netizen>;
image_control->installRootColormap();
root_colormap_installed = True;
- openbox.load_rc(this);
-
image_control->setDither(resource.image_dither);
LoadStyle();
for (int i = 0; i < resource.workspaces; ++i) {
wkspc = new Workspace(*this, workspacesList->count());
workspacesList->insert(wkspc);
+ saveWorkspaceNames();
workspacemenu->insert(wkspc->getName(), wkspc->getMenu());
}
} else {
wkspc = new Workspace(*this, workspacesList->count());
workspacesList->insert(wkspc);
+ saveWorkspaceNames();
workspacemenu->insert(wkspc->getName(), wkspc->getMenu());
}
return fs;
}
+void BScreen::setSloppyFocus(bool b) {
+ resource.sloppy_focus = b;
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".focusModel" << ends;
+ config.setValue(s.str(),
+ (resource.sloppy_focus ?
+ (resource.auto_raise ? "AutoRaiseSloppyFocus" : "SloppyFocus")
+ : "ClickToFocus"));
+}
+
+void BScreen::setAutoRaise(bool a) {
+ resource.auto_raise = a;
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".focusModel" << ends;
+ config.setValue(s.str(),
+ (resource.sloppy_focus ?
+ (resource.auto_raise ? "AutoRaiseSloppyFocus" : "SloppyFocus")
+ : "ClickToFocus"));
+}
+
+void BScreen::setImageDither(bool d) {
+ resource.image_dither = d;
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".imageDither" << ends;
+ config.setValue(s.str(), resource.image_dither);
+}
+
+void BScreen::setOpaqueMove(bool o) {
+ resource.opaque_move = o;
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".opaqueMove" << ends;
+ config.setValue(s.str(), resource.opaque_move);
+}
+
+void BScreen::setFullMax(bool f) {
+ resource.full_max = f;
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".fullMaximization" << ends;
+ config.setValue(s.str(), resource.full_max);
+}
+
+void BScreen::setFocusNew(bool f) {
+ resource.focus_new = f;
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".focusNewWindows" << ends;
+ config.setValue(s.str(), resource.focus_new);
+}
+
+void BScreen::setFocusLast(bool f) {
+ resource.focus_last = f;
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".focusLastWindow" << ends;
+ config.setValue(s.str(), resource.focus_last);
+}
+
+void BScreen::setWindowZones(int z) {
+ resource.zones = z;
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".windowZones" << ends;
+ config.setValue(s.str(), resource.zones);
+}
+
+void BScreen::setWorkspaceCount(int w) {
+ resource.workspaces = w;
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".workspaces" << ends;
+ config.setValue(s.str(), resource.workspaces);
+}
+
+void BScreen::setPlacementPolicy(int p) {
+ resource.placement_policy = p;
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".windowPlacement" << ends;
+ const char *placement;
+ switch (resource.placement_policy) {
+ case CascadePlacement: placement = "CascadePlacement"; break;
+ case BestFitPlacement: placement = "BestFitPlacement"; break;
+ case ColSmartPlacement: placement = "ColSmartPlacement"; break;
+ default:
+ case RowSmartPlacement: placement = "RowSmartPlacement"; break;
+ }
+ config.setValue(s.str(), placement);
+}
+
+void BScreen::setEdgeSnapThreshold(int t) {
+ resource.edge_snap_threshold = t;
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".edgeSnapThreshold" << ends;
+ config.setValue(s.str(), resource.edge_snap_threshold);
+}
+
+void BScreen::setRowPlacementDirection(int d) {
+ resource.row_direction = d;
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".rowPlacementDirection" <<
+ ends;
+ config.setValue(s.str(),
+ resource.row_direction == LeftRight ?
+ "LeftToRight" : "RightToLeft");
+}
+
+void BScreen::setColPlacementDirection(int d) {
+ resource.col_direction = d;
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".colPlacementDirection" <<
+ ends;
+ config.setValue(s.str(),
+ resource.col_direction == TopBottom ?
+ "TopToBottom" : "BottomToTop");
+}
+
+void BScreen::setRootCommand(const char *cmd) {
+if (resource.root_command != NULL)
+ delete [] resource.root_command;
+ if (cmd != NULL)
+ resource.root_command = bstrdup(cmd);
+ else
+ resource.root_command = NULL;
+ // this doesn't save to the Resources config because it can't be changed
+ // inside Openbox, and this way we dont add an empty command which would over-
+ // ride the styles commend when none has been specified
+}
+#ifdef HAVE_STRFTIME
+void BScreen::setStrftimeFormat(const char *f) {
+ if (resource.strftime_format != NULL)
+ delete [] resource.strftime_format;
+
+ resource.strftime_format = bstrdup(f);
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".strftimeFormat" << ends;
+ config.setValue(s.str(), resource.strftime_format);
+}
+
+#else // !HAVE_STRFTIME
+void BScreen::setDateFormat(int f) {
+ resource.date_format = f;
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".dateFormat" << ends;
+ config.setValue(s.str(), resource.date_format == B_EuropeanDate ?
+ "European" : "American");
+}
+
+void BScreen::setClock24Hour(Bool c) {
+ resource.clock24hour = c;
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".clockFormat" << ends;
+ config.setValue(s.str(), resource.clock24hour ? 24 : 12);
+}
+#endif // HAVE_STRFTIME
+
+void BScreen::setHideToolbar(bool b) {
+ resource.hide_toolbar = b;
+ if (resource.hide_toolbar)
+ getToolbar()->unMapToolbar();
+ else
+ getToolbar()->mapToolbar();
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".hideToolbar" << ends;
+ config.setValue(s.str(), resource.hide_toolbar ? "True" : "False");
+}
+
+void BScreen::saveWorkspaceNames() {
+ ostrstream rc, names;
+
+ for (int i = 0; i < resource.workspaces; i++) {
+ Workspace *w = getWorkspace(i);
+ if (w != NULL) {
+ names << w->getName();
+ if (i < resource.workspaces-1)
+ names << ',';
+ }
+ }
+ names << ends;
+
+ rc << "session.screen" << getScreenNumber() << ".workspaceNames" << ends;
+ config.setValue(rc.str(), names.str());
+}
+
+void BScreen::save() {
+ setSloppyFocus(resource.sloppy_focus);
+ setAutoRaise(resource.auto_raise);
+ setImageDither(resource.image_dither);
+ setOpaqueMove(resource.opaque_move);
+ setFullMax(resource.full_max);
+ setFocusNew(resource.focus_new);
+ setFocusLast(resource.focus_last);
+ setWindowZones(resource.zones);
+ setWorkspaceCount(resource.workspaces);
+ setPlacementPolicy(resource.placement_policy);
+ setEdgeSnapThreshold(resource.edge_snap_threshold);
+ setRowPlacementDirection(resource.row_direction);
+ setColPlacementDirection(resource.col_direction);
+ setRootCommand(resource.root_command);
+#ifdef HAVE_STRFTIME
+ // it deletes the current value before setting the new one, so we have to
+ // duplicate the current value.
+ setStrftimeFormat(bstrdup(resource.strftime_format));
+#else // !HAVE_STRFTIME
+ setDateFormat(resource.date_format);
+ setClock24Hour(resource.clock24hour);
+#endif // HAVE_STRFTIME
+ setHideToolbar(resource.hide_toolbar);
+}
+
void BScreen::load() {
std::ostrstream rscreen, rname, rclass;
std::string s;
if (config.getValue(rname.str(), rclass.str(), b))
resource.hide_toolbar = b;
+ rname.seekp(0); rclass.seekp(0);
+ rname << rscreen.str() << "fullMaximization" << ends;
+ rclass << rscreen.str() << "FullMaximization" << ends;
+ if (config.getValue(rname.str(), rclass.str(), b))
+ resource.full_max = b;
+
+ rname.seekp(0); rclass.seekp(0);
+ rname << rscreen.str() << "focusNewWindows" << ends;
+ rclass << rscreen.str() << "FocusNewWindows" << ends;
+ if (config.getValue(rname.str(), rclass.str(), b))
+ resource.focus_new = b;
+
+ rname.seekp(0); rclass.seekp(0);
+ rname << rscreen.str() << "focusLastWindow" << ends;
+ rclass << rscreen.str() << "FocusLastWindow" << ends;
+ if (config.getValue(rname.str(), rclass.str(), b))
+ resource.focus_last = b;
+
+ rname.seekp(0); rclass.seekp(0);
+ rname << rscreen.str() << "rowPlacementDirection" << ends;
+ rclass << rscreen.str() << "RowPlacementDirection" << ends;
+ if (config.getValue(rname.str(), rclass.str(), s)) {
+ if (0 == strncasecmp(s.c_str(), "RightToLeft", s.length()))
+ resource.row_direction = RightLeft;
+ else if (0 == strncasecmp(s.c_str(), "LeftToRight", s.length()))
+ resource.row_direction = LeftRight;
+ }
+
+ rname.seekp(0); rclass.seekp(0);
+ rname << rscreen.str() << "colPlacementDirection" << ends;
+ rclass << rscreen.str() << "ColPlacementDirection" << ends;
+ if (config.getValue(rname.str(), rclass.str(), s)) {
+ if (0 == strncasecmp(s.c_str(), "BottomToTop", s.length()))
+ resource.col_direction = BottomTop;
+ else if (0 == strncasecmp(s.c_str(), "TopToBottom", s.length()))
+ resource.col_direction = TopBottom;
+ }
+
+ rname.seekp(0); rclass.seekp(0);
+ rname << rscreen.str() << "workspaces" << ends;
+ rclass << rscreen.str() << "Workspaces" << ends;
+ if (config.getValue(rname.str(), rclass.str(), l))
+ resource.workspaces = l;
+
+ removeWorkspaceNames();
+ rname.seekp(0); rclass.seekp(0);
+ rname << rscreen.str() << "workspaceNames" << ends;
+ rclass << rscreen.str() << "WorkspaceNames" << ends;
+ if (config.getValue(rname.str(), rclass.str(), s)) {
+ std::string::const_iterator it = s.begin(), end = s.end();
+ while(1) {
+ std::string::const_iterator tmp = it;// current string.begin()
+ it = std::find(tmp, end, ','); // look for comma between tmp and end
+ std::string name(tmp, it); // name = s[tmp:it]
+ addWorkspaceName(name.c_str());
+ if (it == end)
+ break;
+ ++it;
+ }
+ }
+
+ rname.seekp(0); rclass.seekp(0);
+ rname << rscreen.str() << "focusModel" << ends;
+ rclass << rscreen.str() << "FocusModel" << ends;
+ if (config.getValue(rname.str(), rclass.str(), s)) {
+ if (0 == strncasecmp(s.c_str(), "ClickToFocus", s.length())) {
+ resource.auto_raise = false;
+ resource.sloppy_focus = false;
+ } else if (0 == strncasecmp(s.c_str(), "AutoRaiseSloppyFocus",
+ s.length())) {
+ resource.sloppy_focus = true;
+ resource.auto_raise = true;
+ } else if (0 == strncasecmp(s.c_str(), "SloppyFocus", s.length())) {
+ resource.sloppy_focus = true;
+ resource.auto_raise = false;
+ }
+ }
+
+ rname.seekp(0); rclass.seekp(0);
+ rname << rscreen.str() << "windowZones" << ends;
+ rclass << rscreen.str() << "WindowZones" << ends;
+ if (config.getValue(rname.str(), rclass.str(), l))
+ resource.zones = (l == 1 || l == 2 || l == 4) ? l : 1;
+
+ rname.seekp(0); rclass.seekp(0);
+ rname << rscreen.str() << "windowPlacement" << ends;
+ rclass << rscreen.str() << "WindowPlacement" << ends;
+ if (config.getValue(rname.str(), rclass.str(), s)) {
+ if (0 == strncasecmp(s.c_str(), "RowSmartPlacement", s.length()))
+ resource.placement_policy = RowSmartPlacement;
+ else if (0 == strncasecmp(s.c_str(), "ColSmartPlacement", s.length()))
+ resource.placement_policy = ColSmartPlacement;
+ else if (0 == strncasecmp(s.c_str(), "BestFitPlacement", s.length()))
+ resource.placement_policy = BestFitPlacement;
+ else if (0 == strncasecmp(s.c_str(), "CascadePlacement", s.length()))
+ resource.placement_policy = CascadePlacement;
+ }
+
+#ifdef HAVE_STRFTIME
+ rname.seekp(0); rclass.seekp(0);
+ rname << rscreen.str() << "strftimeFormat" << ends;
+ rclass << rscreen.str() << "StrftimeFormat" << ends;
+ if (config.getValue(rname.str(), rclass.str(), s))
+ resource.strftime_format = bstrdup(s.c_str());
+#else // !HAVE_STRFTIME
+ rname.seekp(0); rclass.seekp(0);
+ rname << rscreen.str() << "dateFormat" << ends;
+ rclass << rscreen.str() << "DateFormat" << ends;
+ if (config.getValue(rname.str(), rclass.str(), s)) {
+ if (strncasecmp(s.c_str(), "European", s.length()))
+ resource.date_format = B_EuropeanDate;
+ else if (strncasecmp(s.c_str(), "American", s.length()))
+ resource.date_format = B_AmericanDate;
+ }
+
+ rname.seekp(0); rclass.seekp(0);
+ rname << rscreen.str() << "clockFormat" << ends;
+ rclass << rscreen.str() << "ClockFormat" << ends;
+ if (config.getValue(rname.str(), rclass.str(), l)) {
+ if (clock == 24)
+ resource.clock24hour = true;
+ else if (clock == 12)
+ resource.clock24hour = false;
+#endif // HAVE_STRFTIME
+
+ rname.seekp(0); rclass.seekp(0);
+ rname << rscreen.str() << "edgeSnapThreshold" << ends;
+ rclass << rscreen.str() << "EdgeSnapThreshold" << ends;
+ if (config.getValue(rname.str(), rclass.str(), l))
+ resource.edge_snap_threshold = l;
+
+ rname.seekp(0); rclass.seekp(0);
+ rname << rscreen.str() << "imageDither" << ends;
+ rclass << rscreen.str() << "ImageDither" << ends;
+ if (config.getValue(rname.str(), rclass.str(), b))
+ resource.image_dither = b;
+
+ rname.seekp(0); rclass.seekp(0);
+ rname << rscreen.str() << "rootCommand" << ends;
+ rclass << rscreen.str() << "RootCommand" << ends;
+ if (config.getValue(rname.str(), rclass.str(), s))
+ resource.root_command = bstrdup(s.c_str());
+
+ rname.seekp(0); rclass.seekp(0);
+ rname << rscreen.str() << "opaqueMove" << ends;
+ rclass << rscreen.str() << "OpaqueMove" << ends;
+ resource.opaque_move = b;
}
void BScreen::reconfigure(void) {
void BScreen::removeWorkspaceNames(void) {
while (workspaceNames->count())
- delete [] workspaceNames->remove(0);
+ delete [] workspaceNames->remove(0);
}
int BScreen::addWorkspace(void) {
Workspace *wkspc = new Workspace(*this, workspacesList->count());
workspacesList->insert(wkspc);
+ saveWorkspaceNames();
workspacemenu->insert(wkspc->getName(), wkspc->getMenu(),
wkspc->getWorkspaceID() + 2);
}
-#ifdef HAVE_STRFTIME
-void BScreen::saveStrftimeFormat(const char *format) {
- if (resource.strftime_format)
- delete [] resource.strftime_format;
-
- resource.strftime_format = bstrdup(format);
-}
-#endif // HAVE_STRFTIME
-
-
void BScreen::addWorkspaceName(const char *name) {
workspaceNames->insert(bstrdup(name));
}
-
char* BScreen::getNameOfWorkspace(int id) {
char *name = (char *) 0;
geom_visible = False;
}
}
-
-void BScreen::setHideToolbar(bool b) {
- resource.hide_toolbar = b;
- if (resource.hide_toolbar)
- getToolbar()->unMapToolbar();
- else
- getToolbar()->mapToolbar();
- ostrstream s;
- s << "session.screen" << getScreenNumber() << ".hideToolbar" << ends;
- config.setValue(s.str(), resource.hide_toolbar ? "True" : "False");
-}
-
ToolbarStyle tstyle;
MenuStyle mstyle;
- Bool sloppy_focus, auto_raise,
- auto_edge_balance, image_dither, ordered_dither, opaque_move, full_max,
- focus_new, focus_last;
- bool hide_toolbar;
+ bool sloppy_focus, auto_raise, auto_edge_balance, image_dither, focus_last,
+ ordered_dither, opaque_move, hide_toolbar, full_max, focus_new;
BColor border_color;
Resource styleconfig;
- int workspaces, toolbar_placement, toolbar_width_percent, placement_policy,
- edge_snap_threshold, row_direction, col_direction;
+ int workspaces, placement_policy, edge_snap_threshold, row_direction,
+ col_direction;
unsigned int handle_width, bevel_width, frame_width, border_width;
- unsigned int zones; // number of zones to be used when alt-resizing a window
+ int zones; // number of zones to be used when alt-resizing a window
#ifdef HAVE_STRFTIME
char *strftime_format;
#else // !HAVE_STRFTIME
- Bool clock24hour;
+ bool clock24hour;
int date_format;
#endif // HAVE_STRFTIME
BScreen(Openbox &, int, Resource &);
~BScreen();
- inline const Bool &isSloppyFocus() const
- { return resource.sloppy_focus; }
- inline const Bool &isRootColormapInstalled() const
- { return root_colormap_installed; }
- inline const Bool &doAutoRaise() const { return resource.auto_raise; }
inline const Bool &isScreenManaged() const { return managed; }
- inline const Bool &doImageDither() const
- { return resource.image_dither; }
- inline const Bool &doOrderedDither() const
- { return resource.ordered_dither; }
- inline const Bool &doOpaqueMove() const { return resource.opaque_move; }
- inline const Bool &doFullMax() const { return resource.full_max; }
- inline const Bool &doFocusNew() const { return resource.focus_new; }
- inline const Bool &doFocusLast() const { return resource.focus_last; }
-
inline const GC &getOpGC() const { return opGC; }
inline Openbox &getOpenbox() { return openbox; }
inline Slit *getSlit() { return slit; }
#endif // SLIT
- inline int getWindowZones() const
- { return resource.zones; }
- inline void saveWindowZones(int z) { resource.zones = z; }
-
inline Toolbar *getToolbar() { return toolbar; }
inline Workspace *getWorkspace(int w) { return workspacesList->find(w); }
inline Workspace *getCurrentWorkspace() { return current_workspace; }
inline Workspacemenu *getWorkspacemenu() { return workspacemenu; }
+
+ inline void iconUpdate() { iconmenu->update(); }
inline const unsigned int &getHandleWidth() const
{ return resource.handle_width; }
{ return current_workspace->getWorkspaceID(); }
inline const int getWorkspaceCount() { return workspacesList->count(); }
inline const int getIconCount() { return iconList->count(); }
- inline const int &getNumberOfWorkspaces() const
- { return resource.workspaces; }
- inline const int &getPlacementPolicy() const
- { return resource.placement_policy; }
- inline const int &getEdgeSnapThreshold() const
- { return resource.edge_snap_threshold; }
- inline const int &getRowPlacementDirection() const
- { return resource.row_direction; }
- inline const int &getColPlacementDirection() const
- { return resource.col_direction; }
-
- inline void saveRootCommand(const char *cmd) {
- if (resource.root_command != NULL)
- delete [] resource.root_command;
- if (cmd != NULL)
- resource.root_command = bstrdup(cmd);
- else
- resource.root_command = NULL;
- }
- inline const char *getRootCommand() const
- { return resource.root_command; }
-
+
+ inline const Bool &isRootColormapInstalled() const
+ { return root_colormap_installed; }
inline void setRootColormapInstalled(Bool r) { root_colormap_installed = r; }
- inline void saveSloppyFocus(Bool s) { resource.sloppy_focus = s; }
- inline void saveAutoRaise(Bool a) { resource.auto_raise = a; }
- inline void saveWorkspaces(int w) { resource.workspaces = w; }
- inline void savePlacementPolicy(int p) { resource.placement_policy = p; }
- inline void saveRowPlacementDirection(int d) { resource.row_direction = d; }
- inline void saveColPlacementDirection(int d) { resource.col_direction = d; }
- inline void saveEdgeSnapThreshold(int t)
- { resource.edge_snap_threshold = t; }
- inline void saveImageDither(Bool d) { resource.image_dither = d; }
- inline void saveOpaqueMove(Bool o) { resource.opaque_move = o; }
- inline void saveFullMax(Bool f) { resource.full_max = f; }
- inline void saveFocusNew(Bool f) { resource.focus_new = f; }
- inline void saveFocusLast(Bool f) { resource.focus_last = f; }
- inline void iconUpdate() { iconmenu->update(); }
+
+ inline bool sloppyFocus() const { return resource.sloppy_focus; }
+ void setSloppyFocus(bool s);
+
+ inline bool autoRaise() const { return resource.auto_raise; }
+ void setAutoRaise(bool a);
+
+ inline bool imageDither() const { return resource.image_dither; }
+ void setImageDither(bool d);
+
+ inline bool orderedDither() const { return resource.ordered_dither; }
+
+ inline bool opaqueMove() const { return resource.opaque_move; }
+ void setOpaqueMove(bool o);
+
+ inline bool fullMax() const { return resource.full_max; }
+ void setFullMax(bool f);
+
+ inline bool focusNew() const { return resource.focus_new; }
+ void setFocusNew(bool f);
+
+ inline bool focusLast() const { return resource.focus_last; }
+ void setFocusLast(bool f);
+
+ inline int getWindowZones() const { return resource.zones; }
+ void setWindowZones(int z);
+
+ inline int workspaceCount() const { return resource.workspaces; }
+ void setWorkspaceCount(int w);
+
+ inline int placementPolicy() const { return resource.placement_policy; }
+ void setPlacementPolicy(int p);
+
+ inline int edgeSnapThreshold() const { return resource.edge_snap_threshold; }
+ void setEdgeSnapThreshold(int t);
+
+ inline int rowPlacementDirection() const { return resource.row_direction; }
+ void setRowPlacementDirection(int d);
+
+ inline int colPlacementDirection() const { return resource.col_direction; }
+ void setColPlacementDirection(int d);
+
+ inline char *rootCommand() const { return resource.root_command; }
+ inline void setRootCommand(const char *cmd);
+
#ifdef HAVE_STRFTIME
- inline char *getStrftimeFormat() { return resource.strftime_format; }
- void saveStrftimeFormat(const char *);
+ inline char *strftimeFormat() { return resource.strftime_format; }
+ void setStrftimeFormat(const char *);
#else // !HAVE_STRFTIME
- inline int getDateFormat() { return resource.date_format; }
- inline void saveDateFormat(int f) { resource.date_format = f; }
- inline Bool isClock24Hour() { return resource.clock24hour; }
- inline void saveClock24Hour(Bool c) { resource.clock24hour = c; }
+ inline int dateFormat() { return resource.date_format; }
+ void setDateFormat(int f);
+ inline bool clock24Hour() { return resource.clock24hour; }
+ void setClock24Hour(Bool c);
#endif // HAVE_STRFTIME
inline bool hideToolbar() const { return resource.hide_toolbar; }
void removeWorkspaceNames();
void addWorkspaceName(const char *);
+ void saveWorkspaceNames();
void addNetizen(Netizen *);
void removeNetizen(Window);
void addIcon(OpenboxWindow *);
void raiseFocus();
void reconfigure();
void load();
+ void save();
void rereadMenu();
void shutdown();
void showPosition(int, int);
m_direction == Horizontal ? "Horizontal" : "Vertical");
}
+void Slit::save() {
+ setOnTop(m_ontop);
+ setAutoHide(m_autohide);
+ setPlacement(m_placement);
+ setDirection(m_direction);
+}
+
void Slit::load() {
std::ostrstream rscreen, rname, rclass;
std::string s;
void removeClient(Window, Bool = True);
void reconfigure();
void load();
+ void save();
void reposition();
void shutdown();
config.setValue(s.str(), placement);
}
+void Toolbar::save() {
+ setOnTop(m_ontop);
+ setAutoHide(m_autohide);
+ setWidthPercent(m_width_percent);
+ setPlacement(m_placement);
+}
+
void Toolbar::load() {
std::ostrstream rscreen, rname, rclass;
std::string s;
tt = localtime(&ttmp);
if (tt) {
char t[1025], *time_string = (char *) 0;
- int len = strftime(t, 1024, screen.getStrftimeFormat(), tt);
+ int len = strftime(t, 1024, screen.strftimeFormat(), tt);
t[len++-1] = ' '; // add a space to the string for padding
t[len] = '\0';
if (redraw) {
#ifdef HAVE_STRFTIME
char t[1024];
- if (! strftime(t, 1024, screen.getStrftimeFormat(), tt))
+ if (! strftime(t, 1024, screen.strftimeFormat(), tt))
return;
#else // !HAVE_STRFTIME
char t[9];
return;
XSetInputFocus(display, frame.workspace_label,
- ((screen.isSloppyFocus()) ? RevertToPointerRoot :
+ ((screen.sloppyFocus()) ? RevertToPointerRoot :
RevertToParent),
CurrentTime);
XClearWindow(display, frame.workspace_label);
void edit();
void reconfigure();
void load();
+ void save();
void mapToolbar();
void unMapToolbar();
#ifdef HAVE_STRFTIME
associateClientWindow();
- if (! screen->isSloppyFocus())
+ if (! screen->sloppyFocus())
openbox.grabButton(Button1, 0, frame.plate, True, ButtonPressMask,
GrabModeSync, GrabModeSync, None, None);
configure(frame.x, frame.y, frame.width, frame.height);
- if (! screen->isSloppyFocus())
+ if (! screen->sloppyFocus())
openbox.grabButton(Button1, 0, frame.plate, True, ButtonPressMask,
GrabModeSync, GrabModeSync, None, None);
else
XSendEvent(display, client.window, False, NoEventMask, &ce);
}
- if (screen->isSloppyFocus() && screen->doAutoRaise())
+ if (screen->sloppyFocus() && screen->autoRaise())
timer->start();
ret = True;
XMapSubwindows(display, frame.window);
XMapWindow(display, frame.window);
- if (flags.iconic && screen->doFocusNew()) setInputFocus();
+ if (flags.iconic && screen->focusNew()) setInputFocus();
flags.visible = True;
flags.iconic = False;
dh -= client.base_height;
dh -= frame.y_border;
- if (! screen->doFullMax())
+ if (! screen->fullMax())
dh -= screen->getToolbar()->getExposedHeight() + frame.border_w;
if (dw < client.min_width) dw = client.min_width;
dx += ((screen->size().w() - dw) / 2) - frame.border_w;
- if (screen->doFullMax()) {
+ if (screen->fullMax()) {
dy += ((screen->size().h() - dh) / 2) - frame.border_w;
} else {
dy += (((screen->size().h() - screen->getToolbar()->getExposedHeight())
XSetWindowBorder(display, frame.plate, frame.uborder_pixel);
}
- if (screen->isSloppyFocus() && screen->doAutoRaise() && timer->isTiming())
+ if (screen->sloppyFocus() && screen->autoRaise() && timer->isTiming())
timer->stop();
}
redrawAllButtons();
- if (flags.transient || screen->doFocusNew())
+ if (flags.transient || screen->focusNew())
setInputFocus();
else
setFocusFlag(False);
shade();
}
- if (! (flags.focused || screen->isSloppyFocus()) ) {
+ if (! (flags.focused || screen->sloppyFocus()) ) {
setInputFocus(); // any click focus' the window in 'click to focus'
}
if (stack_change < 0) {
flags.moving = False;
openbox.maskWindowEvents(0, (OpenboxWindow *) 0);
- if (!screen->doOpaqueMove()) {
+ if (!screen->opaqueMove()) {
XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
frame.move_x, frame.move_y, frame.resize_w - 1,
frame.resize_h - 1);
openbox.maskWindowEvents(client.window, this);
- if (! screen->doOpaqueMove()) {
+ if (! screen->opaqueMove()) {
openbox.grab();
frame.move_x = frame.x;
dx -= frame.border_w;
dy -= frame.border_w;
- int snap_distance = screen->getEdgeSnapThreshold();
+ int snap_distance = screen->edgeSnapThreshold();
// width/height of the snapping window
unsigned int snap_w = frame.width + (frame.border_w * 2);
unsigned int snap_h = size().h() + (frame.border_w * 2);
dy = dbby - snap_h;
}
- if (screen->doOpaqueMove()) {
+ if (screen->opaqueMove()) {
configure(dx, dy, frame.width, frame.height);
} else {
XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
if (w->isTransient() && w->getTransientFor() &&
w->getTransientFor()->isVisible()) {
w->getTransientFor()->setInputFocus();
- } else if (screen.isSloppyFocus()) {
+ } else if (screen.sloppyFocus()) {
screen.getOpenbox().setFocusedWindow((OpenboxWindow *) 0);
} else {
OpenboxWindow *top = stackingList->first();
clientmenu->setLabel(name);
clientmenu->update();
+ screen.saveWorkspaceNames();
}
int test_x, test_y, place_x = 0, place_y = 0;
int start_pos = 0;
int change_y =
- ((screen.getColPlacementDirection() == BScreen::TopBottom) ? 1 : -1);
+ ((screen.colPlacementDirection() == BScreen::TopBottom) ? 1 : -1);
int change_x =
- ((screen.getRowPlacementDirection() == BScreen::LeftRight) ? 1 : -1);
+ ((screen.rowPlacementDirection() == BScreen::LeftRight) ? 1 : -1);
int delta_x = 8, delta_y = 8;
LinkedListIterator<OpenboxWindow> it(windowList);
- test_y = (screen.getColPlacementDirection() == BScreen::TopBottom) ?
+ test_y = (screen.colPlacementDirection() == BScreen::TopBottom) ?
start_pos : screen.size().h() - win_size.h() - start_pos;
while(!placed &&
- ((screen.getColPlacementDirection() == BScreen::BottomTop) ?
+ ((screen.colPlacementDirection() == BScreen::BottomTop) ?
test_y > 0 : test_y + win_size.h() < (signed) space.h())) {
- test_x = (screen.getRowPlacementDirection() == BScreen::LeftRight) ?
+ test_x = (screen.rowPlacementDirection() == BScreen::LeftRight) ?
start_pos : space.w() - win_size.w() - start_pos;
while (!placed &&
- ((screen.getRowPlacementDirection() == BScreen::RightLeft) ?
+ ((screen.rowPlacementDirection() == BScreen::RightLeft) ?
test_x > 0 : test_x + win_size.w() < (signed) space.w())) {
placed = true;
int test_x, test_y;
int start_pos = 0;
int change_y =
- ((screen.getColPlacementDirection() == BScreen::TopBottom) ? 1 : -1);
+ ((screen.colPlacementDirection() == BScreen::TopBottom) ? 1 : -1);
int change_x =
- ((screen.getRowPlacementDirection() == BScreen::LeftRight) ? 1 : -1);
+ ((screen.rowPlacementDirection() == BScreen::LeftRight) ? 1 : -1);
int delta_x = 8, delta_y = 8;
LinkedListIterator<OpenboxWindow> it(windowList);
- test_x = (screen.getRowPlacementDirection() == BScreen::LeftRight) ?
+ test_x = (screen.rowPlacementDirection() == BScreen::LeftRight) ?
start_pos : screen.size().w() - win_size.w() - start_pos;
while(!placed &&
- ((screen.getRowPlacementDirection() == BScreen::RightLeft) ?
+ ((screen.rowPlacementDirection() == BScreen::RightLeft) ?
test_x > 0 : test_x + win_size.w() < (signed) space.w())) {
- test_y = (screen.getColPlacementDirection() == BScreen::TopBottom) ?
+ test_y = (screen.colPlacementDirection() == BScreen::TopBottom) ?
start_pos : screen.size().h() - win_size.h() - start_pos;
while(!placed &&
- ((screen.getColPlacementDirection() == BScreen::BottomTop) ?
+ ((screen.colPlacementDirection() == BScreen::BottomTop) ?
test_y > 0 : test_y + win_size.h() < (signed) space.h())){
placed = true;
(screen.getBorderWidth() * 4),
start_pos = 0,
change_y =
- ((screen.getColPlacementDirection() == BScreen::TopBottom) ? 1 : -1),
+ ((screen.colPlacementDirection() == BScreen::TopBottom) ? 1 : -1),
change_x =
- ((screen.getRowPlacementDirection() == BScreen::LeftRight) ? 1 : -1),
+ ((screen.rowPlacementDirection() == BScreen::LeftRight) ? 1 : -1),
delta_x = 8, delta_y = 8;
LinkedListIterator<OpenboxWindow> it(windowList);
win->size().h()+screen.getBorderWidth() * 4);
Point *place = NULL;
- switch (screen.getPlacementPolicy()) {
+ switch (screen.placementPolicy()) {
case BScreen::BestFitPlacement:
place = bestFitPlacement(window_size, space);
break;
menuTimestamps = new LinkedList<MenuTimestamp>;
- load_rc();
+ load();
#ifdef HAVE_GETPID
openbox_pid = XInternAtom(getXDisplay(), "_BLACKBOX_PID", False);
::exit(3);
}
+ // save current settings and default values
+ save();
+
XSynchronize(getXDisplay(), False);
XSync(getXDisplay(), False);
}
-Openbox::~Openbox(void) {
+Openbox::~Openbox() {
while (screenList->count())
delete screenList->remove(0);
(screen = searchScreen(e->xcrossing.window))) {
screen->getImageControl()->installRootColormap();
} else if ((win = searchWindow(e->xcrossing.window))) {
- if (win->getScreen()->isSloppyFocus() &&
+ if (win->getScreen()->sloppyFocus() &&
(! win->isFocused()) && (! no_focus)) {
grab();
Bool Openbox::handleSignal(int sig) {
switch (sig) {
case SIGHUP:
- reconfigure();
- break;
-
case SIGUSR1:
- reload_rc();
+ reconfigure();
break;
case SIGUSR2:
}
-void Openbox::shutdown(void) {
+void Openbox::shutdown() {
BaseDisplay::shutdown();
XSetInputFocus(getXDisplay(), PointerRoot, None, CurrentTime);
s->shutdown();
XSync(getXDisplay(), False);
-
- save_rc();
}
-void Openbox::save_rc(void) {
+void Openbox::save() {
config.setAutoSave(false);
+ // save all values as they are so that the defaults will be written to the rc
+ // file
+
config.setValue("session.menuFile", getMenuFilename());
config.setValue("session.colorsPerChannel",
resource.colors_per_channel);
(resource.auto_raise_delay.tv_usec / 1000)));
config.setValue("session.cacheLife", (long)resource.cache_life / 60000);
config.setValue("session.cacheMax", (long)resource.cache_max);
+ config.setValue("session.styleFile", resource.style_file);
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();
-
- 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");
-
- const char *placement;
- switch (screen->getPlacementPolicy()) {
- case BScreen::CascadePlacement: placement = "CascadePlacement"; break;
- case BScreen::BestFitPlacement: placement = "BestFitPlacement"; 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());
-
-#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());
-
- // 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;*/
+ for (BScreen *s = it.current(); s != NULL; it++, s = it.current()) {
+ s->save();
+ s->getToolbar()->save();
+ s->getSlit()->save();
}
config.setAutoSave(true);
config.save();
}
-void Openbox::load_rc(void) {
+void Openbox::load() {
if (!config.load())
return;
}
-void Openbox::load_rc(BScreen *screen) {
- ASSERT (screen != NULL);
- const int screen_number = screen->getScreenNumber();
- ASSERT (screen_number >= 0);
-
- if (!config.load())
- return;
-
- std::string s;
- long l;
- bool b;
- char name_lookup[1024], class_lookup[1024];
-
- sprintf(name_lookup, "session.screen%d.fullMaximization", screen_number);
- sprintf(class_lookup, "Session.Screen%d.FullMaximization", screen_number);
- if (config.getValue(name_lookup, class_lookup, b))
- screen->saveFullMax((Bool)b);
- else
- screen->saveFullMax(False);
-
- sprintf(name_lookup, "session.screen%d.focusNewWindows", screen_number);
- sprintf(class_lookup, "Session.Screen%d.FocusNewWindows", screen_number);
- if (config.getValue(name_lookup, class_lookup, b))
- screen->saveFocusNew((Bool)b);
- else
- screen->saveFocusNew(False);
-
- sprintf(name_lookup, "session.screen%d.focusLastWindow", screen_number);
- sprintf(class_lookup, "Session.Screen%d.focusLastWindow", screen_number);
- if (config.getValue(name_lookup, class_lookup, b))
- screen->saveFocusLast((Bool)b);
- else
- screen->saveFocusLast(False);
-
- sprintf(name_lookup, "session.screen%d.rowPlacementDirection",
- screen_number);
- sprintf(class_lookup, "Session.Screen%d.RowPlacementDirection",
- screen_number);
- if (config.getValue(name_lookup, class_lookup, s)) {
- if (0 == strncasecmp(s.c_str(), "righttoleft", s.length()))
- 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 (config.getValue(name_lookup, class_lookup, s)) {
- if (0 == strncasecmp(s.c_str(), "bottomtotop", s.length()))
- 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 (config.getValue(name_lookup, class_lookup, l))
- screen->saveWorkspaces(l);
- else
- screen->saveWorkspaces(1);
-
- screen->removeWorkspaceNames();
- sprintf(name_lookup, "session.screen%d.workspaceNames", screen_number);
- sprintf(class_lookup, "Session.Screen%d.WorkspaceNames", screen_number);
- if (config.getValue(name_lookup, class_lookup, s)) {
- // for (int i = 0; i < screen->getNumberOfWorkspaces(); i++) {
- std::string::const_iterator it = s.begin(), end = s.end();
- while(1) {
- std::string::const_iterator tmp = it;// current string.begin()
- it = std::find(tmp, end, ','); // look for comma between tmp and end
- std::string name(tmp, it); // name = s[tmp:it]
- screen->addWorkspaceName(name.c_str());
- if (it == end)
- break;
- ++it;
- }
- }
-
- sprintf(name_lookup, "session.screen%d.focusModel", screen_number);
- sprintf(class_lookup, "Session.Screen%d.FocusModel", screen_number);
- if (config.getValue(name_lookup, class_lookup, s)) {
- if (0 == strncasecmp(s.c_str(), "clicktofocus", s.length())) {
- screen->saveAutoRaise(False);
- screen->saveSloppyFocus(False);
- } else if (0 == strncasecmp(s.c_str(), "autoraisesloppyfocus",
- s.length())) {
- 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 (config.getValue(name_lookup, class_lookup, l))
- screen->saveWindowZones((l == 1 || l == 2 || l == 4) ? l : 1);
- else
- screen->saveWindowZones(1);
-
- sprintf(name_lookup, "session.screen%d.windowPlacement", screen_number);
- sprintf(class_lookup, "Session.Screen%d.WindowPlacement", screen_number);
- if (config.getValue(name_lookup, class_lookup, s)) {
- if (0 == strncasecmp(s.c_str(), "RowSmartPlacement", s.length()))
- screen->savePlacementPolicy(BScreen::RowSmartPlacement);
- else if (0 == strncasecmp(s.c_str(), "ColSmartPlacement", s.length()))
- screen->savePlacementPolicy(BScreen::ColSmartPlacement);
- else if (0 == strncasecmp(s.c_str(), "BestFitPlacement", s.length()))
- screen->savePlacementPolicy(BScreen::BestFitPlacement);
- else
- screen->savePlacementPolicy(BScreen::CascadePlacement);
- } else
- screen->savePlacementPolicy(BScreen::RowSmartPlacement);
-
-#ifdef SLIT
-#endif // SLIT
-
-#ifdef HAVE_STRFTIME
- sprintf(name_lookup, "session.screen%d.strftimeFormat", screen_number);
- sprintf(class_lookup, "Session.Screen%d.StrftimeFormat", screen_number);
- if (config.getValue(name_lookup, class_lookup, s))
- screen->saveStrftimeFormat(s.c_str());
- 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 (config.getValue(name_lookup, class_lookup, s)) {
- if (strncasecmp(s.c_str(), "european", s.length()))
- 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 (config.getValue(name_lookup, class_lookup, l)) {
- 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 (config.getValue(name_lookup, class_lookup, l))
- screen->saveEdgeSnapThreshold(l);
- else
- screen->saveEdgeSnapThreshold(4);
-
- sprintf(name_lookup, "session.screen%d.imageDither", screen_number);
- sprintf(class_lookup, "Session.Screen%d.ImageDither", screen_number);
- if (config.getValue("session.imageDither", "Session.ImageDither", b))
- screen->saveImageDither((Bool)b);
- else
- screen->saveImageDither(True);
-
- sprintf(name_lookup, "session.screen%d.rootCommand", screen_number);
- sprintf(class_lookup, "Session.Screen%d.RootCommand", screen_number);
- if (config.getValue(name_lookup, class_lookup, s))
- screen->saveRootCommand(s.c_str());
- else
- screen->saveRootCommand(NULL);
-
- if (config.getValue("session.opaqueMove", "Session.OpaqueMove", b))
- screen->saveOpaqueMove((Bool)b);
- else
- screen->saveOpaqueMove(False);
-}
-
-
-void Openbox::reload_rc(void) {
- load_rc();
- reconfigure();
-}
-
-
-void Openbox::reconfigure(void) {
+void Openbox::reconfigure() {
reconfigure_wait = True;
if (! timer->isTiming()) timer->start();
}
-void Openbox::real_reconfigure(void) {
+void Openbox::real_reconfigure() {
grab();
- config.load();
- config.setValue("session.styleFile", resource.style_file); // autosave's
+ load();
+ save();
for (int i = 0, n = menuTimestamps->count(); i < n; i++) {
MenuTimestamp *ts = menuTimestamps->remove(0);
}
-void Openbox::checkMenu(void) {
+void Openbox::checkMenu() {
Bool reread = False;
LinkedListIterator<MenuTimestamp> it(menuTimestamps);
for (MenuTimestamp *tmp = it.current(); tmp && (! reread);
}
-void Openbox::rereadMenu(void) {
+void Openbox::rereadMenu() {
reread_menu_wait = True;
if (! timer->isTiming()) timer->start();
}
-void Openbox::real_rereadMenu(void) {
+void Openbox::real_rereadMenu() {
for (int i = 0, n = menuTimestamps->count(); i < n; i++) {
MenuTimestamp *ts = menuTimestamps->remove(0);
}
-void Openbox::timeout(void) {
+void Openbox::timeout() {
if (reconfigure_wait)
real_reconfigure();
public:
DataSearch(Window w, Z *d): window(w), data(d) {}
- inline const Window &getWindow(void) const { return window; }
- inline Z *getData(void) { return data; }
+ inline const Window &getWindow() const { return window; }
+ inline Z *getData() { return data; }
};
protected:
- void load_rc(void);
- void save_rc(void);
- void reload_rc(void);
- void real_rereadMenu(void);
- void real_reconfigure(void);
+ void load();
+ void save();
+ void real_rereadMenu();
+ void real_reconfigure();
virtual void process_event(XEvent *);
public:
Openbox(int, char **, char * = 0, char * = 0);
- virtual ~Openbox(void);
+ virtual ~Openbox();
#ifdef HAVE_GETPID
- inline const Atom &getOpenboxPidAtom(void) const { return openbox_pid; }
+ inline const Atom &getOpenboxPidAtom() const { return openbox_pid; }
#endif // HAVE_GETPID
Basemenu *searchMenu(Window);
OpenboxWindow *searchGroup(Window, OpenboxWindow *);
OpenboxWindow *searchWindow(Window);
- inline OpenboxWindow *getFocusedWindow(void) { return focused_window; }
+ inline OpenboxWindow *getFocusedWindow() { return focused_window; }
BScreen *getScreen(int);
BScreen *searchScreen(Window);
inline Resource &getConfig() {
return config;
}
- inline const Time &getDoubleClickInterval(void) const
+ inline const Time &getDoubleClickInterval() const
{ return resource.double_click_interval; }
- inline const Time &getLastTime(void) const { return last_time; }
+ inline const Time &getLastTime() const { return last_time; }
Toolbar *searchToolbar(Window);
- inline const char *getStyleFilename(void) const
+ inline const char *getStyleFilename() const
{ return resource.style_file; }
- inline const char *getMenuFilename(void) const
+ inline const char *getMenuFilename() const
{ return resource.menu_file; }
- inline const int &getColorsPerChannel(void) const
+ inline const int &getColorsPerChannel() const
{ return resource.colors_per_channel; }
- inline const timeval &getAutoRaiseDelay(void) const
+ inline const timeval &getAutoRaiseDelay() const
{ return resource.auto_raise_delay; }
- inline const char *getTitleBarLayout(void) const
+ inline const char *getTitleBarLayout() const
{ return resource.titlebar_layout; }
- inline const unsigned long &getCacheLife(void) const
+ inline const unsigned long &getCacheLife() const
{ return resource.cache_life; }
- inline const unsigned long &getCacheMax(void) const
+ inline const unsigned long &getCacheMax() const
{ return resource.cache_max; }
inline void maskWindowEvents(Window w, OpenboxWindow *bw)
inline void setNoFocus(Bool f) { no_focus = f; }
void setFocusedWindow(OpenboxWindow *w);
- void shutdown(void);
- void load_rc(BScreen *);
+ void shutdown();
void saveStyleFilename(const char *);
void saveMenuFilename(const char *);
void saveMenuSearch(Window, Basemenu *);
void removeToolbarSearch(Window);
void removeGroupSearch(Window);
void restart(const char * = 0);
- void reconfigure(void);
- void rereadMenu(void);
- void checkMenu(void);
+ void reconfigure();
+ void rereadMenu();
+ void checkMenu();
virtual Bool handleSignal(int);
- virtual void timeout(void);
+ virtual void timeout();
#ifdef SLIT
Slit *searchSlit(Window);