aboutsummaryrefslogtreecommitdiff
path: root/src/Container.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Container.cc')
-rw-r--r--src/Container.cc36
1 files changed, 27 insertions, 9 deletions
diff --git a/src/Container.cc b/src/Container.cc
index 3eda052..242a7f1 100644
--- a/src/Container.cc
+++ b/src/Container.cc
@@ -20,7 +20,7 @@
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE. 21// DEALINGS IN THE SOFTWARE.
22 22
23// $Id: Container.cc,v 1.6 2003/10/26 21:05:03 fluxgen Exp $ 23// $Id: Container.cc,v 1.7 2003/10/31 10:37:09 rathnor Exp $
24 24
25#include "Container.hh" 25#include "Container.hh"
26 26
@@ -30,7 +30,6 @@
30Container::Container(const FbTk::FbWindow &parent): 30Container::Container(const FbTk::FbWindow &parent):
31 FbTk::FbWindow(parent, 0, 0, 1, 1, ExposureMask), m_selected(0), 31 FbTk::FbWindow(parent, 0, 0, 1, 1, ExposureMask), m_selected(0),
32 m_update_lock(false) { 32 m_update_lock(false) {
33
34 FbTk::EventManager::instance()->add(*this, *this); 33 FbTk::EventManager::instance()->add(*this, *this);
35} 34}
36 35
@@ -177,18 +176,37 @@ void Container::repositionItems() {
177 176
178 ItemList::iterator it = m_item_list.begin(); 177 ItemList::iterator it = m_item_list.begin();
179 const ItemList::iterator it_end = m_item_list.end(); 178 const ItemList::iterator it_end = m_item_list.end();
180 int next_x = 0; 179 int borderW = m_item_list.front()->borderWidth();
181 for (; it != it_end; ++it, next_x += max_width_per_client) { 180
181 int rounding_error = width() - ((maxWidthPerClient() + borderW)* m_item_list.size() - borderW);
182
183 int next_x = -borderW; // zero so the border of the first shows
184 int extra = 0;
185 for (; it != it_end; ++it, next_x += max_width_per_client + borderW + extra) {
186 if (rounding_error != 0) {
187 --rounding_error;
188 extra = 1;
189 } else {
190 extra = 0;
191 }
182 // resize each clients including border in size 192 // resize each clients including border in size
183 (*it)->moveResize(next_x - (*it)->borderWidth(), 193 (*it)->moveResize(next_x,
184 -(*it)->borderWidth(), 194 -borderW,
185 max_width_per_client - (*it)->borderWidth(), 195 max_width_per_client + extra,
186 height() + (*it)->borderWidth()); 196 height());
187 (*it)->clear(); 197 (*it)->clear();
188 } 198 }
189} 199}
190 200
191 201
192unsigned int Container::maxWidthPerClient() const { 202unsigned int Container::maxWidthPerClient() const {
193 return (size() == 0 ? width() : (width() + size()*m_item_list.front()->borderWidth())/size()); 203 int count = size();
204 if (count == 0)
205 return width();
206 else {
207 int borderW = m_item_list.front()->borderWidth();
208 // there're count-1 borders to fit in with the windows
209 // -> 1 per window plus end
210 return (width() - (count - 1) * borderW) / count;
211 }
194} 212}