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>2011-11-01 09:57:22 (GMT)
commite945aceb6aa71db200dfb8db659f3248bb62af68 (patch)
treeb1428d78b17dd9b1332fa02196d811d282a24e7f /src
parent70b63f6aee4a612e34c729d5d19e5b0e0626fc7e (diff)
downloadfluxbox_pavel-e945aceb6aa71db200dfb8db659f3248bb62af68.zip
fluxbox_pavel-e945aceb6aa71db200dfb8db659f3248bb62af68.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 a5e5cd1..9eaec31 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); 191 m_timer.setCommand(clean_cache);
192 RefCount<Command<void> > clean_cache(new SimpleCommand<ImageControl>(*this, &ImageControl::cleanCache)); 192 setCacheTimeout(cache_timeout);
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 e855727..701e38a 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -387,9 +387,11 @@ BScreen::BScreen(FbTk::ResourceManager_base &rm,
387 // setup image cache engine 387 // setup image cache engine
388 m_image_control.reset(new FbTk::ImageControl(scrn, 388 m_image_control.reset(new FbTk::ImageControl(scrn,
389 fluxbox->colorsPerChannel(), 389 fluxbox->colorsPerChannel(),
390 fluxbox->getCacheLife(), fluxbox->getCacheMax())); 390 *fluxbox->getCacheLifeResource(), fluxbox->getCacheMax()));
391 imageControl().installRootColormap(); 391 imageControl().installRootColormap();
392 root_colormap_installed = true; 392 root_colormap_installed = true;
393 m_tracker.join(fluxbox->getCacheLifeResource().modifiedSig(),
394 MemFun(imageControl(), &FbTk::ImageControl::setCacheTimeout));
393 395
394 m_root_theme.reset(new RootTheme(imageControl())); 396 m_root_theme.reset(new RootTheme(imageControl()));
395 m_root_theme->reconfigTheme(); 397 m_root_theme->reconfigTheme();
diff --git a/src/fluxbox.hh b/src/fluxbox.hh
index dc3b0b3..92d6daf 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