aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Lübking <thomas.luebking@gmail.com>2016-09-24 17:36:09 (GMT)
committerThomas Lübking <thomas.luebking@gmail.com>2016-10-02 13:53:24 (GMT)
commit93a91904e631c0ae95242c6de95bf8a1b3d90c20 (patch)
treeffe1500ad7ef11d8361bea73274a64b1f29ba957 /src
parent7d30d0007d4aed25be7c6b636a21a84855cd349d (diff)
downloadfluxbox-93a91904e631c0ae95242c6de95bf8a1b3d90c20.zip
fluxbox-93a91904e631c0ae95242c6de95bf8a1b3d90c20.tar.bz2
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
Diffstat (limited to 'src')
-rw-r--r--src/IconbarTool.cc16
-rw-r--r--src/IconbarTool.hh4
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,
287 FbTk::MemFun(*this, &IconbarTool::themeReconfigured)); 287 FbTk::MemFun(*this, &IconbarTool::themeReconfigured));
288 m_tracker.join(screen.reconfigureSig(), 288 m_tracker.join(screen.reconfigureSig(),
289 FbTk::MemFunIgnoreArgs(*this, &IconbarTool::updateIconifiedPattern)); 289 FbTk::MemFunIgnoreArgs(*this, &IconbarTool::updateIconifiedPattern));
290
291 m_resizeSig_timer.setTimeout(100 * FbTk::FbTime::IN_MILLISECONDS);
292 m_resizeSig_timer.fireOnce(true);
293 FbTk::RefCount<FbTk::Command<void> > ers(new FbTk::SimpleCommand<IconbarTool>(*this, &IconbarTool::emitResizeSig));
294 m_resizeSig_timer.setCommand(ers);
295
290 themeReconfigured(); 296 themeReconfigured();
291} 297}
292 298
@@ -360,7 +366,7 @@ void IconbarTool::setMode(string mode) {
360 } 366 }
361 reset(); 367 reset();
362 368
363 resizeSig().emit(); 369 m_resizeSig_timer.start();
364 370
365 // unlock graphics update 371 // unlock graphics update
366 m_icon_container.setUpdateLock(false); 372 m_icon_container.setUpdateLock(false);
@@ -372,6 +378,10 @@ void IconbarTool::setMode(string mode) {
372 m_menu.reconfigure(); 378 m_menu.reconfigure();
373} 379}
374 380
381void IconbarTool::emitResizeSig() {
382 resizeSig().emit();
383}
384
375unsigned int IconbarTool::width() const { 385unsigned int IconbarTool::width() const {
376 return m_icon_container.width(); 386 return m_icon_container.width();
377} 387}
@@ -427,7 +437,7 @@ void IconbarTool::update(UpdateReason reason, Focusable *win) {
427 break; 437 break;
428 } 438 }
429 439
430 resizeSig().emit(); 440 m_resizeSig_timer.start();
431 const unsigned int maxsize = (m_icon_container.orientation() & 1) ? height() : width(); 441 const unsigned int maxsize = (m_icon_container.orientation() & 1) ? height() : width();
432 m_icon_container.setMaxTotalSize(maxsize); 442 m_icon_container.setMaxTotalSize(maxsize);
433 m_icon_container.setMaxSizePerClient(maxsize/std::max(1, m_icon_container.size())); 443 m_icon_container.setMaxSizePerClient(maxsize/std::max(1, m_icon_container.size()));
@@ -482,7 +492,7 @@ void IconbarTool::insertWindow(Focusable &win, int pos) {
482 } 492 }
483 493
484 m_icon_container.insertItem(button, pos); 494 m_icon_container.insertItem(button, pos);
485 m_tracker.join(button->titleChanged(), FbTk::MemFun(resizeSig(), &FbTk::Signal<>::emit)); 495 m_tracker.join(button->titleChanged(), FbTk::MemFun(m_resizeSig_timer, &FbTk::Timer::start));
486} 496}
487 497
488void IconbarTool::reset() { 498void 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 @@
29#include "FbTk/Container.hh" 29#include "FbTk/Container.hh"
30#include "FbTk/CachedPixmap.hh" 30#include "FbTk/CachedPixmap.hh"
31#include "FbTk/Resource.hh" 31#include "FbTk/Resource.hh"
32#include "FbTk/Timer.hh"
32 33
33#include <map> 34#include <map>
34 35
@@ -104,6 +105,9 @@ private:
104 105
105 void themeReconfigured(); 106 void themeReconfigured();
106 107
108 FbTk::Timer m_resizeSig_timer;
109 void emitResizeSig();
110
107 BScreen &m_screen; 111 BScreen &m_screen;
108 FbTk::Container m_icon_container; 112 FbTk::Container m_icon_container;
109 IconbarTheme &m_theme; 113 IconbarTheme &m_theme;