all repos — fluxbox @ cdc6210bfe53ca05eae93e48e52a1ffed3a9b610

custom fork of the fluxbox windowmanager

replaced LinkedList with stl container
fluxgen fluxgen
commit

cdc6210bfe53ca05eae93e48e52a1ffed3a9b610

parent

0c4c33f9f595818868dc83f8582909f68dd7efdd

4 files changed, 62 insertions(+), 67 deletions(-)

jump to
M src/Image.ccsrc/Image.cc

@@ -25,7 +25,7 @@

// stupid macros needed to access some functions in version 2 of the GNU C // library -// $Id: Image.cc,v 1.3 2002/01/09 14:11:20 fluxgen Exp $ +// $Id: Image.cc,v 1.4 2002/02/04 22:41:27 fluxgen Exp $ #ifndef _GNU_SOURCE #define _GNU_SOURCE

@@ -2188,8 +2188,6 @@ getVisual()->c_class);

throw static_cast<int>(1); //throw error code 1 } - - cache = new LinkedList<Cache>; }

@@ -2218,8 +2216,7 @@

delete [] colors; } - if (cache->count()) { - int i, n = cache->count(); + if (cache.size() > 0) { fprintf(stderr, I18n::instance()-> getMessage(

@@ -2229,48 +2226,44 @@ #else // !NLS

0, 0, #endif // NLS "BImageContol::~BImageControl: pixmap cache - " - "releasing %d pixmaps\n"), n); + "releasing %d pixmaps\n"), cache.size()); - for (i = 0; i < n; i++) { - Cache *tmp = cache->first(); - XFreePixmap(basedisplay->getXDisplay(), tmp->pixmap); - cache->remove(tmp); - delete tmp; + CacheList::iterator it = cache.begin(); + CacheList::iterator it_end = cache.end(); + for (; it != it_end; ++it) { + XFreePixmap(basedisplay->getXDisplay(), (*it)->pixmap); + delete (*it); } #ifdef TIMEDCACHE if (timer) { - timer->stop(); delete timer; } #endif // TIMEDCACHE } - - delete cache; } Pixmap BImageControl::searchCache(unsigned int width, unsigned int height, unsigned long texture, BColor *c1, BColor *c2) { - if (cache->count()) { - LinkedListIterator<Cache> it(cache); - - for (; it.current(); it++) { - if ((it.current()->width == width) && - (it.current()->height == height) && - (it.current()->texture == texture) && - (it.current()->pixel1 == c1->getPixel())) - if (texture & BImage::GRADIENT) { - if (it.current()->pixel2 == c2->getPixel()) { - it.current()->count++; - return it.current()->pixmap; - } - } else { - it.current()->count++; - return it.current()->pixmap; - } - } + CacheList::iterator it = cache.begin(); + CacheList::iterator it_end = cache.end(); + for (; it != it_end; ++it) { + if (((*it)->width == width) && + ((*it)->height == height) && + ((*it)->texture == texture) && + ((*it)->pixel1 == c1->getPixel())) { + if (texture & BImage::GRADIENT) { + if ((*it)->pixel2 == c2->getPixel()) { + (*it)->count++; + return (*it)->pixmap; + } + } else { + (*it)->count++; + return (*it)->pixmap; + } + } } return None;

@@ -2303,9 +2296,9 @@ tmp->pixel2 = texture->getColorTo()->getPixel();

else tmp->pixel2 = 0l; - cache->insert(tmp); + cache.push_back(tmp); - if ((unsigned) cache->count() > cache_max) { + if ((unsigned) cache.size() > cache_max) { #ifdef DEBUG fprintf(stderr, I18n::instance()->

@@ -2331,22 +2324,21 @@

void BImageControl::removeImage(Pixmap pixmap) { if (pixmap) { - LinkedListIterator<Cache> it(cache); - for (; it.current(); it++) { - if (it.current()->pixmap == pixmap) { - Cache *tmp = it.current(); - - if (tmp->count) { - tmp->count--; + CacheList::iterator it = cache.begin(); + CacheList::iterator it_end = cache.end(); + for (; it != it_end; ++it) { + if ((*it)->pixmap == pixmap) { + if ((*it)->count) { + (*it)->count--; #ifdef TIMEDCACHE - if (! timer) timeout(); + if (! timer) timeout(); #else // !TIMEDCACHE - if (! tmp->count) timeout(); + if (! (*it)->count) timeout(); #endif // TIMEDCACHE - } + } - return; + return; } } }

@@ -2586,14 +2578,16 @@ }

void BImageControl::timeout(void) { - LinkedListIterator<Cache> it(cache); - for (; it.current(); it++) { - Cache *tmp = it.current(); + CacheList::iterator it = cache.begin(); + CacheList::iterator it_end = cache.end(); + for (; it != it_end; ++it) { + Cache *tmp = (*it); if (tmp->count <= 0) { XFreePixmap(basedisplay->getXDisplay(), tmp->pixmap); - cache->remove(tmp); + it = cache.erase(it); delete tmp; + if (it == it_end) break; } } }
M src/Image.hhsrc/Image.hh

@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Image.hh,v 1.3 2002/01/09 14:11:20 fluxgen Exp $ +// $Id: Image.hh,v 1.4 2002/02/04 22:41:27 fluxgen Exp $ #ifndef _IMAGE_HH_ #define _IMAGE_HH_

@@ -31,13 +31,9 @@ #include <X11/Xlib.h>

#include <X11/Xutil.h> #include "Timer.hh" - -#ifndef _BASEDISPLAY_HH_ #include "BaseDisplay.hh" -#endif -#ifndef _LINKEDLIST_HH_ -#include "LinkedList.hh" -#endif + +#include <list> class BImage; class BImageControl;

@@ -182,7 +178,9 @@ unsigned int count, width, height;

unsigned long pixel1, pixel2, texture; } Cache; - LinkedList<Cache> *cache; + typedef std::list<Cache *> CacheList; + + CacheList cache; protected:
M src/Toolbar.ccsrc/Toolbar.cc

@@ -503,18 +503,24 @@ if (Fluxbox::instance()->useIconBar()) {

if (!iconbar) { iconbar = new IconBar(screen, frame.window_label); if (screen->getIconCount()) { - LinkedListIterator<FluxboxWindow> it(screen->getIconList()); - for(; it.current(); it++) - addIcon(it.current()); + BScreen::Icons & l = screen->getIconList(); + BScreen::Icons::iterator it = l.begin(); + BScreen::Icons::iterator it_end = l.end(); + for(; it != it_end; ++it) { + addIcon(*it); + } } } else iconbar->reconfigure(); } else { if (iconbar) { - LinkedListIterator<FluxboxWindow> it(screen->getIconList()); - for (; it.current(); it++) - delIcon(it.current()); + BScreen::Icons & l = screen->getIconList(); + BScreen::Icons::iterator it = l.begin(); + BScreen::Icons::iterator it_end = l.end(); + for(; it != it_end; ++it) { + delIcon(*it); + } delete iconbar; iconbar = 0; }
M src/Toolbar.hhsrc/Toolbar.hh

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Toolbar.hh,v 1.5 2002/01/21 00:54:38 fluxgen Exp $ +// $Id: Toolbar.hh,v 1.6 2002/02/04 22:38:41 fluxgen Exp $ #ifndef _TOOLBAR_HH_ #define _TOOLBAR_HH_

@@ -27,9 +27,6 @@

#include <X11/Xlib.h> #ifndef _BASEMENU_HH_ #include "Basemenu.hh" -#endif -#ifndef _LINKEDLIST_HH_ -#include "LinkedList.hh" #endif #ifndef _TIMER_HH_ #include "Timer.hh"