From 295bb1919bc748d369eb8b5597c1cd12577d3176 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Thu, 14 Jul 2011 14:56:25 +0200 Subject: Attach a modifiedSig handler to the session.cacheLife resource --- src/FbTk/ImageControl.cc | 18 +++++++++++------- src/FbTk/ImageControl.hh | 4 +++- src/Screen.cc | 4 +++- src/fluxbox.hh | 2 +- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/FbTk/ImageControl.cc b/src/FbTk/ImageControl.cc index c99ef9a..510ea35 100644 --- a/src/FbTk/ImageControl.cc +++ b/src/FbTk/ImageControl.cc @@ -175,7 +175,7 @@ struct ImageControl::Cache { }; ImageControl::ImageControl(int screen_num, - int cpc, unsigned long cache_timeout, unsigned long cmax): + int cpc, unsigned int cache_timeout, unsigned long cmax): m_colors_per_channel(cpc), m_screen_num(screen_num) { @@ -187,12 +187,9 @@ ImageControl::ImageControl(int screen_num, cache_max = cmax; - if (cache_timeout && s_timed_cache) { - m_timer.setTimeout(cache_timeout * FbTk::FbTime::IN_MILLISECONDS); - RefCount > clean_cache(new SimpleCommand(*this, &ImageControl::cleanCache)); - m_timer.setCommand(clean_cache); - m_timer.start(); - } + RefCount > clean_cache(new SimpleCommand(*this, &ImageControl::cleanCache)); + m_timer.setCommand(clean_cache); + setCacheTimeout(cache_timeout * FbTk::FbTime::IN_MILLISECONDS); createColorTable(); } @@ -221,6 +218,13 @@ ImageControl::~ImageControl() { } } +void ImageControl::setCacheTimeout(unsigned int cache_timeout) { + if (cache_timeout && s_timed_cache) { + m_timer.setTimeout(cache_timeout * 60000l); + m_timer.start(); + } else + m_timer.stop(); +} Pixmap ImageControl::searchCache(unsigned int width, unsigned int height, const Texture &text, FbTk::Orientation orient) const { diff --git a/src/FbTk/ImageControl.hh b/src/FbTk/ImageControl.hh index 747525b..1795bbf 100644 --- a/src/FbTk/ImageControl.hh +++ b/src/FbTk/ImageControl.hh @@ -42,9 +42,11 @@ class Texture; class ImageControl: private NotCopyable { public: ImageControl(int screen_num, int colors_per_channel = 4, - unsigned long cache_timeout = 300000l, unsigned long cache_max = 200l); + unsigned int cache_timeout = 5, unsigned long cache_max = 200l); virtual ~ImageControl(); + void setCacheTimeout(unsigned int cache_timeout); + int depth() const { return m_screen_depth; } int colorsPerChannel() const { return m_colors_per_channel; } size_t nrColors() const { return m_colors.size(); } diff --git a/src/Screen.cc b/src/Screen.cc index 6e74d88..e3e6fce 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -413,9 +413,11 @@ BScreen::BScreen(FbTk::ResourceManager_base &rm, // setup image cache engine m_image_control.reset(new FbTk::ImageControl(scrn, fluxbox->colorsPerChannel(), - fluxbox->getCacheLife(), fluxbox->getCacheMax())); + *fluxbox->getCacheLifeResource(), fluxbox->getCacheMax())); imageControl().installRootColormap(); root_colormap_installed = true; + m_tracker.join(fluxbox->getCacheLifeResource().modifiedSig(), + MemFun(imageControl(), &FbTk::ImageControl::setCacheTimeout)); m_root_theme.reset(new RootTheme(imageControl())); m_root_theme->reconfigTheme(); diff --git a/src/fluxbox.hh b/src/fluxbox.hh index c245d43..1c6d10a 100644 --- a/src/fluxbox.hh +++ b/src/fluxbox.hh @@ -129,7 +129,7 @@ public: time_t getAutoRaiseDelay() const { return *m_rc_auto_raise_delay; } - unsigned int getCacheLife() const { return *m_rc_cache_life * 60000; } + FbTk::UIntResource &getCacheLifeResource() { return m_rc_cache_life; } unsigned int getCacheMax() const { return *m_rc_cache_max; } -- cgit v0.11.2