X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=src%2FScreen.cc;h=10c092d3a177514c378a79106a500e8c1f7252da;hb=874d0ea446daac149e6b4b572f7e7196a855c8b9;hp=313aeb21e8efa2c9a053832334f2d47298b50759;hpb=4602d87180951a4b7a40283a2fb77f31cad4d789;p=chaz%2Fopenbox diff --git a/src/Screen.cc b/src/Screen.cc index 313aeb21..10c092d3 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -847,6 +847,7 @@ XFontSet BScreen::createFontSet(const char *fontname) { return fs; } + void BScreen::setSloppyFocus(bool b) { resource.sloppy_focus = b; ostrstream s; @@ -855,8 +856,10 @@ void BScreen::setSloppyFocus(bool b) { (resource.sloppy_focus ? (resource.auto_raise ? "AutoRaiseSloppyFocus" : "SloppyFocus") : "ClickToFocus")); + s.rdbuf()->freeze(0); } + void BScreen::setAutoRaise(bool a) { resource.auto_raise = a; ostrstream s; @@ -865,57 +868,73 @@ void BScreen::setAutoRaise(bool a) { (resource.sloppy_focus ? (resource.auto_raise ? "AutoRaiseSloppyFocus" : "SloppyFocus") : "ClickToFocus")); + s.rdbuf()->freeze(0); } + void BScreen::setImageDither(bool d) { resource.image_dither = d; ostrstream s; s << "session.screen" << getScreenNumber() << ".imageDither" << ends; config.setValue(s.str(), resource.image_dither); + s.rdbuf()->freeze(0); } + void BScreen::setOpaqueMove(bool o) { resource.opaque_move = o; ostrstream s; s << "session.screen" << getScreenNumber() << ".opaqueMove" << ends; config.setValue(s.str(), resource.opaque_move); + s.rdbuf()->freeze(0); } + void BScreen::setFullMax(bool f) { resource.full_max = f; ostrstream s; s << "session.screen" << getScreenNumber() << ".fullMaximization" << ends; config.setValue(s.str(), resource.full_max); + s.rdbuf()->freeze(0); } + void BScreen::setFocusNew(bool f) { resource.focus_new = f; ostrstream s; s << "session.screen" << getScreenNumber() << ".focusNewWindows" << ends; config.setValue(s.str(), resource.focus_new); + s.rdbuf()->freeze(0); } + void BScreen::setFocusLast(bool f) { resource.focus_last = f; ostrstream s; s << "session.screen" << getScreenNumber() << ".focusLastWindow" << ends; config.setValue(s.str(), resource.focus_last); + s.rdbuf()->freeze(0); } + void BScreen::setWindowZones(int z) { resource.zones = z; ostrstream s; s << "session.screen" << getScreenNumber() << ".windowZones" << ends; config.setValue(s.str(), resource.zones); + s.rdbuf()->freeze(0); } + void BScreen::setWorkspaceCount(int w) { resource.workspaces = w; ostrstream s; s << "session.screen" << getScreenNumber() << ".workspaces" << ends; config.setValue(s.str(), resource.workspaces); + s.rdbuf()->freeze(0); } + void BScreen::setPlacementPolicy(int p) { resource.placement_policy = p; ostrstream s; @@ -929,15 +948,19 @@ void BScreen::setPlacementPolicy(int p) { case RowSmartPlacement: placement = "RowSmartPlacement"; break; } config.setValue(s.str(), placement); + s.rdbuf()->freeze(0); } + 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); + s.rdbuf()->freeze(0); } + void BScreen::setRowPlacementDirection(int d) { resource.row_direction = d; ostrstream s; @@ -946,8 +969,10 @@ void BScreen::setRowPlacementDirection(int d) { config.setValue(s.str(), resource.row_direction == LeftRight ? "LeftToRight" : "RightToLeft"); + s.rdbuf()->freeze(0); } + void BScreen::setColPlacementDirection(int d) { resource.col_direction = d; ostrstream s; @@ -956,8 +981,10 @@ void BScreen::setColPlacementDirection(int d) { config.setValue(s.str(), resource.col_direction == TopBottom ? "TopToBottom" : "BottomToTop"); + s.rdbuf()->freeze(0); } + void BScreen::setRootCommand(const char *cmd) { if (resource.root_command != NULL) delete [] resource.root_command; @@ -967,8 +994,10 @@ if (resource.root_command != NULL) 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 + // ride the styles command when none has been specified } + + #ifdef HAVE_STRFTIME void BScreen::setStrftimeFormat(const char *f) { if (resource.strftime_format != NULL) @@ -978,6 +1007,7 @@ void BScreen::setStrftimeFormat(const char *f) { ostrstream s; s << "session.screen" << getScreenNumber() << ".strftimeFormat" << ends; config.setValue(s.str(), resource.strftime_format); + s.rdbuf()->freeze(0); } #else // !HAVE_STRFTIME @@ -987,6 +1017,7 @@ void BScreen::setDateFormat(int f) { s << "session.screen" << getScreenNumber() << ".dateFormat" << ends; config.setValue(s.str(), resource.date_format == B_EuropeanDate ? "European" : "American"); + s.rdbuf()->freeze(0); } void BScreen::setClock24Hour(Bool c) { @@ -994,6 +1025,7 @@ void BScreen::setClock24Hour(Bool c) { ostrstream s; s << "session.screen" << getScreenNumber() << ".clockFormat" << ends; config.setValue(s.str(), resource.clock24hour ? 24 : 12); + s.rdbuf()->freeze(0); } #endif // HAVE_STRFTIME @@ -1006,23 +1038,26 @@ void BScreen::setHideToolbar(bool b) { ostrstream s; s << "session.screen" << getScreenNumber() << ".hideToolbar" << ends; config.setValue(s.str(), resource.hide_toolbar ? "True" : "False"); + s.rdbuf()->freeze(0); } 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 << ','; - } + 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; + } + names << ends; - rc << "session.screen" << getScreenNumber() << ".workspaceNames" << ends; - config.setValue(rc.str(), names.str()); + rc << "session.screen" << getScreenNumber() << ".workspaceNames" << ends; + config.setValue(rc.str(), names.str()); + rc.rdbuf()->freeze(0); + names.rdbuf()->freeze(0); } void BScreen::save() { @@ -1173,8 +1208,15 @@ void BScreen::load() { rname.seekp(0); rclass.seekp(0); rname << rscreen.str() << "strftimeFormat" << ends; rclass << rscreen.str() << "StrftimeFormat" << ends; - if (config.getValue(rname.str(), rclass.str(), s)) + + if (resource.strftime_format != NULL){ + delete [] resource.strftime_format; + resource.strftime_format=NULL; + } + + 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; @@ -1211,14 +1253,23 @@ void BScreen::load() { rname.seekp(0); rclass.seekp(0); rname << rscreen.str() << "rootCommand" << ends; rclass << rscreen.str() << "RootCommand" << ends; - if (config.getValue(rname.str(), rclass.str(), s)) + + if (resource.root_command != NULL){ + delete [] resource.root_command; + resource.root_command=NULL; + } + 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; if (config.getValue(rname.str(), rclass.str(), b)) resource.opaque_move = b; + rscreen.rdbuf()->freeze(0); + rname.rdbuf()->freeze(0); + rclass.rdbuf()->freeze(0); } void BScreen::reconfigure(void) { @@ -1402,8 +1453,13 @@ void BScreen::removeWorkspaceNames(void) { void BScreen::LoadStyle(void) { Resource &conf = resource.styleconfig; - conf.setFile(openbox.getStyleFilename()); - if (!conf.load()) { + const char *sfile = openbox.getStyleFilename(); + bool loaded = false; + if (sfile != NULL) { + conf.setFile(sfile); + loaded = conf.load(); + } + if (!loaded) { conf.setFile(DEFAULTSTYLE); if (!conf.load()) { fprintf(stderr, i18n->getMessage(ScreenSet, ScreenDefaultStyleLoadFail,