all repos — fluxbox @ b0663bc167f34b9796f98406329317f7bee15b00

custom fork of the fluxbox windowmanager

Patch from Bo Simonsen.

Max size per client (setMaxSizePerClient) was computed for
iconbar.alignment = Relative not taking into account that a fixed size
can be given when iconbar.alignment = Left/Right.

In a "recent" change, relative alignment was changed, to better handle
items with long titles. This is breaking existing behavior, the new
behavior is (with this commit) now denoted RelativeSmart.
Mark Tiefenbruck mark@fluxbox.org
commit

b0663bc167f34b9796f98406329317f7bee15b00

parent

f76720d918d1a2c72811a6ec5b3a1fc4b52f768c

M doc/fluxbox.1.indoc/fluxbox.1.in

@@ -1201,6 +1201,11 @@ .RS 4

All icons will be sized evenly to fill the iconbar completely .RE .PP +\fBRelativeSmart\fR: +.RS 4 +All icons will initially be sized evenly, but icons with long titles will be larger +.RE +.PP \fBRight\fR: .RS 4 All icons will be right\-aligned with the width set in the \(oqinit\(cq file
M nls/fluxbox-nls.hhnls/fluxbox-nls.hh

@@ -27,6 +27,7 @@ AlignVertical = 17,

AlignCenter = 18, AlignTop = 19, AlignBottom = 20, + AlignRelativeSmart = 21, BaseDisplaySet = 2, BaseDisplayAborting = 1,
M src/FbTk/Container.ccsrc/FbTk/Container.cc

@@ -324,7 +324,7 @@

// if we have a max total size, then we must also resize ourself // within that bound Alignment align = alignment(); - if (m_max_total_size && align != RELATIVE) { + if (m_max_total_size && (align != RELATIVE && align != RELATIVE_SMART)) { total_width = (max_width_per_client + borderW) * num_items - borderW; if (total_width > m_max_total_size) { total_width = m_max_total_size;

@@ -379,7 +379,7 @@ unsigned int tmpw, tmph;

unsigned int totalDemands = 0; std::vector<unsigned int> buttonDemands; - if (align == RELATIVE || total_width == m_max_total_size) { + if (align == RELATIVE_SMART && total_width == m_max_total_size) { buttonDemands.reserve(num_items); for (it = begin(); it != it_end; ++it) { buttonDemands.push_back((*it)->preferredWidth());

@@ -440,7 +440,7 @@ }

// rotate the x and y coords tmpx = next_x; tmpy = -borderW; - if (align == RELATIVE && totalDemands) { + if ((align == RELATIVE || align == RELATIVE_SMART) && totalDemands) { tmpw = buttonDemands.at(i)*total_width/totalDemands + extra; } else { tmpw = max_width_per_client + extra;

@@ -469,6 +469,7 @@ case CENTER:

case LEFT: return m_max_size_per_client; break; + case RELATIVE_SMART: case RELATIVE: if (size() == 0) return width();
M src/FbTk/Container.hhsrc/FbTk/Container.hh

@@ -39,7 +39,7 @@ class Container: public FbWindow, public EventHandler, private NotCopyable {

public: // LEFT, RIGHT => fixed total width, fixed icon size // RELATIVE => fixed total width, relative/variable icon size - enum Alignment { LEFT, CENTER, RIGHT, RELATIVE }; + enum Alignment { LEFT, CENTER, RIGHT, RELATIVE, RELATIVE_SMART }; typedef Button * Item; typedef const Button * ConstItem; typedef std::list<Item> ItemList;
M src/IconbarTool.ccsrc/IconbarTool.cc

@@ -73,6 +73,8 @@ if (m_value == FbTk::Container::LEFT)

return string("Left"); if (m_value == FbTk::Container::RIGHT) return string("Right"); + if (m_value == FbTk::Container::RELATIVE_SMART) + return string("RelativeSmart"); return string("Relative"); }

@@ -84,6 +86,8 @@ else if (strcasecmp(str, "Right") == 0)

m_value = FbTk::Container::RIGHT; else if (strcasecmp(str, "Relative") == 0) m_value = FbTk::Container::RELATIVE; + else if (strcasecmp(str, "RelativeSmart") == 0) + m_value = FbTk::Container::RELATIVE_SMART; else setDefaultValue(); }

@@ -143,6 +147,7 @@ L_MODE_ALL,

L_LEFT, L_RELATIVE, + L_RELATIVE_SMART, L_RIGHT, };

@@ -163,6 +168,7 @@ _FB_XTEXT(Toolbar, IconbarModeAllWindows, "All Windows", "All windows are shown"),

_FB_XTEXT(Align, Left, "Left", "Align to the left"), _FB_XTEXT(Align, Relative, "Relative", "Align relative to the width"), + _FB_XTEXT(Align, RelativeSmart, "Relative (Smart)", "Align relative to the width, but let elements vary according to size of title"), _FB_XTEXT(Align, Right, "Right", "Align to the right"), };

@@ -181,6 +187,7 @@ menu.insertItem(new FbTk::MenuSeparator());

menu.insertItem(new ToolbarAlignMenuItem(_labels[L_LEFT], handler, FbTk::Container::LEFT, saverc_cmd)); menu.insertItem(new ToolbarAlignMenuItem(_labels[L_RELATIVE], handler, FbTk::Container::RELATIVE, saverc_cmd)); + menu.insertItem(new ToolbarAlignMenuItem(_labels[L_RELATIVE_SMART], handler, FbTk::Container::RELATIVE_SMART, saverc_cmd)); menu.insertItem(new ToolbarAlignMenuItem(_labels[L_RIGHT], handler, FbTk::Container::RIGHT, saverc_cmd)); menu.insertItem(new FbTk::MenuSeparator());

@@ -304,11 +311,21 @@ void IconbarTool::move(int x, int y) {

m_icon_container.move(x, y); } +void IconbarTool::updateMaxSizes(unsigned int width, unsigned int height) { + const unsigned int maxsize = (m_icon_container.orientation() & 1) ? height : width; + m_icon_container.setMaxTotalSize(maxsize); + + if(*m_rc_alignment == FbTk::Container::LEFT || *m_rc_alignment == FbTk::Container::RIGHT) { + *m_rc_client_width = FbTk::Util::clamp(*m_rc_client_width, 10, 400); + m_icon_container.setMaxSizePerClient(*m_rc_client_width); + } else { + m_icon_container.setMaxSizePerClient(maxsize/std::max(1, m_icon_container.size())); + } +} + void IconbarTool::resize(unsigned int width, unsigned int height) { m_icon_container.resize(width, height); - const unsigned int maxsize = (m_icon_container.orientation() & 1) ? height : width; - m_icon_container.setMaxTotalSize(maxsize); - m_icon_container.setMaxSizePerClient(maxsize/std::max(1, m_icon_container.size())); + updateMaxSizes(width, height); renderTheme(); }

@@ -316,9 +333,7 @@ void IconbarTool::moveResize(int x, int y,

unsigned int width, unsigned int height) { m_icon_container.moveResize(x, y, width, height); - const unsigned int maxsize = (m_icon_container.orientation() & 1) ? height : width; - m_icon_container.setMaxTotalSize(maxsize); - m_icon_container.setMaxSizePerClient(maxsize/std::max(1, m_icon_container.size())); + updateMaxSizes(width, height); renderTheme(); }

@@ -438,10 +453,8 @@ break;

} m_resizeSig_timer.start(); - const unsigned int maxsize = (m_icon_container.orientation() & 1) ? height() : width(); - m_icon_container.setMaxTotalSize(maxsize); - m_icon_container.setMaxSizePerClient(maxsize/std::max(1, m_icon_container.size())); + updateMaxSizes(width(), height()); // unlock container and update graphics m_icon_container.setUpdateLock(false); m_icon_container.update();
M src/IconbarTool.hhsrc/IconbarTool.hh

@@ -98,6 +98,7 @@ void reset();

/// add icons to the list void updateList(); + void updateMaxSizes(unsigned int width, unsigned int height); /// called when the list emits a signal void update(UpdateReason reason, Focusable *win);