diff options
author | mathias <mathias> | 2005-04-27 09:52:30 (GMT) |
---|---|---|
committer | mathias <mathias> | 2005-04-27 09:52:30 (GMT) |
commit | b97c3db25193c3b549e46910604d27e5ff92baa2 (patch) | |
tree | e0625ab80a5dd1f814e58d3d680cc78d9f5cc53b /src/WorkspaceNameTool.cc | |
parent | 6df9d6ed54a299c0897cdd2d8aa380dc02b15a41 (diff) | |
download | fluxbox-b97c3db25193c3b549e46910604d27e5ff92baa2.zip fluxbox-b97c3db25193c3b549e46910604d27e5ff92baa2.tar.bz2 |
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.
Diffstat (limited to 'src/WorkspaceNameTool.cc')
-rw-r--r-- | src/WorkspaceNameTool.cc | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/WorkspaceNameTool.cc b/src/WorkspaceNameTool.cc index dbbc571..fdc4ffe 100644 --- a/src/WorkspaceNameTool.cc +++ b/src/WorkspaceNameTool.cc | |||
@@ -30,6 +30,8 @@ | |||
30 | 30 | ||
31 | #include "FbTk/ImageControl.hh" | 31 | #include "FbTk/ImageControl.hh" |
32 | 32 | ||
33 | #include <algorithm> | ||
34 | |||
33 | WorkspaceNameTool::WorkspaceNameTool(const FbTk::FbWindow &parent, | 35 | WorkspaceNameTool::WorkspaceNameTool(const FbTk::FbWindow &parent, |
34 | ToolTheme &theme, BScreen &screen): | 36 | ToolTheme &theme, BScreen &screen): |
35 | ToolbarItem(ToolbarItem::FIXED), | 37 | ToolbarItem(ToolbarItem::FIXED), |
@@ -68,6 +70,7 @@ void WorkspaceNameTool::moveResize(int x, int y, | |||
68 | } | 70 | } |
69 | 71 | ||
70 | void WorkspaceNameTool::update(FbTk::Subject *subj) { | 72 | void WorkspaceNameTool::update(FbTk::Subject *subj) { |
73 | |||
71 | m_button.setText(m_screen.currentWorkspace()->name()); | 74 | m_button.setText(m_screen.currentWorkspace()->name()); |
72 | if (m_button.width() != width()) { | 75 | if (m_button.width() != width()) { |
73 | resize(width(), height()); | 76 | resize(width(), height()); |
@@ -79,13 +82,13 @@ void WorkspaceNameTool::update(FbTk::Subject *subj) { | |||
79 | 82 | ||
80 | unsigned int WorkspaceNameTool::width() const { | 83 | unsigned int WorkspaceNameTool::width() const { |
81 | // calculate largest size | 84 | // calculate largest size |
82 | int max_size = 0; | 85 | unsigned int max_size = 0; |
83 | const int num_workspaces = m_screen.getNumberOfWorkspaces(); | 86 | const BScreen::Workspaces& workspaces = m_screen.getWorkspacesList(); |
84 | for (int workspace = 0; workspace < num_workspaces; ++workspace) { | 87 | BScreen::Workspaces::const_iterator it; |
85 | const std::string &name = m_screen.getWorkspace(workspace)->name().c_str(); | 88 | for (it = workspaces.begin(); it != workspaces.end(); it++) { |
86 | int size = m_theme.font().textWidth(name.c_str(), name.size()); | 89 | const std::string &name = (*it)->name(); |
87 | if (size > max_size) | 90 | max_size = std::max(m_theme.font().textWidth(name.c_str(), name.size()), |
88 | max_size = size; | 91 | max_size); |
89 | } | 92 | } |
90 | // so align text dont cut the last character | 93 | // so align text dont cut the last character |
91 | max_size += 2; | 94 | max_size += 2; |