all repos — fluxbox @ df0c942aa2576a8edaae5a13ace01643729035ea

custom fork of the fluxbox windowmanager

cosmetic + avoid unneeded App::instance()->display() calls
akir akir
commit

df0c942aa2576a8edaae5a13ace01643729035ea

parent

a90fe37f9a3828eee54f6aeda4ebdb99b27d58d7

2 files changed, 41 insertions(+), 45 deletions(-)

jump to
M src/FbTk/ImageControl.ccsrc/FbTk/ImageControl.cc

@@ -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: ImageControl.cc,v 1.15 2004/09/09 21:13:10 akir Exp $ +// $Id: ImageControl.cc,v 1.16 2004/09/10 16:41:30 akir Exp $ #include "ImageControl.hh"

@@ -120,7 +120,7 @@ RefCount<Command> clean_cache(new SimpleCommand<ImageControl>(*this, &ImageControl::cleanCache));

m_timer.setCommand(clean_cache); m_timer.start(); } - + createColorTable(); }

@@ -140,7 +140,7 @@ delete [] grad_ybuffer;

} Display *disp = FbTk::App::instance()->display(); - + if (m_colors) { unsigned long *pixels = new unsigned long [m_num_colors];

@@ -167,7 +167,7 @@

Pixmap ImageControl::searchCache(unsigned int width, unsigned int height, const Texture &text) const { - + if (text.pixmap().drawable() != None) { // do comparsion with width/height and texture_pixmap CacheList::iterator it = cache.begin();

@@ -191,28 +191,28 @@ tmp.texture = text.type();

tmp.pixel1 = text.color().pixel(); tmp.pixel2 = text.colorTo().pixel(); */ - - 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 == text.type()) && - ((*it)->pixel1 == text.color().pixel())) { - if (text.type() & FbTk::Texture::GRADIENT) { - if ((*it)->pixel2 == text.colorTo().pixel()) { - (*it)->count++; - return (*it)->pixmap; - } - } else { - (*it)->count++; - return (*it)->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 == text.type()) && + ((*it)->pixel1 == text.color().pixel())) { + if (text.type() & FbTk::Texture::GRADIENT) { + if ((*it)->pixel2 == text.colorTo().pixel()) { + (*it)->count++; + return (*it)->pixmap; + } + } else { + (*it)->count++; + return (*it)->pixmap; + } + } } return None; - + }

@@ -250,7 +250,7 @@ tmp->pixel2 = texture.colorTo().pixel();

else tmp->pixel2 = 0l; - cache.push_back(tmp); + cache.push_back(tmp); if ((unsigned) cache.size() > cache_max) cleanCache();

@@ -343,10 +343,10 @@ }

void ImageControl::installRootColormap() { - XGrabServer(FbTk::App::instance()->display()); + Display *disp = FbTk::App::instance()->display(); + XGrabServer(disp); - Display *disp = FbTk::App::instance()->display(); bool install = true; int i = 0, ncmap = 0; Colormap *cmaps =

@@ -357,14 +357,14 @@ for (i = 0; i < ncmap; i++) {

if (*(cmaps + i) == m_colormap) install = false; } - + if (install) XInstallColormap(disp, m_colormap); XFree(cmaps); } - XUngrabServer(FbTk::App::instance()->display()); + XUngrabServer(disp); }

@@ -402,7 +402,7 @@ XFreePixmap(disp, tmp->pixmap);

deadlist.push_back(it); delete tmp; tmp=0; - } + } } std::list<CacheList::iterator>::iterator dead_it = deadlist.begin();

@@ -410,7 +410,7 @@ std::list<CacheList::iterator>::iterator dead_it_end = deadlist.end();

for (; dead_it != dead_it_end; ++dead_it) { cache.erase(*dead_it); } - + } void ImageControl::createColorTable() {

@@ -511,7 +511,7 @@ m_colors[i].flags = DoRed|DoGreen|DoBlue;

} } } - + for (unsigned int i = 0; i < m_num_colors; i++) { if (! XAllocColor(disp, m_colormap, &m_colors[i])) { fprintf(stderr, "couldn't alloc color %i %i %i\n",

@@ -520,7 +520,7 @@ m_colors[i].flags = 0;

} else m_colors[i].flags = DoRed|DoGreen|DoBlue; } - + XColor icolors[256]; unsigned int incolors = (((1 << m_screen_depth) > 256) ? 256 : (1 << m_screen_depth));

@@ -532,7 +532,7 @@ for (unsigned int i = 0; i < m_num_colors; i++) {

if (! m_colors[i].flags) { unsigned long chk = 0xffffffff, pixel, close = 0; char p = 2; - + while (p--) { for (unsigned int ii = 0; ii < incolors; ii++) { int r = (m_colors[i].red - icolors[i].red) >> 8;
M src/FbTk/MenuIcon.ccsrc/FbTk/MenuIcon.cc

@@ -1,7 +1,7 @@

// MenuIcon.cc for FbTk - Fluxbox ToolKit // Copyright (c) 2004 Henrik Kinnunen (fluxgen at users.sourceforge.net) // and Simon Bowden (rathnor at users.sourceforge.net) -// +// // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation

@@ -20,7 +20,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: MenuIcon.cc,v 1.1 2004/06/07 22:28:39 fluxgen Exp $ +// $Id: MenuIcon.cc,v 1.2 2004/09/10 16:37:54 akir Exp $ #include "MenuIcon.hh"

@@ -39,7 +39,7 @@ m_pixmap = pm->pixmap().release();

m_mask = pm->mask().release(); delete pm; } - + } void MenuIcon::updateTheme(const MenuTheme &theme) {

@@ -51,12 +51,13 @@ delete pm;

} } -void MenuIcon::draw(FbDrawable &drawable, +void MenuIcon::draw(FbDrawable &drawable, const MenuTheme &theme, bool highlight, int x, int y, unsigned int width, unsigned int height) const { + Display *disp = FbTk::App::instance()->display(); if (height - 2*theme.bevelWidth() != m_pixmap.height() && !m_filename.empty()) { unsigned int scale_size = height - 2*theme.bevelWidth();

@@ -68,11 +69,8 @@ if (m_pixmap.drawable() != 0) {

GC gc = theme.frameTextGC().gc(); // enable clip mask - XSetClipMask(FbTk::App::instance()->display(), - gc, - m_mask.drawable()); - XSetClipOrigin(FbTk::App::instance()->display(), - gc, x + theme.bevelWidth(), y + theme.bevelWidth()); + XSetClipMask(disp, gc, m_mask.drawable()); + XSetClipOrigin(disp, gc, x + theme.bevelWidth(), y + theme.bevelWidth()); drawable.copyArea(m_pixmap.drawable(), gc,

@@ -81,9 +79,7 @@ x + theme.bevelWidth(), y + theme.bevelWidth(),

m_pixmap.width(), m_pixmap.height()); // restore clip mask - XSetClipMask(FbTk::App::instance()->display(), - gc, - None); + XSetClipMask(disp, gc, None); } FbTk::MenuItem::draw(drawable, theme, highlight, x, y, width, height); }