all repos — fluxbox @ b97c3db25193c3b549e46910604d27e5ff92baa2

custom fork of the fluxbox windowmanager

close #1182770

if someone changed the session.screen0.workspaces:<int> value and fired a
"reload config"/reconfigure-Command fluxbox crashed.

changes:

  - cleaner way of reading in the workspacenames
  - cleaner way of initialize the workspaces in BScreen()
  - on BScreen::reconfigure we add/delete Workspaces to the 
    current screen until init-file and fluxbox are in sync

    -> the user changed the initfile and pressed reload, so
       imho he wants to have the changes in the init-file realized.
mathias mathias
commit

b97c3db25193c3b549e46910604d27e5ff92baa2

parent

6df9d6ed54a299c0897cdd2d8aa380dc02b15a41

5 files changed, 54 insertions(+), 44 deletions(-)

jump to
M ChangeLogChangeLog

@@ -1,6 +1,11 @@

(Format: Year/Month/Day) Changes for 0.9.13 *05/04/27: + * Fix #1182770 (Mathias) + session.screen*.workspaces: <int> and the number of + workspaces in the running fluxbox were out of sync and lead to + segfault on a "reloadconfig"-Command. + fluxbox.cc Screen.cc Workspace.cc WorkspaceNameTool.cc * Fix drawing when transparency off (Simon) FbWindow.cc *05/04/26:
M src/Screen.ccsrc/Screen.cc

@@ -328,21 +328,11 @@ renderGeomWindow();

renderPosWindow(); // setup workspaces and workspace menu - - if (*resource.workspaces != 0) { - for (int i = 0; i < *resource.workspaces; ++i) { - Workspace *wkspc = new Workspace(*this, m_layermanager, - getNameOfWorkspace(m_workspaces_list.size()), - m_workspaces_list.size()); - m_workspaces_list.push_back(wkspc); - } - } else { // create at least one workspace - Workspace *wkspc = new Workspace(*this, m_layermanager, - getNameOfWorkspace(m_workspaces_list.size()), - m_workspaces_list.size()); - m_workspaces_list.push_back(wkspc); + int nr_ws = *resource.workspaces; + addWorkspace(); // at least one + for (int i = 1; i < nr_ws; ++i) { + addWorkspace(); } - m_current_workspace = m_workspaces_list.front();

@@ -656,6 +646,7 @@

void BScreen::reconfigure() { + m_windowtheme->setFocusedAlpha(*resource.focused_alpha); m_windowtheme->setUnfocusedAlpha(*resource.unfocused_alpha); m_menutheme->setAlpha(*resource.menu_alpha);

@@ -687,6 +678,18 @@ m_menutheme->frameFont().setAntialias(*resource.antialias);

renderGeomWindow(); renderPosWindow(); + + // realize the number of workspaces from the init-file + const int nr_ws = *resource.workspaces; + if (nr_ws > m_workspaces_list.size()) { + while(nr_ws != m_workspaces_list.size()) { + addWorkspace(); + } + } else if (nr_ws < m_workspaces_list.size()) { + while(nr_ws != m_workspaces_list.size()) { + removeLastWorkspace(); + } + } //reconfigure menus m_workspacemenu->reconfigure();

@@ -851,11 +854,16 @@ reconfigure();

} int BScreen::addWorkspace() { + + bool save_name = getNameOfWorkspace(m_workspaces_list.size()) != "" ? false : true; Workspace *wkspc = new Workspace(*this, m_layermanager, - "", + getNameOfWorkspace(m_workspaces_list.size()), m_workspaces_list.size()); m_workspaces_list.push_back(wkspc); - addWorkspaceName(wkspc->name().c_str()); // update names + + if (save_name) + addWorkspaceName(wkspc->name().c_str()); //update names + saveWorkspaces(m_workspaces_list.size()); updateNetizenWorkspaceCount();

@@ -878,8 +886,6 @@ wkspc->removeAll();

//remove last workspace m_workspaces_list.pop_back(); - - updateNetizenWorkspaceCount(); saveWorkspaces(m_workspaces_list.size());
M src/Workspace.ccsrc/Workspace.cc

@@ -364,7 +364,7 @@ }

