diff options
-rw-r--r-- | src/FbTk/ImageControl.cc | 12 | ||||
-rw-r--r-- | src/FbTk/ImageControl.hh | 3 | ||||
-rw-r--r-- | src/Screen.cc | 4 | ||||
-rw-r--r-- | src/fluxbox.hh | 2 |
4 files changed, 14 insertions, 7 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 { | |||
177 | ImageControl::ImageControl(int screen_num, | 177 | ImageControl::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 | ||
227 | void ImageControl::setCacheMax(unsigned long cache_max) { | ||
228 | m_cache_max = cache_max; | ||
229 | if (cache.size() > m_cache_max) | ||
230 | cleanCache(); | ||
231 | } | ||
232 | |||
229 | Pixmap ImageControl::searchCache(unsigned int width, unsigned int height, | 233 | Pixmap 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 e3e6fce..931b356 100644 --- a/src/Screen.cc +++ b/src/Screen.cc | |||
@@ -413,11 +413,13 @@ 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->getCacheLifeResource(), fluxbox->getCacheMax())); | 416 | *fluxbox->getCacheLifeResource(), *fluxbox->getCacheMaxResource())); |
417 | imageControl().installRootColormap(); | 417 | imageControl().installRootColormap(); |
418 | root_colormap_installed = true; | 418 | root_colormap_installed = true; |
419 | m_tracker.join(fluxbox->getCacheLifeResource().modifiedSig(), | 419 | m_tracker.join(fluxbox->getCacheLifeResource().modifiedSig(), |
420 | MemFun(imageControl(), &FbTk::ImageControl::setCacheTimeout)); | 420 | MemFun(imageControl(), &FbTk::ImageControl::setCacheTimeout)); |
421 | m_tracker.join(fluxbox->getCacheMaxResource().modifiedSig(), | ||
422 | MemFun(imageControl(), &FbTk::ImageControl::setCacheMax)); | ||
421 | 423 | ||
422 | m_root_theme.reset(new RootTheme(imageControl())); | 424 | m_root_theme.reset(new RootTheme(imageControl())); |
423 | m_root_theme->reconfigTheme(); | 425 | m_root_theme->reconfigTheme(); |
diff --git a/src/fluxbox.hh b/src/fluxbox.hh index 1c6d10a..3e2e756 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) |