X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2FScreen.cc;h=0548f5acb5e8f86fc256689cf0efd8534e721396;hb=0a3cfdfcb956024639a05549a50586e3d826b42e;hp=251faadd429464f1ad5f960109df48830ff6f31d;hpb=9cd9d92bb1d66db9329bf5cd6e42e8b0096945e6;p=chaz%2Fopenbox diff --git a/src/Screen.cc b/src/Screen.cc index 251faadd..0548f5ac 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -232,9 +232,14 @@ BScreen::BScreen(Openbox &ob, int scrn, Resource &conf) : ScreenInfo(ob, scrn), rootmenu = 0; resource.mstyle.t_fontset = resource.mstyle.f_fontset = - resource.tstyle.fontset = resource.wstyle.fontset = (XFontSet) 0; + resource.tstyle.fontset = resource.wstyle.fontset = NULL; resource.mstyle.t_font = resource.mstyle.f_font = resource.tstyle.font = - resource.wstyle.font = (XFontStruct *) 0; + resource.wstyle.font = NULL; + +#ifdef SLIT + slit = NULL; +#endif // SLIT + toolbar = NULL; #ifdef HAVE_GETPID pid_t bpid = getpid(); @@ -249,9 +254,6 @@ BScreen::BScreen(Openbox &ob, int scrn, Resource &conf) : ScreenInfo(ob, scrn), openbox.getSessionCursor()); workspaceNames = new LinkedList; - - load(); // load config options from Resources - workspacesList = new LinkedList; rootmenuList = new LinkedList; netizenList = new LinkedList; @@ -265,6 +267,7 @@ BScreen::BScreen(Openbox &ob, int scrn, Resource &conf) : ScreenInfo(ob, scrn), image_control->setDither(resource.image_dither); + load(); // load config options from Resources LoadStyle(); XGCValues gcv; @@ -417,7 +420,7 @@ BScreen::BScreen(Openbox &ob, int scrn, Resource &conf) : ScreenInfo(ob, scrn), iconmenu = new Iconmenu(*this); configmenu = new Configmenu(*this); - Workspace *wkspc = (Workspace *) 0; + Workspace *wkspc = NULL; if (resource.workspaces != 0) { for (int i = 0; i < resource.workspaces; ++i) { wkspc = new Workspace(*this, workspacesList->count()); @@ -852,6 +855,7 @@ void BScreen::setSloppyFocus(bool b) { (resource.sloppy_focus ? (resource.auto_raise ? "AutoRaiseSloppyFocus" : "SloppyFocus") : "ClickToFocus")); + s.rdbuf()->freeze(0); } void BScreen::setAutoRaise(bool a) { @@ -862,6 +866,7 @@ void BScreen::setAutoRaise(bool a) { (resource.sloppy_focus ? (resource.auto_raise ? "AutoRaiseSloppyFocus" : "SloppyFocus") : "ClickToFocus")); + s.rdbuf()->freeze(0); } void BScreen::setImageDither(bool d) { @@ -869,6 +874,7 @@ void BScreen::setImageDither(bool 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) { @@ -876,6 +882,7 @@ void BScreen::setOpaqueMove(bool 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) { @@ -883,6 +890,7 @@ void BScreen::setFullMax(bool 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) { @@ -890,6 +898,7 @@ void BScreen::setFocusNew(bool 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) { @@ -897,6 +906,7 @@ void BScreen::setFocusLast(bool 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) { @@ -904,6 +914,7 @@ void BScreen::setWindowZones(int z) { ostrstream s; s << "session.screen" << getScreenNumber() << ".windowZones" << ends; config.setValue(s.str(), resource.zones); + s.rdbuf()->freeze(0); } void BScreen::setWorkspaceCount(int w) { @@ -911,6 +922,7 @@ void BScreen::setWorkspaceCount(int w) { ostrstream s; s << "session.screen" << getScreenNumber() << ".workspaces" << ends; config.setValue(s.str(), resource.workspaces); + s.rdbuf()->freeze(0); } void BScreen::setPlacementPolicy(int p) { @@ -926,6 +938,7 @@ void BScreen::setPlacementPolicy(int p) { case RowSmartPlacement: placement = "RowSmartPlacement"; break; } config.setValue(s.str(), placement); + s.rdbuf()->freeze(0); } void BScreen::setEdgeSnapThreshold(int t) { @@ -933,6 +946,7 @@ void BScreen::setEdgeSnapThreshold(int 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) { @@ -943,6 +957,7 @@ void BScreen::setRowPlacementDirection(int d) { config.setValue(s.str(), resource.row_direction == LeftRight ? "LeftToRight" : "RightToLeft"); + s.rdbuf()->freeze(0); } void BScreen::setColPlacementDirection(int d) { @@ -953,6 +968,7 @@ 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) { @@ -975,6 +991,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 @@ -984,6 +1001,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) { @@ -991,6 +1009,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 @@ -1003,23 +1022,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() { @@ -1040,7 +1062,8 @@ void BScreen::save() { #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)); + std::string s = resource.strftime_format; + setStrftimeFormat(s.c_str()); #else // !HAVE_STRFTIME setDateFormat(resource.date_format); setClock24Hour(resource.clock24hour); @@ -1059,6 +1082,13 @@ void BScreen::load() { rclass << rscreen.str() << "HideToolbar" << ends; if (config.getValue(rname.str(), rclass.str(), b)) resource.hide_toolbar = b; + Toolbar *t = getToolbar(); + if (t != NULL) { + if (resource.hide_toolbar) + t->unMapToolbar(); + else + t->mapToolbar(); + } rname.seekp(0); rclass.seekp(0); rname << rscreen.str() << "fullMaximization" << ends; @@ -1162,8 +1192,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; @@ -1200,17 +1237,31 @@ 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) { load(); + toolbar->load(); +#ifdef SLIT + slit->load(); +#endif // SLIT LoadStyle(); XGCValues gcv; @@ -1386,8 +1437,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, @@ -1726,7 +1782,7 @@ OpenboxWindow *BScreen::getIcon(int index) { if (index >= 0 && index < iconList->count()) return iconList->find(index); - return (OpenboxWindow *) 0; + return NULL; } @@ -1785,7 +1841,7 @@ void BScreen::changeWorkspaceID(int id) { openbox.getFocusedWindow()->getScreen() == this && (! openbox.getFocusedWindow()->isStuck())) { current_workspace->setLastFocusedWindow(openbox.getFocusedWindow()); - openbox.setFocusedWindow((OpenboxWindow *) 0); + openbox.setFocusedWindow(NULL); } current_workspace = getWorkspace(id); @@ -1952,7 +2008,7 @@ void BScreen::addWorkspaceName(const char *name) { } char* BScreen::getNameOfWorkspace(int id) { - char *name = (char *) 0; + char *name = NULL; if (id >= 0 && id < workspaceNames->count()) { char *wkspc_name = workspaceNames->find(id); @@ -2144,7 +2200,7 @@ void BScreen::InitMenu(void) { rootmenu->insert(i18n->getMessage(ScreenSet, ScreenExit, "Exit"), BScreen::Exit); } else { - openbox.saveMenuFilename(openbox.getMenuFilename()); + openbox.setMenuFilename(openbox.getMenuFilename()); } } @@ -2345,7 +2401,7 @@ Bool BScreen::parseMenuFile(FILE *file, Rootmenu *menu) { if (! feof(submenufile)) { if (! parseMenuFile(submenufile, menu)) - openbox.saveMenuFilename(newfile); + openbox.setMenuFilename(newfile); fclose(submenufile); } @@ -2504,7 +2560,7 @@ Bool BScreen::parseMenuFile(FILE *file, Rootmenu *menu) { rootmenuList->insert(stylesmenu); } - openbox.saveMenuFilename(stylesdir); + openbox.setMenuFilename(stylesdir); } else { fprintf(stderr, i18n->getMessage(ScreenSet, ScreenSTYLESDIRErrorNotDir,