void Workspace::setName(const std::string &name) { - if (!name.empty()) { + if (!name.empty() && name != "") { m_name = name; } else { //if name == 0 then set default name from nls _FB_USES_NLS;

@@ -375,7 +375,7 @@ "Workspace %d", "Default workspace names, with a %d for the workspace number"),

m_id + 1); //m_id starts at 0 m_name = tname; } - + screen().updateWorkspaceNamesAtom(); menu().setLabel(m_name.c_str());
M src/WorkspaceNameTool.ccsrc/WorkspaceNameTool.cc

@@ -30,6 +30,8 @@ #include "Workspace.hh"

#include "FbTk/ImageControl.hh" +#include <algorithm> + WorkspaceNameTool::WorkspaceNameTool(const FbTk::FbWindow &parent, ToolTheme &theme, BScreen &screen): ToolbarItem(ToolbarItem::FIXED),

@@ -68,6 +70,7 @@ m_button.moveResize(x, y, width, height);

} void WorkspaceNameTool::update(FbTk::Subject *subj) { + m_button.setText(m_screen.currentWorkspace()->name()); if (m_button.width() != width()) { resize(width(), height());

@@ -79,13 +82,13 @@ }

unsigned int WorkspaceNameTool::width() const { // calculate largest size - int max_size = 0; - const int num_workspaces = m_screen.getNumberOfWorkspaces(); - for (int workspace = 0; workspace < num_workspaces; ++workspace) { - const std::string &name = m_screen.getWorkspace(workspace)->name().c_str(); - int size = m_theme.font().textWidth(name.c_str(), name.size()); - if (size > max_size) - max_size = size; + unsigned int max_size = 0; + const BScreen::Workspaces& workspaces = m_screen.getWorkspacesList(); + BScreen::Workspaces::const_iterator it; + for (it = workspaces.begin(); it != workspaces.end(); it++) { + const std::string &name = (*it)->name(); + max_size = std::max(m_theme.font().textWidth(name.c_str(), name.size()), + max_size); } // so align text dont cut the last character max_size += 2;
M src/fluxbox.ccsrc/fluxbox.cc

@@ -374,7 +374,7 @@ "Couldn't find screens to manage.\nMake sure you don't have another window manager running.", "Error message when no unmanaged screens found - usually means another window manager is running"));

} m_keyscreen = m_mousescreen = m_screen_list.front(); - + // setup theme manager to have our style file ready to be scanned FbTk::ThemeManager::instance().load(FbTk::StringUtil::expandFilename(getStyleFilename()));

@@ -388,7 +388,7 @@ m_key.reset(new Keys(StringUtil::expandFilename(*m_rc_keyfile).c_str()));

m_resourcemanager.unlock(); ungrab(); - + #ifdef DEBUG if (m_resourcemanager.lockDepth() != 0) cerr<<"--- resource manager lockdepth = "<<m_resourcemanager.lockDepth()<<endl;

@@ -1568,22 +1568,18 @@ #ifdef DEBUG

cerr<<__FILE__<<"("<<__FUNCTION__<<"): Workspaces="<< screen.getNumberOfWorkspaces()<<endl; #endif // DEBUG - char *search = StringUtil::strdup(value.addr); - - int i; - for (i = 0; i < screen.getNumberOfWorkspaces(); i++) { - char *nn; - - if (! i) nn = strtok(search, ","); - else nn = strtok(0, ","); - - if (nn) - screen.addWorkspaceName(nn); - else break; - + string values(value.addr); + BScreen::WorkspaceNames names; + + StringUtil::removeTrailingWhitespace(values); + StringUtil::removeFirstWhitespace(values); + StringUtil::stringtok<BScreen::WorkspaceNames>(names, values, ","); + BScreen::WorkspaceNames::iterator it; + for(it = names.begin(); it != names.end(); it++) { + if (!(*it).empty() && (*it) != "") + screen.addWorkspaceName((*it).c_str()); } - - delete [] search; + } FbTk::Image::removeAllSearchPaths();