aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk
diff options
context:
space:
mode:
authorakir <akir>2004-09-10 16:41:30 (GMT)
committerakir <akir>2004-09-10 16:41:30 (GMT)
commitdf0c942aa2576a8edaae5a13ace01643729035ea (patch)
tree5ef2a1526885539c70e6c2e8700898245df4c452 /src/FbTk
parenta90fe37f9a3828eee54f6aeda4ebdb99b27d58d7 (diff)
downloadfluxbox_paul-df0c942aa2576a8edaae5a13ace01643729035ea.zip
fluxbox_paul-df0c942aa2576a8edaae5a13ace01643729035ea.tar.bz2
cosmetic + avoid unneeded App::instance()->display() calls
Diffstat (limited to 'src/FbTk')
-rw-r--r--src/FbTk/ImageControl.cc66
-rw-r--r--src/FbTk/MenuIcon.cc20
2 files changed, 41 insertions, 45 deletions
diff --git a/src/FbTk/ImageControl.cc b/src/FbTk/ImageControl.cc
index e89b2cb..cd86c94 100644
--- a/src/FbTk/ImageControl.cc
+++ b/src/FbTk/ImageControl.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: ImageControl.cc,v 1.15 2004/09/09 21:13:10 akir Exp $ 25// $Id: ImageControl.cc,v 1.16 2004/09/10 16:41:30 akir Exp $
26 26
27#include "ImageControl.hh" 27#include "ImageControl.hh"
28 28
@@ -120,7 +120,7 @@ ImageControl::ImageControl(int screen_num, bool dither,
120 m_timer.setCommand(clean_cache); 120 m_timer.setCommand(clean_cache);
121 m_timer.start(); 121 m_timer.start();
122 } 122 }
123 123
124 createColorTable(); 124 createColorTable();
125} 125}
126 126
@@ -140,7 +140,7 @@ ImageControl::~ImageControl() {
140 } 140 }
141 141
142 Display *disp = FbTk::App::instance()->display(); 142 Display *disp = FbTk::App::instance()->display();
143 143
144 if (m_colors) { 144 if (m_colors) {
145 unsigned long *pixels = new unsigned long [m_num_colors]; 145 unsigned long *pixels = new unsigned long [m_num_colors];
146 146
@@ -167,7 +167,7 @@ ImageControl::~ImageControl() {
167 167
168Pixmap ImageControl::searchCache(unsigned int width, unsigned int height, 168Pixmap ImageControl::searchCache(unsigned int width, unsigned int height,
169 const Texture &text) const { 169 const Texture &text) const {
170 170
171 if (text.pixmap().drawable() != None) { 171 if (text.pixmap().drawable() != None) {
172 // do comparsion with width/height and texture_pixmap 172 // do comparsion with width/height and texture_pixmap
173 CacheList::iterator it = cache.begin(); 173 CacheList::iterator it = cache.begin();
@@ -191,28 +191,28 @@ Pixmap ImageControl::searchCache(unsigned int width, unsigned int height,
191 tmp.pixel1 = text.color().pixel(); 191 tmp.pixel1 = text.color().pixel();
192 tmp.pixel2 = text.colorTo().pixel(); 192 tmp.pixel2 = text.colorTo().pixel();
193 */ 193 */
194 194
195 CacheList::iterator it = cache.begin(); 195 CacheList::iterator it = cache.begin();
196 CacheList::iterator it_end = cache.end(); 196 CacheList::iterator it_end = cache.end();
197 for (; it != it_end; ++it) { 197 for (; it != it_end; ++it) {
198 if (((*it)->width == width) && 198 if (((*it)->width == width) &&
199 ((*it)->height == height) && 199 ((*it)->height == height) &&
200 ((*it)->texture == text.type()) && 200 ((*it)->texture == text.type()) &&
201 ((*it)->pixel1 == text.color().pixel())) { 201 ((*it)->pixel1 == text.color().pixel())) {
202 if (text.type() & FbTk::Texture::GRADIENT) { 202 if (text.type() & FbTk::Texture::GRADIENT) {
203 if ((*it)->pixel2 == text.colorTo().pixel()) { 203 if ((*it)->pixel2 == text.colorTo().pixel()) {
204 (*it)->count++; 204 (*it)->count++;
205 return (*it)->pixmap; 205 return (*it)->pixmap;
206 } 206 }
207 } else { 207 } else {
208 (*it)->count++; 208 (*it)->count++;
209 return (*it)->pixmap; 209 return (*it)->pixmap;
210 } 210 }
211 } 211 }
212 } 212 }
213 213
214 return None; 214 return None;
215 215
216} 216}
217 217
218 218
@@ -250,7 +250,7 @@ Pixmap ImageControl::renderImage(unsigned int width, unsigned int height,
250 else 250 else
251 tmp->pixel2 = 0l; 251 tmp->pixel2 = 0l;
252 252
253 cache.push_back(tmp); 253 cache.push_back(tmp);
254 254
255 if ((unsigned) cache.size() > cache_max) 255 if ((unsigned) cache.size() > cache_max)
256 cleanCache(); 256 cleanCache();
@@ -343,10 +343,10 @@ void ImageControl::getGradientBuffers(unsigned int w,
343 343
344 344
345void ImageControl::installRootColormap() { 345void ImageControl::installRootColormap() {
346 XGrabServer(FbTk::App::instance()->display());
347
348 346
349 Display *disp = FbTk::App::instance()->display(); 347 Display *disp = FbTk::App::instance()->display();
348 XGrabServer(disp);
349
350 bool install = true; 350 bool install = true;
351 int i = 0, ncmap = 0; 351 int i = 0, ncmap = 0;
352 Colormap *cmaps = 352 Colormap *cmaps =
@@ -357,14 +357,14 @@ void ImageControl::installRootColormap() {
357 if (*(cmaps + i) == m_colormap) 357 if (*(cmaps + i) == m_colormap)
358 install = false; 358 install = false;
359 } 359 }
360 360
361 if (install) 361 if (install)
362 XInstallColormap(disp, m_colormap); 362 XInstallColormap(disp, m_colormap);
363 363
364 XFree(cmaps); 364 XFree(cmaps);
365 } 365 }
366 366
367 XUngrabServer(FbTk::App::instance()->display()); 367 XUngrabServer(disp);
368} 368}
369 369
370 370
@@ -402,7 +402,7 @@ void ImageControl::cleanCache() {
402 deadlist.push_back(it); 402 deadlist.push_back(it);
403 delete tmp; 403 delete tmp;
404 tmp=0; 404 tmp=0;
405 } 405 }
406 } 406 }
407 407
408 std::list<CacheList::iterator>::iterator dead_it = deadlist.begin(); 408 std::list<CacheList::iterator>::iterator dead_it = deadlist.begin();
@@ -410,7 +410,7 @@ void ImageControl::cleanCache() {
410 for (; dead_it != dead_it_end; ++dead_it) { 410 for (; dead_it != dead_it_end; ++dead_it) {
411 cache.erase(*dead_it); 411 cache.erase(*dead_it);
412 } 412 }
413 413
414} 414}
415 415
416void ImageControl::createColorTable() { 416void ImageControl::createColorTable() {
@@ -511,7 +511,7 @@ void ImageControl::createColorTable() {
511 } 511 }
512 } 512 }
513 } 513 }
514 514
515 for (unsigned int i = 0; i < m_num_colors; i++) { 515 for (unsigned int i = 0; i < m_num_colors; i++) {
516 if (! XAllocColor(disp, m_colormap, &m_colors[i])) { 516 if (! XAllocColor(disp, m_colormap, &m_colors[i])) {
517 fprintf(stderr, "couldn't alloc color %i %i %i\n", 517 fprintf(stderr, "couldn't alloc color %i %i %i\n",
@@ -520,7 +520,7 @@ void ImageControl::createColorTable() {
520 } else 520 } else
521 m_colors[i].flags = DoRed|DoGreen|DoBlue; 521 m_colors[i].flags = DoRed|DoGreen|DoBlue;
522 } 522 }
523 523
524 XColor icolors[256]; 524 XColor icolors[256];
525 unsigned int incolors = (((1 << m_screen_depth) > 256) ? 256 : (1 << m_screen_depth)); 525 unsigned int incolors = (((1 << m_screen_depth) > 256) ? 256 : (1 << m_screen_depth));
526 526
@@ -532,7 +532,7 @@ void ImageControl::createColorTable() {
532 if (! m_colors[i].flags) { 532 if (! m_colors[i].flags) {
533 unsigned long chk = 0xffffffff, pixel, close = 0; 533 unsigned long chk = 0xffffffff, pixel, close = 0;
534 char p = 2; 534 char p = 2;
535 535
536 while (p--) { 536 while (p--) {
537 for (unsigned int ii = 0; ii < incolors; ii++) { 537 for (unsigned int ii = 0; ii < incolors; ii++) {
538 int r = (m_colors[i].red - icolors[i].red) >> 8; 538 int r = (m_colors[i].red - icolors[i].red) >> 8;
diff --git a/src/FbTk/MenuIcon.cc b/src/FbTk/MenuIcon.cc
index 168e056..bd9ed79 100644
--- a/src/FbTk/MenuIcon.cc
+++ b/src/FbTk/MenuIcon.cc
@@ -1,7 +1,7 @@
1// MenuIcon.cc for FbTk - Fluxbox ToolKit 1// MenuIcon.cc for FbTk - Fluxbox ToolKit
2// Copyright (c) 2004 Henrik Kinnunen (fluxgen at users.sourceforge.net) 2// Copyright (c) 2004 Henrik Kinnunen (fluxgen at users.sourceforge.net)
3// and Simon Bowden (rathnor at users.sourceforge.net) 3// and Simon Bowden (rathnor at users.sourceforge.net)
4// 4//
5// Permission is hereby granted, free of charge, to any person obtaining a 5// Permission is hereby granted, free of charge, to any person obtaining a
6// copy of this software and associated documentation files (the "Software"), 6// copy of this software and associated documentation files (the "Software"),
7// to deal in the Software without restriction, including without limitation 7// to deal in the Software without restriction, including without limitation
@@ -20,7 +20,7 @@
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE. 21// DEALINGS IN THE SOFTWARE.
22 22
23// $Id: MenuIcon.cc,v 1.1 2004/06/07 22:28:39 fluxgen Exp $ 23// $Id: MenuIcon.cc,v 1.2 2004/09/10 16:37:54 akir Exp $
24 24
25#include "MenuIcon.hh" 25#include "MenuIcon.hh"
26 26
@@ -39,7 +39,7 @@ MenuIcon::MenuIcon(const std::string &filename, const std::string &label, int sc
39 m_mask = pm->mask().release(); 39 m_mask = pm->mask().release();
40 delete pm; 40 delete pm;
41 } 41 }
42 42
43} 43}
44 44
45void MenuIcon::updateTheme(const MenuTheme &theme) { 45void MenuIcon::updateTheme(const MenuTheme &theme) {
@@ -51,12 +51,13 @@ void MenuIcon::updateTheme(const MenuTheme &theme) {
51 } 51 }
52} 52}
53 53
54void MenuIcon::draw(FbDrawable &drawable, 54void MenuIcon::draw(FbDrawable &drawable,
55 const MenuTheme &theme, 55 const MenuTheme &theme,
56 bool highlight, 56 bool highlight,
57 int x, int y, 57 int x, int y,
58 unsigned int width, unsigned int height) const { 58 unsigned int width, unsigned int height) const {
59 59
60 Display *disp = FbTk::App::instance()->display();
60 if (height - 2*theme.bevelWidth() != m_pixmap.height() && 61 if (height - 2*theme.bevelWidth() != m_pixmap.height() &&
61 !m_filename.empty()) { 62 !m_filename.empty()) {
62 unsigned int scale_size = height - 2*theme.bevelWidth(); 63 unsigned int scale_size = height - 2*theme.bevelWidth();
@@ -68,11 +69,8 @@ void MenuIcon::draw(FbDrawable &drawable,
68 GC gc = theme.frameTextGC().gc(); 69 GC gc = theme.frameTextGC().gc();
69 70
70 // enable clip mask 71 // enable clip mask
71 XSetClipMask(FbTk::App::instance()->display(), 72 XSetClipMask(disp, gc, m_mask.drawable());
72 gc, 73 XSetClipOrigin(disp, gc, x + theme.bevelWidth(), y + theme.bevelWidth());
73 m_mask.drawable());
74 XSetClipOrigin(FbTk::App::instance()->display(),
75 gc, x + theme.bevelWidth(), y + theme.bevelWidth());
76 74
77 drawable.copyArea(m_pixmap.drawable(), 75 drawable.copyArea(m_pixmap.drawable(),
78 gc, 76 gc,
@@ -81,9 +79,7 @@ void MenuIcon::draw(FbDrawable &drawable,
81 m_pixmap.width(), m_pixmap.height()); 79 m_pixmap.width(), m_pixmap.height());
82 80
83 // restore clip mask 81 // restore clip mask
84 XSetClipMask(FbTk::App::instance()->display(), 82 XSetClipMask(disp, gc, None);
85 gc,
86 None);
87 } 83 }
88 FbTk::MenuItem::draw(drawable, theme, highlight, x, y, width, height); 84 FbTk::MenuItem::draw(drawable, theme, highlight, x, y, width, height);
89} 85}