From: Dana Jansens Date: Sat, 6 Jul 2002 00:28:27 +0000 (+0000) Subject: was ending up using the wrong cache items. now i find and release it every time a... X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;ds=sidebyside;h=5282d92b627041047b2603b0c2d013c221f4dd56;p=chaz%2Fopenbox was ending up using the wrong cache items. now i find and release it every time a string is drawn --- diff --git a/src/Basemenu.cc b/src/Basemenu.cc index 5b4acdf0..b6b242b6 100644 --- a/src/Basemenu.cc +++ b/src/Basemenu.cc @@ -536,6 +536,7 @@ bool Basemenu::hasSubmenu(int index) { void Basemenu::drawItem(int index, bool highlight, bool clear, int x, int y, unsigned int w, unsigned int h) { + fprintf(stderr, "DRAW ITEM\n"); BasemenuItem *item = find(index); if (! item) return; @@ -628,6 +629,7 @@ void Basemenu::drawItem(int index, bool highlight, bool clear, } if (dotext && text) { + fprintf(stderr, "FONT: %s\nTEXT: %s\n", style->f_font->name().c_str(), text); style->f_font->drawString(menu.frame, text_x, text_y, (highlight ? style->h_text : (item->isEnabled() ? style->f_text : diff --git a/src/Font.cc b/src/Font.cc index f377c5eb..a3a42f49 100644 --- a/src/Font.cc +++ b/src/Font.cc @@ -61,9 +61,7 @@ BFont::BFont(Display *d, BScreen *screen, const string &family, int size, #endif // XFT _font(0), _fontset(0), - _fontset_extents(0), - _cache(0), - _item(0) { + _fontset_extents(0) { _valid = init(); } @@ -76,9 +74,7 @@ BFont::BFont(Display *d, BScreen *screen, const string &xlfd) : #endif // XFT _font(0), _fontset(0), - _fontset_extents(0), - _cache(0), - _item(0) { + _fontset_extents(0) { string int_xlfd; if (xlfd.empty()) int_xlfd = _fallback_font; @@ -160,9 +156,6 @@ BFont::~BFont() { XFreeFontSet(_display, _fontset); if (_font) XFreeFont(_display, _font); - - if (_item) - _cache->release(_item); } @@ -262,10 +255,8 @@ void BFont::drawString(Drawable d, int x, int y, const BColor &color, } #endif // XFT - if (! _cache) - _cache = color.display()->gcCache(); - if (! _item) - _item = _cache->find(color, _font, GXcopy, ClipByChildren); + BGCCache *_cache = color.display()->gcCache(); + BGCCacheItem *_item = _cache->find(color, _font, GXcopy, ClipByChildren); assert(_cache); assert(_item); @@ -278,6 +269,8 @@ void BFont::drawString(Drawable d, int x, int y, const BColor &color, XDrawString(_display, d, _item->gc(), x, _font->ascent + y, string.c_str(), string.size()); + + _cache->release(_item); } diff --git a/src/Font.hh b/src/Font.hh index 38c4b4f8..4f4624ed 100644 --- a/src/Font.hh +++ b/src/Font.hh @@ -87,9 +87,6 @@ private: bool createFont(void); bool parseFontString(const std::string &xlfd); - mutable BGCCache *_cache; - mutable BGCCacheItem *_item; - bool _valid; public: