aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-07-15 18:35:09 (GMT)
committerPaul Tagliamonte <paultag@fluxbox.org>2012-04-07 02:11:32 (GMT)
commite587b6e72987d3325ddd89d354a2aaec77fb1372 (patch)
tree559fe24de04351142c86d7419de846b5158b1b95 /src
parente5fb4814ae8946332f6eca6019372e2616701cbf (diff)
downloadfluxbox_paul-e587b6e72987d3325ddd89d354a2aaec77fb1372.zip
fluxbox_paul-e587b6e72987d3325ddd89d354a2aaec77fb1372.tar.bz2
Attach a modifiedSig handler to the session.cacheMax resource
Diffstat (limited to 'src')
-rw-r--r--src/FbTk/ImageControl.cc12
-rw-r--r--src/FbTk/ImageControl.hh3
-rw-r--r--src/Screen.cc4
-rw-r--r--src/fluxbox.hh2
4 files changed, 14 insertions, 7 deletions
diff --git a/src/FbTk/ImageControl.cc b/src/FbTk/ImageControl.cc
index 9eaec31..a745cf8 100644
--- a/src/FbTk/ImageControl.cc
+++ b/src/FbTk/ImageControl.cc
@@ -177,7 +177,7 @@ struct ImageControl::Cache {
177ImageControl::ImageControl(int screen_num, 177ImageControl::ImageControl(int screen_num,
178 int cpc, unsigned int 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), m_cache_max(cmax) {
181 181
182 Display *disp = FbTk::App::instance()->display(); 182 Display *disp = FbTk::App::instance()->display();
183 183
@@ -185,8 +185,6 @@ ImageControl::ImageControl(int screen_num,
185 m_visual = DefaultVisual(disp, screen_num); 185 m_visual = DefaultVisual(disp, screen_num);
186 m_colormap = DefaultColormap(disp, screen_num); 186 m_colormap = DefaultColormap(disp, screen_num);
187 187
188 cache_max = cmax;
189
190 RefCount<Command<void> > clean_cache(new SimpleCommand<ImageControl>(*this, &ImageControl::cleanCache)); 188 RefCount<Command<void> > clean_cache(new SimpleCommand<ImageControl>(*this, &ImageControl::cleanCache));
191 m_timer.setCommand(clean_cache); 189 m_timer.setCommand(clean_cache);
192 setCacheTimeout(cache_timeout); 190 setCacheTimeout(cache_timeout);
@@ -226,6 +224,12 @@ void ImageControl::setCacheTimeout(unsigned int cache_timeout) {
226 m_timer.stop(); 224 m_timer.stop();
227} 225}
228 226
227void ImageControl::setCacheMax(unsigned long cache_max) {
228 m_cache_max = cache_max;
229 if (cache.size() > m_cache_max)
230 cleanCache();
231}
232
229Pixmap ImageControl::searchCache(unsigned int width, unsigned int height, 233Pixmap ImageControl::searchCache(unsigned int width, unsigned int height,
230 const Texture &text, FbTk::Orientation orient) const { 234 const Texture &text, FbTk::Orientation orient) const {
231 235
@@ -326,7 +330,7 @@ Pixmap ImageControl::renderImage(unsigned int width, unsigned int height,
326 330
327 cache.push_back(tmp); 331 cache.push_back(tmp);
328 332
329 if (cache.size() > cache_max) 333 if (cache.size() > m_cache_max)
330 cleanCache(); 334 cleanCache();
331 335
332 return pixmap; 336 return pixmap;
diff --git a/src/FbTk/ImageControl.hh b/src/FbTk/ImageControl.hh
index 1795bbf..983b319 100644
--- a/src/FbTk/ImageControl.hh
+++ b/src/FbTk/ImageControl.hh
@@ -46,6 +46,7 @@ public:
46 virtual ~ImageControl(); 46 virtual ~ImageControl();
47 47
48 void setCacheTimeout(unsigned int cache_timeout); 48 void setCacheTimeout(unsigned int cache_timeout);
49 void setCacheMax(unsigned long cache_max);
49 50
50 int depth() const { return m_screen_depth; } 51 int depth() const { return m_screen_depth; }
51 int colorsPerChannel() const { return m_colors_per_channel; } 52 int colorsPerChannel() const { return m_colors_per_channel; }
@@ -112,7 +113,7 @@ private:
112 typedef std::list<Cache *> CacheList; 113 typedef std::list<Cache *> CacheList;
113 114
114 mutable CacheList cache; 115 mutable CacheList cache;
115 unsigned long cache_max; 116 unsigned long m_cache_max;
116}; 117};
117 118
118} // end namespace FbTk 119} // end namespace FbTk
diff --git a/src/Screen.cc b/src/Screen.cc
index c8f7801..7e3913a 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -387,11 +387,13 @@ 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->getCacheLifeResource(), fluxbox->getCacheMax())); 390 *fluxbox->getCacheLifeResource(), *fluxbox->getCacheMaxResource()));
391 imageControl().installRootColormap(); 391 imageControl().installRootColormap();
392 root_colormap_installed = true; 392 root_colormap_installed = true;
393 m_tracker.join(fluxbox->getCacheLifeResource().modifiedSig(), 393 m_tracker.join(fluxbox->getCacheLifeResource().modifiedSig(),
394 MemFun(imageControl(), &FbTk::ImageControl::setCacheTimeout)); 394 MemFun(imageControl(), &FbTk::ImageControl::setCacheTimeout));
395 m_tracker.join(fluxbox->getCacheMaxResource().modifiedSig(),
396 MemFun(imageControl(), &FbTk::ImageControl::setCacheMax));
395 397
396 m_root_theme.reset(new RootTheme(imageControl())); 398 m_root_theme.reset(new RootTheme(imageControl()));
397 m_root_theme->reconfigTheme(); 399 m_root_theme->reconfigTheme();
diff --git a/src/fluxbox.hh b/src/fluxbox.hh
index 92d6daf..20b25fb 100644
--- a/src/fluxbox.hh
+++ b/src/fluxbox.hh
@@ -130,7 +130,7 @@ public:
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 FbTk::UIntResource &getCacheLifeResource() { return m_rc_cache_life; } 132 FbTk::UIntResource &getCacheLifeResource() { return m_rc_cache_life; }
133 unsigned int getCacheMax() const { return *m_rc_cache_max; } 133 FbTk::UIntResource &getCacheMaxResource() { return m_rc_cache_max; }
134 134
135 135
136 void maskWindowEvents(Window w, FluxboxWindow *bw) 136 void maskWindowEvents(Window w, FluxboxWindow *bw)