aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-07-14 12:56:25 (GMT)
committerPavel Labath <pavelo@centrum.sk>2013-02-18 21:04:22 (GMT)
commit295bb1919bc748d369eb8b5597c1cd12577d3176 (patch)
treeb7782bada32a49febe4dc275216629e3528249bd /src
parent4ea546a91e7188ad6a95931637b7b928abd38342 (diff)
downloadfluxbox_pavel-295bb1919bc748d369eb8b5597c1cd12577d3176.zip
fluxbox_pavel-295bb1919bc748d369eb8b5597c1cd12577d3176.tar.bz2
Attach a modifiedSig handler to the session.cacheLife resource
Diffstat (limited to 'src')
-rw-r--r--src/FbTk/ImageControl.cc18
-rw-r--r--src/FbTk/ImageControl.hh4
-rw-r--r--src/Screen.cc4
-rw-r--r--src/fluxbox.hh2
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 {
175}; 175};
176 176
177ImageControl::ImageControl(int screen_num, 177ImageControl::ImageControl(int screen_num,
178 int cpc, unsigned long cache_timeout, unsigned long cmax): 178 int cpc, unsigned int cache_timeout, unsigned long cmax):
179 m_colors_per_channel(cpc), 179 m_colors_per_channel(cpc),
180 m_screen_num(screen_num) { 180 m_screen_num(screen_num) {
181 181
@@ -187,12 +187,9 @@ ImageControl::ImageControl(int screen_num,
187 187
188 cache_max = cmax; 188 cache_max = cmax;
189 189
190 if (cache_timeout && s_timed_cache) { 190 RefCount<Command<void> > clean_cache(new SimpleCommand<ImageControl>(*this, &ImageControl::cleanCache));
191 m_timer.setTimeout(cache_timeout * FbTk::FbTime::IN_MILLISECONDS); 191 m_timer.setCommand(clean_cache);
192 RefCount<Command<void> > clean_cache(new SimpleCommand<ImageControl>(*this, &ImageControl::cleanCache)); 192 setCacheTimeout(cache_timeout * FbTk::FbTime::IN_MILLISECONDS);
193 m_timer.setCommand(clean_cache);
194 m_timer.start();
195 }
196 193
197 createColorTable(); 194 createColorTable();
198} 195}
@@ -221,6 +218,13 @@ ImageControl::~ImageControl() {
221 } 218 }
222} 219}
223 220
221void ImageControl::setCacheTimeout(unsigned int cache_timeout) {
222 if (cache_timeout && s_timed_cache) {
223 m_timer.setTimeout(cache_timeout * 60000l);
224 m_timer.start();
225 } else
226 m_timer.stop();
227}
224 228
225Pixmap ImageControl::searchCache(unsigned int width, unsigned int height, 229Pixmap ImageControl::searchCache(unsigned int width, unsigned int height,
226 const Texture &text, FbTk::Orientation orient) const { 230 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;
42class ImageControl: private NotCopyable { 42class ImageControl: private NotCopyable {
43public: 43public:
44 ImageControl(int screen_num, int colors_per_channel = 4, 44 ImageControl(int screen_num, int colors_per_channel = 4,
45 unsigned long cache_timeout = 300000l, unsigned long cache_max = 200l); 45 unsigned int cache_timeout = 5, unsigned long cache_max = 200l);
46 virtual ~ImageControl(); 46 virtual ~ImageControl();
47 47
48 void setCacheTimeout(unsigned int cache_timeout);
49
48 int depth() const { return m_screen_depth; } 50 int depth() const { return m_screen_depth; }
49 int colorsPerChannel() const { return m_colors_per_channel; } 51 int colorsPerChannel() const { return m_colors_per_channel; }
50 size_t nrColors() const { return m_colors.size(); } 52 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,
413 // setup image cache engine 413 // setup image cache engine
414 m_image_control.reset(new FbTk::ImageControl(scrn, 414 m_image_control.reset(new FbTk::ImageControl(scrn,
415 fluxbox->colorsPerChannel(), 415 fluxbox->colorsPerChannel(),
416 fluxbox->getCacheLife(), fluxbox->getCacheMax())); 416 *fluxbox->getCacheLifeResource(), fluxbox->getCacheMax()));
417 imageControl().installRootColormap(); 417 imageControl().installRootColormap();
418 root_colormap_installed = true; 418 root_colormap_installed = true;
419 m_tracker.join(fluxbox->getCacheLifeResource().modifiedSig(),
420 MemFun(imageControl(), &FbTk::ImageControl::setCacheTimeout));
419 421
420 m_root_theme.reset(new RootTheme(imageControl())); 422 m_root_theme.reset(new RootTheme(imageControl()));
421 m_root_theme->reconfigTheme(); 423 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:
129 129
130 time_t getAutoRaiseDelay() const { return *m_rc_auto_raise_delay; } 130 time_t getAutoRaiseDelay() const { return *m_rc_auto_raise_delay; }
131 131
132 unsigned int getCacheLife() const { return *m_rc_cache_life * 60000; } 132 FbTk::UIntResource &getCacheLifeResource() { return m_rc_cache_life; }
133 unsigned int getCacheMax() const { return *m_rc_cache_max; } 133 unsigned int getCacheMax() const { return *m_rc_cache_max; }
134 134
135 135