aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-07-15 18:35:09 (GMT)
committerPavel Labath <pavelo@centrum.sk>2013-02-18 21:04:22 (GMT)
commit996ad8d5cbba7b547e961362bbf549c98f28089f (patch)
tree18cdb841aaebe3e857d37e19cb870d9ae347ce61 /src/FbTk
parenteec6f0be03a95d7c108e4acce73c72bc575db260 (diff)
downloadfluxbox_pavel-996ad8d5cbba7b547e961362bbf549c98f28089f.zip
fluxbox_pavel-996ad8d5cbba7b547e961362bbf549c98f28089f.tar.bz2
Attach a modifiedSig handler to the session.cacheMax resource
Diffstat (limited to 'src/FbTk')
-rw-r--r--src/FbTk/ImageControl.cc12
-rw-r--r--src/FbTk/ImageControl.hh3
2 files changed, 10 insertions, 5 deletions
diff --git a/src/FbTk/ImageControl.cc b/src/FbTk/ImageControl.cc
index 510ea35..cd9774f 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 * FbTk::FbTime::IN_MILLISECONDS); 190 setCacheTimeout(cache_timeout * FbTk::FbTime::IN_MILLISECONDS);
@@ -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