Skip to content

Commit

Permalink
yay, the great STL conversion is almost done, LinkedList is now gone …
Browse files Browse the repository at this point in the history
…from the source
  • Loading branch information
shaleh committed Mar 13, 2002
1 parent 699daa1 commit 83b4b71
Show file tree
Hide file tree
Showing 12 changed files with 208 additions and 668 deletions.
235 changes: 119 additions & 116 deletions src/Basemenu.cc

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions src/Basemenu.hh
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,19 @@
#define __Basemenu_hh

#include <X11/Xlib.h>
#include <deque>

class Blackbox;
class BImageControl;
class BScreen;
class Basemenu;
class BasemenuItem;
#include "LinkedList.hh"


class Basemenu {
private:
LinkedList<BasemenuItem> *menuitems;
typedef std::deque<BasemenuItem*> MenuItems;
MenuItems menuitems;
Blackbox *blackbox;
Basemenu *parent;
BImageControl *image_ctrl;
Expand All @@ -60,7 +61,7 @@ private:


protected:
inline BasemenuItem *find(int index) { return menuitems->find(index); }
BasemenuItem *find(int index);
inline void setTitleVisibility(Bool b) { title_vis = b; }
inline void setMovable(Bool b) { movable = b; }
inline void setHideTree(Bool h) { hide_tree = h; }
Expand All @@ -87,14 +88,15 @@ public:

inline const char *getLabel(void) const { return menu.label; }

int insert(BasemenuItem *, int);
int insert(const char *, int = 0, const char * = (const char *) 0, int = -1);
int insert(const char **, int = -1, int = 0);
int insert(const char *, Basemenu *, int = -1);
int remove(int);

inline const int getX(void) const { return menu.x; }
inline const int getY(void) const { return menu.y; }
inline int getCount(void) { return menuitems->count(); }
inline int getCount(void) { return menuitems.size(); }
inline const int getCurrentSubmenu(void) const { return which_sub; }

inline const unsigned int getWidth(void) const { return menu.width; }
Expand Down
25 changes: 22 additions & 3 deletions src/ImageControl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
# include <ctype.h>
#endif // HAVE_CTYPE_H

#include <X11/Xlib.h>

#include <algorithm>

#include "blackbox.hh"
Expand Down Expand Up @@ -399,7 +401,7 @@ Pixmap BImageControl::searchCache(unsigned int width, unsigned int height,
CacheContainer::iterator it = cache.begin();
const CacheContainer::iterator end = cache.end();
for (; it != end; ++it) {
CachedImage &tmp = *it;
CachedImage& tmp = *it;
if ((tmp.width == width) && (tmp.height == height) &&
(tmp.texture == texture) && (tmp.pixel1 == c1->getPixel()))
if (texture & BImage_Gradient) {
Expand Down Expand Up @@ -710,7 +712,24 @@ struct ZeroRefCheck {
}
};

struct CacheCleaner {
Display *display;
CacheCleaner(Display *d): display(d) {}
void operator()(const BImageControl::CachedImage& image) const {
if (image.count == 0)
XFreePixmap(display, image.pixmap);
}
};

struct ZeroRefCount {
bool operator()(const BImageControl::CachedImage& image) const {
return (image.count == 0);
}
};

void BImageControl::timeout(void) {
cache.erase(std::remove_if(cache.begin(), cache.end(), ZeroRefCheck()),
cache.end());
std::for_each(cache.begin(), cache.end(),
CacheCleaner(basedisplay->getXDisplay()));
cache.remove_if(ZeroRefCount());
}

Loading

0 comments on commit 83b4b71

Please sign in to comment.