cosmetic + avoid unneeded App::instance()->display() calls
This commit is contained in:
parent
a90fe37f9a
commit
df0c942aa2
2 changed files with 41 additions and 45 deletions
|
@ -22,7 +22,7 @@
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// 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"
|
#include "ImageControl.hh"
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ ImageControl::ImageControl(int screen_num, bool dither,
|
||||||
m_timer.setCommand(clean_cache);
|
m_timer.setCommand(clean_cache);
|
||||||
m_timer.start();
|
m_timer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
createColorTable();
|
createColorTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ ImageControl::~ImageControl() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Display *disp = FbTk::App::instance()->display();
|
Display *disp = FbTk::App::instance()->display();
|
||||||
|
|
||||||
if (m_colors) {
|
if (m_colors) {
|
||||||
unsigned long *pixels = new unsigned long [m_num_colors];
|
unsigned long *pixels = new unsigned long [m_num_colors];
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ ImageControl::~ImageControl() {
|
||||||
|
|
||||||
Pixmap ImageControl::searchCache(unsigned int width, unsigned int height,
|
Pixmap ImageControl::searchCache(unsigned int width, unsigned int height,
|
||||||
const Texture &text) const {
|
const Texture &text) const {
|
||||||
|
|
||||||
if (text.pixmap().drawable() != None) {
|
if (text.pixmap().drawable() != None) {
|
||||||
// do comparsion with width/height and texture_pixmap
|
// do comparsion with width/height and texture_pixmap
|
||||||
CacheList::iterator it = cache.begin();
|
CacheList::iterator it = cache.begin();
|
||||||
|
@ -191,28 +191,28 @@ Pixmap ImageControl::searchCache(unsigned int width, unsigned int height,
|
||||||
tmp.pixel1 = text.color().pixel();
|
tmp.pixel1 = text.color().pixel();
|
||||||
tmp.pixel2 = text.colorTo().pixel();
|
tmp.pixel2 = text.colorTo().pixel();
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CacheList::iterator it = cache.begin();
|
CacheList::iterator it = cache.begin();
|
||||||
CacheList::iterator it_end = cache.end();
|
CacheList::iterator it_end = cache.end();
|
||||||
for (; it != it_end; ++it) {
|
for (; it != it_end; ++it) {
|
||||||
if (((*it)->width == width) &&
|
if (((*it)->width == width) &&
|
||||||
((*it)->height == height) &&
|
((*it)->height == height) &&
|
||||||
((*it)->texture == text.type()) &&
|
((*it)->texture == text.type()) &&
|
||||||
((*it)->pixel1 == text.color().pixel())) {
|
((*it)->pixel1 == text.color().pixel())) {
|
||||||
if (text.type() & FbTk::Texture::GRADIENT) {
|
if (text.type() & FbTk::Texture::GRADIENT) {
|
||||||
if ((*it)->pixel2 == text.colorTo().pixel()) {
|
if ((*it)->pixel2 == text.colorTo().pixel()) {
|
||||||
(*it)->count++;
|
(*it)->count++;
|
||||||
return (*it)->pixmap;
|
return (*it)->pixmap;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
(*it)->count++;
|
(*it)->count++;
|
||||||
return (*it)->pixmap;
|
return (*it)->pixmap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return None;
|
return None;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ Pixmap ImageControl::renderImage(unsigned int width, unsigned int height,
|
||||||
else
|
else
|
||||||
tmp->pixel2 = 0l;
|
tmp->pixel2 = 0l;
|
||||||
|
|
||||||
cache.push_back(tmp);
|
cache.push_back(tmp);
|
||||||
|
|
||||||
if ((unsigned) cache.size() > cache_max)
|
if ((unsigned) cache.size() > cache_max)
|
||||||
cleanCache();
|
cleanCache();
|
||||||
|
@ -343,10 +343,10 @@ void ImageControl::getGradientBuffers(unsigned int w,
|
||||||
|
|
||||||
|
|
||||||
void ImageControl::installRootColormap() {
|
void ImageControl::installRootColormap() {
|
||||||
XGrabServer(FbTk::App::instance()->display());
|
|
||||||
|
|
||||||
|
|
||||||
Display *disp = FbTk::App::instance()->display();
|
Display *disp = FbTk::App::instance()->display();
|
||||||
|
XGrabServer(disp);
|
||||||
|
|
||||||
bool install = true;
|
bool install = true;
|
||||||
int i = 0, ncmap = 0;
|
int i = 0, ncmap = 0;
|
||||||
Colormap *cmaps =
|
Colormap *cmaps =
|
||||||
|
@ -357,14 +357,14 @@ void ImageControl::installRootColormap() {
|
||||||
if (*(cmaps + i) == m_colormap)
|
if (*(cmaps + i) == m_colormap)
|
||||||
install = false;
|
install = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (install)
|
if (install)
|
||||||
XInstallColormap(disp, m_colormap);
|
XInstallColormap(disp, m_colormap);
|
||||||
|
|
||||||
XFree(cmaps);
|
XFree(cmaps);
|
||||||
}
|
}
|
||||||
|
|
||||||
XUngrabServer(FbTk::App::instance()->display());
|
XUngrabServer(disp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -402,7 +402,7 @@ void ImageControl::cleanCache() {
|
||||||
deadlist.push_back(it);
|
deadlist.push_back(it);
|
||||||
delete tmp;
|
delete tmp;
|
||||||
tmp=0;
|
tmp=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<CacheList::iterator>::iterator dead_it = deadlist.begin();
|
std::list<CacheList::iterator>::iterator dead_it = deadlist.begin();
|
||||||
|
@ -410,7 +410,7 @@ void ImageControl::cleanCache() {
|
||||||
for (; dead_it != dead_it_end; ++dead_it) {
|
for (; dead_it != dead_it_end; ++dead_it) {
|
||||||
cache.erase(*dead_it);
|
cache.erase(*dead_it);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageControl::createColorTable() {
|
void ImageControl::createColorTable() {
|
||||||
|
@ -511,7 +511,7 @@ void ImageControl::createColorTable() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int i = 0; i < m_num_colors; i++) {
|
for (unsigned int i = 0; i < m_num_colors; i++) {
|
||||||
if (! XAllocColor(disp, m_colormap, &m_colors[i])) {
|
if (! XAllocColor(disp, m_colormap, &m_colors[i])) {
|
||||||
fprintf(stderr, "couldn't alloc color %i %i %i\n",
|
fprintf(stderr, "couldn't alloc color %i %i %i\n",
|
||||||
|
@ -520,7 +520,7 @@ void ImageControl::createColorTable() {
|
||||||
} else
|
} else
|
||||||
m_colors[i].flags = DoRed|DoGreen|DoBlue;
|
m_colors[i].flags = DoRed|DoGreen|DoBlue;
|
||||||
}
|
}
|
||||||
|
|
||||||
XColor icolors[256];
|
XColor icolors[256];
|
||||||
unsigned int incolors = (((1 << m_screen_depth) > 256) ? 256 : (1 << m_screen_depth));
|
unsigned int incolors = (((1 << m_screen_depth) > 256) ? 256 : (1 << m_screen_depth));
|
||||||
|
|
||||||
|
@ -532,7 +532,7 @@ void ImageControl::createColorTable() {
|
||||||
if (! m_colors[i].flags) {
|
if (! m_colors[i].flags) {
|
||||||
unsigned long chk = 0xffffffff, pixel, close = 0;
|
unsigned long chk = 0xffffffff, pixel, close = 0;
|
||||||
char p = 2;
|
char p = 2;
|
||||||
|
|
||||||
while (p--) {
|
while (p--) {
|
||||||
for (unsigned int ii = 0; ii < incolors; ii++) {
|
for (unsigned int ii = 0; ii < incolors; ii++) {
|
||||||
int r = (m_colors[i].red - icolors[i].red) >> 8;
|
int r = (m_colors[i].red - icolors[i].red) >> 8;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// MenuIcon.cc for FbTk - Fluxbox ToolKit
|
// MenuIcon.cc for FbTk - Fluxbox ToolKit
|
||||||
// Copyright (c) 2004 Henrik Kinnunen (fluxgen at users.sourceforge.net)
|
// Copyright (c) 2004 Henrik Kinnunen (fluxgen at users.sourceforge.net)
|
||||||
// and Simon Bowden (rathnor at users.sourceforge.net)
|
// and Simon Bowden (rathnor at users.sourceforge.net)
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
// to deal in the Software without restriction, including without limitation
|
// to deal in the Software without restriction, including without limitation
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// 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"
|
#include "MenuIcon.hh"
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ MenuIcon::MenuIcon(const std::string &filename, const std::string &label, int sc
|
||||||
m_mask = pm->mask().release();
|
m_mask = pm->mask().release();
|
||||||
delete pm;
|
delete pm;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuIcon::updateTheme(const MenuTheme &theme) {
|
void MenuIcon::updateTheme(const MenuTheme &theme) {
|
||||||
|
@ -51,12 +51,13 @@ void MenuIcon::updateTheme(const MenuTheme &theme) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuIcon::draw(FbDrawable &drawable,
|
void MenuIcon::draw(FbDrawable &drawable,
|
||||||
const MenuTheme &theme,
|
const MenuTheme &theme,
|
||||||
bool highlight,
|
bool highlight,
|
||||||
int x, int y,
|
int x, int y,
|
||||||
unsigned int width, unsigned int height) const {
|
unsigned int width, unsigned int height) const {
|
||||||
|
|
||||||
|
Display *disp = FbTk::App::instance()->display();
|
||||||
if (height - 2*theme.bevelWidth() != m_pixmap.height() &&
|
if (height - 2*theme.bevelWidth() != m_pixmap.height() &&
|
||||||
!m_filename.empty()) {
|
!m_filename.empty()) {
|
||||||
unsigned int scale_size = height - 2*theme.bevelWidth();
|
unsigned int scale_size = height - 2*theme.bevelWidth();
|
||||||
|
@ -68,11 +69,8 @@ void MenuIcon::draw(FbDrawable &drawable,
|
||||||
GC gc = theme.frameTextGC().gc();
|
GC gc = theme.frameTextGC().gc();
|
||||||
|
|
||||||
// enable clip mask
|
// enable clip mask
|
||||||
XSetClipMask(FbTk::App::instance()->display(),
|
XSetClipMask(disp, gc, m_mask.drawable());
|
||||||
gc,
|
XSetClipOrigin(disp, gc, x + theme.bevelWidth(), y + theme.bevelWidth());
|
||||||
m_mask.drawable());
|
|
||||||
XSetClipOrigin(FbTk::App::instance()->display(),
|
|
||||||
gc, x + theme.bevelWidth(), y + theme.bevelWidth());
|
|
||||||
|
|
||||||
drawable.copyArea(m_pixmap.drawable(),
|
drawable.copyArea(m_pixmap.drawable(),
|
||||||
gc,
|
gc,
|
||||||
|
@ -81,9 +79,7 @@ void MenuIcon::draw(FbDrawable &drawable,
|
||||||
m_pixmap.width(), m_pixmap.height());
|
m_pixmap.width(), m_pixmap.height());
|
||||||
|
|
||||||
// restore clip mask
|
// restore clip mask
|
||||||
XSetClipMask(FbTk::App::instance()->display(),
|
XSetClipMask(disp, gc, None);
|
||||||
gc,
|
|
||||||
None);
|
|
||||||
}
|
}
|
||||||
FbTk::MenuItem::draw(drawable, theme, highlight, x, y, width, height);
|
FbTk::MenuItem::draw(drawable, theme, highlight, x, y, width, height);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue