all repos — fluxbox @ 10e3f10b55fbd8f3ff6793a3993b8ee55f3192a2

custom fork of the fluxbox windowmanager

Adjust RELATIVE ::repositionItems (more relative)

The evenly distributed space causes a lot of whitespace and otoh. cut
items, so we use the items internal size as indicator IF the item is a
textbutton (the regular usecase in fluxbox)

Also publish the function to be triggered from outside (because the
caller can, in theory, much better compress several text changes)
Thomas Lübking thomas.luebking@gmail.com
commit

10e3f10b55fbd8f3ff6793a3993b8ee55f3192a2

parent

cc80230bd85dbaf1036b4cf37259d3146229fb00

2 files changed, 29 insertions(+), 8 deletions(-)

jump to
M src/FbTk/Container.ccsrc/FbTk/Container.cc

@@ -23,12 +23,14 @@

#include "Container.hh" #include "Button.hh" +#include "TextButton.hh" #include "TextUtils.hh" #include "EventManager.hh" #include "CompareEqual.hh" #include "STLUtil.hh" #include <algorithm> +#include <vector> namespace FbTk {

@@ -304,7 +306,7 @@ */

unsigned int max_width_per_client = maxWidthPerClient(); unsigned int borderW = m_item_list.front()->borderWidth(); - size_t num_items = m_item_list.size(); + const size_t num_items = m_item_list.size(); unsigned int total_width; unsigned int cur_width;

@@ -364,10 +366,6 @@ const ItemList::iterator it_end = end();

int rounding_error = 0; - if (align == RELATIVE || total_width == m_max_total_size) { - rounding_error = total_width - ((max_width_per_client + borderW)* num_items - borderW); - } - int next_x = -borderW; // zero so the border of the first shows int extra = 0; int direction = 1;

@@ -378,7 +376,25 @@ }

int tmpx, tmpy; unsigned int tmpw, tmph; - for (; it != it_end; ++it, next_x += direction*(max_width_per_client + borderW + extra)) { + unsigned int totalDemands = 0; + std::vector<unsigned int> buttonDemands; + + if (align == RELATIVE || total_width == m_max_total_size) { + buttonDemands.reserve(num_items); + for (it = begin(); it != it_end; ++it) { + buttonDemands.push_back((*it)->preferredWidth()); + totalDemands += buttonDemands.back(); + } + if (totalDemands) { + rounding_error = total_width; + for (int i = 0; i < buttonDemands.size(); ++i) { + rounding_error -= buttonDemands.at(i)*total_width/totalDemands; + } + } + } + + it = begin(); + for (int i = 0; it != it_end; ++it, ++i) { // we only need to do error stuff with alignment RELATIVE // OR with max_total_size triggered if (rounding_error) {

@@ -395,8 +411,13 @@ }

// rotate the x and y coords tmpx = next_x; tmpy = -borderW; - tmpw = max_width_per_client + extra; + if (align == RELATIVE && totalDemands) { + tmpw = buttonDemands.at(i)*total_width/totalDemands + extra; + } else { + tmpw = max_width_per_client + extra; + } tmph = height; + next_x += direction*(tmpw + borderW); translateCoords(m_orientation, tmpx, tmpy, total_width, height); translatePosition(m_orientation, tmpx, tmpy, tmpw, tmph, borderW);
M src/FbTk/Container.hhsrc/FbTk/Container.hh

@@ -98,8 +98,8 @@ ItemList::iterator end() { return m_item_list.end(); }

void clear(); // clear all windows -private: void repositionItems(); +private: Orientation m_orientation;