From 93a91904e631c0ae95242c6de95bf8a1b3d90c20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Sat, 24 Sep 2016 19:36:09 +0200 Subject: compress resize signals typically buttons will call for this quite some, eg. when switching workspace or (now) when altering the focused window. This compresses various changes happening at the same time and re-layout the toolbar only once for them --- src/IconbarTool.cc | 16 +++++++++++++--- src/IconbarTool.hh | 4 ++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index 84c91ef..6e561dc 100644 --- a/src/IconbarTool.cc +++ b/src/IconbarTool.cc @@ -287,6 +287,12 @@ IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, FbTk::MemFun(*this, &IconbarTool::themeReconfigured)); m_tracker.join(screen.reconfigureSig(), FbTk::MemFunIgnoreArgs(*this, &IconbarTool::updateIconifiedPattern)); + + m_resizeSig_timer.setTimeout(100 * FbTk::FbTime::IN_MILLISECONDS); + m_resizeSig_timer.fireOnce(true); + FbTk::RefCount > ers(new FbTk::SimpleCommand(*this, &IconbarTool::emitResizeSig)); + m_resizeSig_timer.setCommand(ers); + themeReconfigured(); } @@ -360,7 +366,7 @@ void IconbarTool::setMode(string mode) { } reset(); - resizeSig().emit(); + m_resizeSig_timer.start(); // unlock graphics update m_icon_container.setUpdateLock(false); @@ -372,6 +378,10 @@ void IconbarTool::setMode(string mode) { m_menu.reconfigure(); } +void IconbarTool::emitResizeSig() { + resizeSig().emit(); +} + unsigned int IconbarTool::width() const { return m_icon_container.width(); } @@ -427,7 +437,7 @@ void IconbarTool::update(UpdateReason reason, Focusable *win) { break; } - resizeSig().emit(); + 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())); @@ -482,7 +492,7 @@ void IconbarTool::insertWindow(Focusable &win, int pos) { } m_icon_container.insertItem(button, pos); - m_tracker.join(button->titleChanged(), FbTk::MemFun(resizeSig(), &FbTk::Signal<>::emit)); + m_tracker.join(button->titleChanged(), FbTk::MemFun(m_resizeSig_timer, &FbTk::Timer::start)); } void IconbarTool::reset() { diff --git a/src/IconbarTool.hh b/src/IconbarTool.hh index 6044005..a461ce5 100644 --- a/src/IconbarTool.hh +++ b/src/IconbarTool.hh @@ -29,6 +29,7 @@ #include "FbTk/Container.hh" #include "FbTk/CachedPixmap.hh" #include "FbTk/Resource.hh" +#include "FbTk/Timer.hh" #include @@ -104,6 +105,9 @@ private: void themeReconfigured(); + FbTk::Timer m_resizeSig_timer; + void emitResizeSig(); + BScreen &m_screen; FbTk::Container m_icon_container; IconbarTheme &m_theme; -- cgit v0.11.2