previous fix for reverting iconbar to relative broke external tabs
Mark Tiefenbruck mark@fluxbox.org
3 files changed,
32 insertions(+),
22 deletions(-)
M
src/FbTk/Container.cc
→
src/FbTk/Container.cc
@@ -33,13 +33,14 @@ namespace FbTk {
typedef CompareEqual_base<FbWindow, Window> CompareWindow; -Container::Container(const FbWindow &parent): +Container::Container(const FbWindow &parent, bool auto_resize): FbWindow(parent, 0, 0, 1, 1, ExposureMask), m_orientation(ROT0), m_align(RELATIVE), m_max_size_per_client(60), m_max_total_size(0), - m_update_lock(false) { + m_update_lock(false), + m_auto_resize(auto_resize) { EventManager::instance()->add(*this, *this); }@@ -328,7 +329,7 @@ max_width_per_client = ( m_max_total_size - (num_items - 1)*borderW ) / num_items;
} else max_width_per_client = 1; } - if (total_width != cur_width) { + if (m_auto_resize && total_width != cur_width) { // calling Container::resize here risks infinite loops unsigned int neww = total_width, newh = height; translateSize(m_orientation, neww, newh);@@ -410,24 +411,31 @@ }
unsigned int Container::maxWidthPerClient() const { - unsigned int max_relative_size; - if (size() == 0) - max_relative_size = width(); - else { - unsigned int borderW = m_item_list.front()->borderWidth(); - // there're count-1 borders to fit in with the windows - // -> 1 per window plus end - unsigned int w = width(), h = height(); - translateSize(m_orientation, w, h); - max_relative_size = w < (size()-1)*borderW ? 1 : - (w - (size() - 1) * borderW) / size(); + switch (alignment()) { + case RIGHT: + case CENTER: + case LEFT: + return m_max_size_per_client; + break; + case RELATIVE: + if (size() == 0) + return width(); + else { + unsigned int borderW = m_item_list.front()->borderWidth(); + // there're count-1 borders to fit in with the windows + // -> 1 per window plus end + unsigned int w = width(), h = height(); + translateSize(m_orientation, w, h); + if (w < (size()-1)*borderW) + return 1; + else + return (w - (size() - 1) * borderW) / size(); + } + break; } - if (alignment() == RELATIVE) - return max_relative_size; - - return (m_max_size_per_client < max_relative_size ? - m_max_size_per_client : max_relative_size); + // this will never happen anyway + return 1; } void Container::for_each(std::mem_fun_t<void, FbWindow> function) {
M
src/FbTk/Container.hh
→
src/FbTk/Container.hh
@@ -43,7 +43,7 @@ typedef Button * Item;
typedef const Button * ConstItem; typedef std::list<Item> ItemList; - explicit Container(const FbWindow &parent); + explicit Container(const FbWindow &parent, bool auto_resize = true); virtual ~Container(); // manipulators@@ -106,7 +106,7 @@ Alignment m_align;
unsigned int m_max_size_per_client; unsigned int m_max_total_size; ItemList m_item_list; - bool m_update_lock; + bool m_update_lock, m_auto_resize; }; } // end namespace FbTk
M
src/IconbarTool.cc
→
src/IconbarTool.cc
@@ -249,7 +249,7 @@ FbTk::ThemeProxy<IconbarTheme> &unfocused_theme,
BScreen &screen, FbTk::Menu &menu): ToolbarItem(ToolbarItem::RELATIVE), m_screen(screen), - m_icon_container(parent), + m_icon_container(parent, false), m_theme(theme), m_focused_theme(focused_theme), m_unfocused_theme(unfocused_theme),@@ -307,6 +307,7 @@ }
void IconbarTool::resize(unsigned int width, unsigned int height) { m_icon_container.resize(width, height); + m_icon_container.setMaxTotalSize(m_icon_container.orientation() == FbTk::ROT0 || m_icon_container.orientation() ? width : height); renderTheme(); }@@ -314,6 +315,7 @@ void IconbarTool::moveResize(int x, int y,
unsigned int width, unsigned int height) { m_icon_container.moveResize(x, y, width, height); + m_icon_container.setMaxTotalSize(m_icon_container.orientation() == FbTk::ROT0 || m_icon_container.orientation() ? width : height); renderTheme(); }