summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-02-04 22:41:27 (GMT)
committerfluxgen <fluxgen>2002-02-04 22:41:27 (GMT)
commitcdc6210bfe53ca05eae93e48e52a1ffed3a9b610 (patch)
tree9384d79d65250831ade68d648c90127835755a67
parent0c4c33f9f595818868dc83f8582909f68dd7efdd (diff)
downloadfluxbox_lack-cdc6210bfe53ca05eae93e48e52a1ffed3a9b610.zip
fluxbox_lack-cdc6210bfe53ca05eae93e48e52a1ffed3a9b610.tar.bz2
replaced LinkedList with stl container
-rw-r--r--src/Image.cc92
-rw-r--r--src/Image.hh14
-rw-r--r--src/Toolbar.cc18
-rw-r--r--src/Toolbar.hh5
4 files changed, 62 insertions, 67 deletions
diff --git a/src/Image.cc b/src/Image.cc
index 611d307..ec0768a 100644
--- a/src/Image.cc
+++ b/src/Image.cc
@@ -25,7 +25,7 @@
25// stupid macros needed to access some functions in version 2 of the GNU C 25// stupid macros needed to access some functions in version 2 of the GNU C
26// library 26// library
27 27
28// $Id: Image.cc,v 1.3 2002/01/09 14:11:20 fluxgen Exp $ 28// $Id: Image.cc,v 1.4 2002/02/04 22:41:27 fluxgen Exp $
29 29
30#ifndef _GNU_SOURCE 30#ifndef _GNU_SOURCE
31#define _GNU_SOURCE 31#define _GNU_SOURCE
@@ -2188,8 +2188,6 @@ BImageControl::BImageControl(BaseDisplay *dpy, ScreenInfo *scrn, Bool _dither,
2188 throw static_cast<int>(1); //throw error code 1 2188 throw static_cast<int>(1); //throw error code 1
2189 2189
2190 } 2190 }
2191
2192 cache = new LinkedList<Cache>;
2193} 2191}
2194 2192
2195 2193
@@ -2218,8 +2216,7 @@ BImageControl::~BImageControl(void) {
2218 delete [] colors; 2216 delete [] colors;
2219 } 2217 }
2220 2218
2221 if (cache->count()) { 2219 if (cache.size() > 0) {
2222 int i, n = cache->count();
2223 fprintf(stderr, 2220 fprintf(stderr,
2224 I18n::instance()-> 2221 I18n::instance()->
2225 getMessage( 2222 getMessage(
@@ -2229,48 +2226,44 @@ BImageControl::~BImageControl(void) {
2229 0, 0, 2226 0, 0,
2230#endif // NLS 2227#endif // NLS
2231 "BImageContol::~BImageControl: pixmap cache - " 2228 "BImageContol::~BImageControl: pixmap cache - "
2232 "releasing %d pixmaps\n"), n); 2229 "releasing %d pixmaps\n"), cache.size());
2233 2230
2234 for (i = 0; i < n; i++) { 2231 CacheList::iterator it = cache.begin();
2235 Cache *tmp = cache->first(); 2232 CacheList::iterator it_end = cache.end();
2236 XFreePixmap(basedisplay->getXDisplay(), tmp->pixmap); 2233 for (; it != it_end; ++it) {
2237 cache->remove(tmp); 2234 XFreePixmap(basedisplay->getXDisplay(), (*it)->pixmap);
2238 delete tmp; 2235 delete (*it);
2239 } 2236 }
2240 2237
2241#ifdef TIMEDCACHE 2238#ifdef TIMEDCACHE
2242 if (timer) { 2239 if (timer) {
2243 timer->stop();
2244 delete timer; 2240 delete timer;
2245 } 2241 }
2246#endif // TIMEDCACHE 2242#endif // TIMEDCACHE
2247 } 2243 }
2248
2249 delete cache;
2250} 2244}
2251 2245
2252 2246
2253Pixmap BImageControl::searchCache(unsigned int width, unsigned int height, 2247Pixmap BImageControl::searchCache(unsigned int width, unsigned int height,
2254 unsigned long texture, 2248 unsigned long texture,
2255 BColor *c1, BColor *c2) { 2249 BColor *c1, BColor *c2) {
2256 if (cache->count()) { 2250 CacheList::iterator it = cache.begin();
2257 LinkedListIterator<Cache> it(cache); 2251 CacheList::iterator it_end = cache.end();
2258 2252 for (; it != it_end; ++it) {
2259 for (; it.current(); it++) { 2253 if (((*it)->width == width) &&
2260 if ((it.current()->width == width) && 2254 ((*it)->height == height) &&
2261 (it.current()->height == height) && 2255 ((*it)->texture == texture) &&
2262 (it.current()->texture == texture) && 2256 ((*it)->pixel1 == c1->getPixel())) {
2263 (it.current()->pixel1 == c1->getPixel())) 2257 if (texture & BImage::GRADIENT) {
2264 if (texture & BImage::GRADIENT) { 2258 if ((*it)->pixel2 == c2->getPixel()) {
2265 if (it.current()->pixel2 == c2->getPixel()) { 2259 (*it)->count++;
2266 it.current()->count++; 2260 return (*it)->pixmap;
2267 return it.current()->pixmap; 2261 }
2268 } 2262 } else {
2269 } else { 2263 (*it)->count++;
2270 it.current()->count++; 2264 return (*it)->pixmap;
2271 return it.current()->pixmap; 2265 }
2272 } 2266 }
2273 }
2274 } 2267 }
2275 2268
2276 return None; 2269 return None;
@@ -2303,9 +2296,9 @@ Pixmap BImageControl::renderImage(unsigned int width, unsigned int height,
2303 else 2296 else
2304 tmp->pixel2 = 0l; 2297 tmp->pixel2 = 0l;
2305 2298
2306 cache->insert(tmp); 2299 cache.push_back(tmp);
2307 2300
2308 if ((unsigned) cache->count() > cache_max) { 2301 if ((unsigned) cache.size() > cache_max) {
2309#ifdef DEBUG 2302#ifdef DEBUG
2310 fprintf(stderr, 2303 fprintf(stderr,
2311 I18n::instance()-> 2304 I18n::instance()->
@@ -2331,22 +2324,21 @@ Pixmap BImageControl::renderImage(unsigned int width, unsigned int height,
2331 2324
2332void BImageControl::removeImage(Pixmap pixmap) { 2325void BImageControl::removeImage(Pixmap pixmap) {
2333 if (pixmap) { 2326 if (pixmap) {
2334 LinkedListIterator<Cache> it(cache); 2327 CacheList::iterator it = cache.begin();
2335 for (; it.current(); it++) { 2328 CacheList::iterator it_end = cache.end();
2336 if (it.current()->pixmap == pixmap) { 2329 for (; it != it_end; ++it) {
2337 Cache *tmp = it.current(); 2330 if ((*it)->pixmap == pixmap) {
2338 2331 if ((*it)->count) {
2339 if (tmp->count) { 2332 (*it)->count--;
2340 tmp->count--;
2341 2333
2342#ifdef TIMEDCACHE 2334#ifdef TIMEDCACHE
2343 if (! timer) timeout(); 2335 if (! timer) timeout();
2344#else // !TIMEDCACHE 2336#else // !TIMEDCACHE
2345 if (! tmp->count) timeout(); 2337 if (! (*it)->count) timeout();
2346#endif // TIMEDCACHE 2338#endif // TIMEDCACHE
2347 } 2339 }
2348 2340
2349 return; 2341 return;
2350 } 2342 }
2351 } 2343 }
2352 } 2344 }
@@ -2586,14 +2578,16 @@ void BImageControl::parseColor(BColor *color, char *c) {
2586 2578
2587 2579
2588void BImageControl::timeout(void) { 2580void BImageControl::timeout(void) {
2589 LinkedListIterator<Cache> it(cache); 2581 CacheList::iterator it = cache.begin();
2590 for (; it.current(); it++) { 2582 CacheList::iterator it_end = cache.end();
2591 Cache *tmp = it.current(); 2583 for (; it != it_end; ++it) {
2584 Cache *tmp = (*it);
2592 2585
2593 if (tmp->count <= 0) { 2586 if (tmp->count <= 0) {
2594 XFreePixmap(basedisplay->getXDisplay(), tmp->pixmap); 2587 XFreePixmap(basedisplay->getXDisplay(), tmp->pixmap);
2595 cache->remove(tmp); 2588 it = cache.erase(it);
2596 delete tmp; 2589 delete tmp;
2590 if (it == it_end) break;
2597 } 2591 }
2598 } 2592 }
2599} 2593}
diff --git a/src/Image.hh b/src/Image.hh
index 672c632..7f7c746 100644
--- a/src/Image.hh
+++ b/src/Image.hh
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Image.hh,v 1.3 2002/01/09 14:11:20 fluxgen Exp $ 25// $Id: Image.hh,v 1.4 2002/02/04 22:41:27 fluxgen Exp $
26 26
27#ifndef _IMAGE_HH_ 27#ifndef _IMAGE_HH_
28#define _IMAGE_HH_ 28#define _IMAGE_HH_
@@ -31,13 +31,9 @@
31#include <X11/Xutil.h> 31#include <X11/Xutil.h>
32 32
33#include "Timer.hh" 33#include "Timer.hh"
34
35#ifndef _BASEDISPLAY_HH_
36#include "BaseDisplay.hh" 34#include "BaseDisplay.hh"
37#endif 35
38#ifndef _LINKEDLIST_HH_ 36#include <list>
39#include "LinkedList.hh"
40#endif
41 37
42class BImage; 38class BImage;
43class BImageControl; 39class BImageControl;
@@ -182,7 +178,9 @@ private:
182 unsigned long pixel1, pixel2, texture; 178 unsigned long pixel1, pixel2, texture;
183 } Cache; 179 } Cache;
184 180
185 LinkedList<Cache> *cache; 181 typedef std::list<Cache *> CacheList;
182
183 CacheList cache;
186 184
187 185
188protected: 186protected:
diff --git a/src/Toolbar.cc b/src/Toolbar.cc
index 29e3685..2415506 100644
--- a/src/Toolbar.cc
+++ b/src/Toolbar.cc
@@ -503,18 +503,24 @@ void Toolbar::reconfigure(void) {
503 if (!iconbar) { 503 if (!iconbar) {
504 iconbar = new IconBar(screen, frame.window_label); 504 iconbar = new IconBar(screen, frame.window_label);
505 if (screen->getIconCount()) { 505 if (screen->getIconCount()) {
506 LinkedListIterator<FluxboxWindow> it(screen->getIconList()); 506 BScreen::Icons & l = screen->getIconList();
507 for(; it.current(); it++) 507 BScreen::Icons::iterator it = l.begin();
508 addIcon(it.current()); 508 BScreen::Icons::iterator it_end = l.end();
509 for(; it != it_end; ++it) {
510 addIcon(*it);
511 }
509 } 512 }
510 513
511 } else 514 } else
512 iconbar->reconfigure(); 515 iconbar->reconfigure();
513 } else { 516 } else {
514 if (iconbar) { 517 if (iconbar) {
515 LinkedListIterator<FluxboxWindow> it(screen->getIconList()); 518 BScreen::Icons & l = screen->getIconList();
516 for (; it.current(); it++) 519 BScreen::Icons::iterator it = l.begin();
517 delIcon(it.current()); 520 BScreen::Icons::iterator it_end = l.end();
521 for(; it != it_end; ++it) {
522 delIcon(*it);
523 }
518 delete iconbar; 524 delete iconbar;
519 iconbar = 0; 525 iconbar = 0;
520 } 526 }
diff --git a/src/Toolbar.hh b/src/Toolbar.hh
index 9982b90..4872500 100644
--- a/src/Toolbar.hh
+++ b/src/Toolbar.hh
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: Toolbar.hh,v 1.5 2002/01/21 00:54:38 fluxgen Exp $ 22// $Id: Toolbar.hh,v 1.6 2002/02/04 22:38:41 fluxgen Exp $
23 23
24#ifndef _TOOLBAR_HH_ 24#ifndef _TOOLBAR_HH_
25#define _TOOLBAR_HH_ 25#define _TOOLBAR_HH_
@@ -28,9 +28,6 @@
28#ifndef _BASEMENU_HH_ 28#ifndef _BASEMENU_HH_
29#include "Basemenu.hh" 29#include "Basemenu.hh"
30#endif 30#endif
31#ifndef _LINKEDLIST_HH_
32#include "LinkedList.hh"
33#endif
34#ifndef _TIMER_HH_ 31#ifndef _TIMER_HH_
35#include "Timer.hh" 32#include "Timer.hh"
36#endif 33#endif