aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Screen.cc39
-rw-r--r--src/Screen.hh11
-rw-r--r--src/fluxbox.cc79
3 files changed, 27 insertions, 102 deletions
diff --git a/src/Screen.cc b/src/Screen.cc
index 0aaa718..77b7ca3 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -243,8 +243,11 @@ const EnumTraits<FbWinFrame::TabPlacement>::Pair EnumTraits<FbWinFrame::TabPlace
243} // end namespace FbTk 243} // end namespace FbTk
244 244
245 245
246const char BScreen::ScreenResource::workspace_names_delim[] = ",";
247
246BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager_base &rm, 248BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager_base &rm,
247 const string &scrname): 249 const string &scrname):
250 workspace_names(rm, std::vector<std::string>(), scrname + ".workspaceNames"),
248 opaque_move(rm, true, scrname + ".opaqueMove"), 251 opaque_move(rm, true, scrname + ".opaqueMove"),
249 full_max(rm, false, scrname+".fullMaximization"), 252 full_max(rm, false, scrname+".fullMaximization"),
250 max_ignore_inc(rm, true, scrname+".maxIgnoreIncrement"), 253 max_ignore_inc(rm, true, scrname+".maxIgnoreIncrement"),
@@ -388,9 +391,6 @@ BScreen::BScreen(FbTk::ResourceManager_base &rm,
388 Keys::GLOBAL|Keys::ON_DESKTOP); 391 Keys::GLOBAL|Keys::ON_DESKTOP);
389 rootWindow().setCursor(XCreateFontCursor(disp, XC_left_ptr)); 392 rootWindow().setCursor(XCreateFontCursor(disp, XC_left_ptr));
390 393
391 // load this screens resources
392 fluxbox->load_rc(*this);
393
394 // setup image cache engine 394 // setup image cache engine
395 m_image_control.reset(new FbTk::ImageControl(scrn, 395 m_image_control.reset(new FbTk::ImageControl(scrn,
396 fluxbox->colorsPerChannel(), 396 fluxbox->colorsPerChannel(),
@@ -856,15 +856,14 @@ void BScreen::reconfigure() {
856 856
857 // realize the number of workspaces from the init-file 857 // realize the number of workspaces from the init-file
858 const unsigned int nr_ws = *resource.workspaces; 858 const unsigned int nr_ws = *resource.workspaces;
859 if (nr_ws > m_workspaces_list.size()) { 859 while(nr_ws > m_workspaces_list.size())
860 while(nr_ws != m_workspaces_list.size()) { 860 addWorkspace();
861 addWorkspace(); 861 while(nr_ws < m_workspaces_list.size())
862 } 862 removeLastWorkspace();
863 } else if (nr_ws < m_workspaces_list.size()) { 863
864 while(nr_ws != m_workspaces_list.size()) { 864 // and update their names
865 removeLastWorkspace(); 865 for(size_t i = 0; i < std::min(m_workspaces_list.size(), resource.workspace_names->size()); ++i)
866 } 866 m_workspaces_list[i]->setName( (*resource.workspace_names)[i] );
867 }
868 867
869 // update menu filenames 868 // update menu filenames
870 m_rootmenu->reloadHelper()->setMainFile(fluxbox->getMenuFilename()); 869 m_rootmenu->reloadHelper()->setMainFile(fluxbox->getMenuFilename());
@@ -904,14 +903,14 @@ void BScreen::reconfigureTabs() {
904void BScreen::updateWorkspaceName(unsigned int w) { 903void BScreen::updateWorkspaceName(unsigned int w) {
905 Workspace *space = getWorkspace(w); 904 Workspace *space = getWorkspace(w);
906 if (space) { 905 if (space) {
907 m_workspace_names[w] = space->name(); 906 (*resource.workspace_names)[w] = space->name();
908 m_workspacenames_sig.emit(*this); 907 m_workspacenames_sig.emit(*this);
909 Fluxbox::instance()->save_rc(); 908 Fluxbox::instance()->save_rc();
910 } 909 }
911} 910}
912 911
913void BScreen::removeWorkspaceNames() { 912void BScreen::removeWorkspaceNames() {
914 m_workspace_names.clear(); 913 resource.workspace_names->clear();
915} 914}
916 915
917void BScreen::addIcon(FluxboxWindow *w) { 916void BScreen::addIcon(FluxboxWindow *w) {
@@ -1345,17 +1344,17 @@ void BScreen::updateAvailableWorkspaceArea() {
1345 m_workspace_area_sig.emit(*this); 1344 m_workspace_area_sig.emit(*this);
1346} 1345}
1347 1346
1348void BScreen::addWorkspaceName(const char *name) { 1347void BScreen::addWorkspaceName(const std::string &name) {
1349 m_workspace_names.push_back(FbTk::FbStringUtil::LocaleStrToFb(name)); 1348 resource.workspace_names->push_back(name);
1350 Workspace *wkspc = getWorkspace(m_workspace_names.size()-1); 1349 Workspace *wkspc = getWorkspace(resource.workspace_names->size()-1);
1351 if (wkspc) 1350 if (wkspc)
1352 wkspc->setName(m_workspace_names.back()); 1351 wkspc->setName(name);
1353} 1352}
1354 1353
1355 1354
1356string BScreen::getNameOfWorkspace(unsigned int workspace) const { 1355string BScreen::getNameOfWorkspace(unsigned int workspace) const {
1357 if (workspace < m_workspace_names.size()) 1356 if (workspace < resource.workspace_names->size())
1358 return m_workspace_names[workspace]; 1357 return (*resource.workspace_names)[workspace];
1359 else 1358 else
1360 return ""; 1359 return "";
1361} 1360}
diff --git a/src/Screen.hh b/src/Screen.hh
index e7b439c..138cd1c 100644
--- a/src/Screen.hh
+++ b/src/Screen.hh
@@ -190,7 +190,7 @@ public:
190 190
191 const Workspaces &getWorkspacesList() const { return m_workspaces_list; } 191 const Workspaces &getWorkspacesList() const { return m_workspaces_list; }
192 Workspaces &getWorkspacesList() { return m_workspaces_list; } 192 Workspaces &getWorkspacesList() { return m_workspaces_list; }
193 const WorkspaceNames &getWorkspaceNames() const { return m_workspace_names; } 193 const WorkspaceNames &getWorkspaceNames() const { return *resource.workspace_names; }
194 /** 194 /**
195 @name Screen signals 195 @name Screen signals
196 */ 196 */
@@ -321,7 +321,7 @@ public:
321 /// remove all workspace names 321 /// remove all workspace names
322 void removeWorkspaceNames(); 322 void removeWorkspaceNames();
323 /// add a workspace name to the end of the workspace name list 323 /// add a workspace name to the end of the workspace name list
324 void addWorkspaceName(const char *name); 324 void addWorkspaceName(const std::string &name);
325 /// add a window to the icon list 325 /// add a window to the icon list
326 void addIcon(FluxboxWindow *win); 326 void addIcon(FluxboxWindow *win);
327 /// remove a window from the icon list 327 /// remove a window from the icon list
@@ -493,7 +493,6 @@ private:
493 493
494 Workspace *m_current_workspace; 494 Workspace *m_current_workspace;
495 495
496 WorkspaceNames m_workspace_names;
497 Workspaces m_workspaces_list; 496 Workspaces m_workspaces_list;
498 497
499 std::auto_ptr<FbWinFrameTheme> m_focused_windowtheme, 498 std::auto_ptr<FbWinFrameTheme> m_focused_windowtheme,
@@ -511,6 +510,12 @@ private:
511 struct ScreenResource { 510 struct ScreenResource {
512 ScreenResource(FbTk::ResourceManager_base &rm, const std::string &scrname); 511 ScreenResource(FbTk::ResourceManager_base &rm, const std::string &scrname);
513 512
513 static const char workspace_names_delim[];
514 FbTk::Resource<
515 std::vector<std::string>,
516 FbTk::VectorTraits<FbTk::StringTraits, workspace_names_delim>
517 > workspace_names;
518
514 FbTk::BoolResource opaque_move, full_max, 519 FbTk::BoolResource opaque_move, full_max,
515 max_ignore_inc, max_disable_move, max_disable_resize, 520 max_ignore_inc, max_disable_move, max_disable_resize,
516 workspace_warping, show_window_pos, auto_raise, click_raises; 521 workspace_warping, show_window_pos, auto_raise, click_raises;
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index 0c391dc..162a409 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.cc
@@ -1131,36 +1131,6 @@ void Fluxbox::save_rc() {
1131 cerr<<_FB_CONSOLETEXT(Fluxbox, BadRCFile, "rc filename is invalid!", "Bad settings file")<<endl; 1131 cerr<<_FB_CONSOLETEXT(Fluxbox, BadRCFile, "rc filename is invalid!", "Bad settings file")<<endl;
1132 1132
1133 1133
1134 ScreenList::iterator it = m_screen_list.begin();
1135 ScreenList::iterator it_end = m_screen_list.end();
1136 for (; it != it_end; ++it) {
1137 BScreen *screen = *it;
1138
1139 std::string workspaces_string("screen");
1140 workspaces_string += FbTk::StringUtil::number2String(screen->screenNumber());
1141 workspaces_string += ".workspaceNames: ";
1142
1143 // these are static, but may not be saved in the users resource file,
1144 // writing these resources will allow the user to edit them at a later
1145 // time... but loading the defaults before saving allows us to rewrite the
1146 // users changes...
1147
1148 const BScreen::WorkspaceNames& names = screen->getWorkspaceNames();
1149 for (size_t i=0; i < names.size(); i++) {
1150 workspaces_string += FbTk::FbStringUtil::FbStrToLocale(names[i]);
1151 workspaces_string += ',';
1152 }
1153
1154 XrmPutLineResource(&new_rc, workspaces_string.c_str());
1155
1156 }
1157
1158 XrmDatabase old_rc = XrmGetFileDatabase(dbfile.c_str());
1159
1160 XrmMergeDatabases(new_rc, &old_rc);
1161 XrmPutFileDatabase(old_rc, dbfile.c_str());
1162 XrmDestroyDatabase(old_rc);
1163
1164 fbdbg<<__FILE__<<"("<<__LINE__<<"): ------------ SAVING DONE"<<endl; 1134 fbdbg<<__FILE__<<"("<<__LINE__<<"): ------------ SAVING DONE"<<endl;
1165 1135
1166} 1136}
@@ -1218,50 +1188,6 @@ void Fluxbox::load_rc() {
1218 *m_rc_stylefile = DEFAULTSTYLE; 1188 *m_rc_stylefile = DEFAULTSTYLE;
1219} 1189}
1220 1190
1221void Fluxbox::load_rc(BScreen &screen) {
1222 //get resource filename
1223 _FB_USES_NLS;
1224 string dbfile(getRcFilename());
1225
1226 XrmDatabaseHelper database;
1227
1228 // XXX make this a regular resource
1229 database = XrmGetFileDatabase(dbfile.c_str());
1230 if (database==0)
1231 database = XrmGetFileDatabase(DEFAULT_INITFILE);
1232
1233
1234 screen.removeWorkspaceNames();
1235
1236 std::string screen_number = FbTk::StringUtil::number2String(screen.screenNumber());
1237
1238 std::string name_lookup("screen");
1239 name_lookup += screen_number;
1240 name_lookup += ".workspaceNames";
1241 std::string class_lookup("screen");
1242 class_lookup += screen_number;
1243 class_lookup += ".WorkspaceNames";
1244
1245 XrmValue value;
1246 char *value_type;
1247 if (XrmGetResource(*database, name_lookup.c_str(), class_lookup.c_str(), &value_type,
1248 &value)) {
1249
1250 string values(value.addr);
1251 BScreen::WorkspaceNames names;
1252
1253 StringUtil::removeTrailingWhitespace(values);
1254 StringUtil::removeFirstWhitespace(values);
1255 StringUtil::stringtok<BScreen::WorkspaceNames>(names, values, ",");
1256 BScreen::WorkspaceNames::iterator it;
1257 for(it = names.begin(); it != names.end(); it++) {
1258 if (!(*it).empty() && (*it) != "")
1259 screen.addWorkspaceName((*it).c_str());
1260 }
1261
1262 }
1263}
1264
1265void Fluxbox::reconfigure() { 1191void Fluxbox::reconfigure() {
1266 load_rc(); 1192 load_rc();
1267 m_reconfigure_wait = true; 1193 m_reconfigure_wait = true;
@@ -1273,11 +1199,6 @@ void Fluxbox::real_reconfigure() {
1273 1199
1274 FbTk::Transparent::usePseudoTransparent(*m_rc_pseudotrans); 1200 FbTk::Transparent::usePseudoTransparent(*m_rc_pseudotrans);
1275 1201
1276 ScreenList::iterator screen_it = m_screen_list.begin();
1277 ScreenList::iterator screen_it_end = m_screen_list.end();
1278 for (; screen_it != screen_it_end; ++screen_it)
1279 load_rc(*(*screen_it));
1280
1281 STLUtil::forAll(m_screen_list, mem_fun(&BScreen::reconfigure)); 1202 STLUtil::forAll(m_screen_list, mem_fun(&BScreen::reconfigure));
1282 m_key->reconfigure(); 1203 m_key->reconfigure();
1283 STLUtil::forAll(m_atomhandler, mem_fun(&AtomHandler::reconfigure)); 1204 STLUtil::forAll(m_atomhandler, mem_fun(&AtomHandler::reconfigure));