X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=otk%2Fimagecontrol.cc;h=ab8f5c50ca2bd03caf250d5f1ebcf67227351333;hb=00bc993775b916de76772bdc5e31618076194797;hp=4496c0d5a9326579d67471d115d1b6bd68a0c96a;hpb=8f8acc24933830d4f5784616b9b0c5896bde0b93;p=chaz%2Fopenbox diff --git a/otk/imagecontrol.cc b/otk/imagecontrol.cc index 4496c0d5..ab8f5c50 100644 --- a/otk/imagecontrol.cc +++ b/otk/imagecontrol.cc @@ -41,11 +41,10 @@ static unsigned long bsqrt(unsigned long x) { ImageControl *ctrl = 0; -ImageControl::ImageControl(TimerQueueManager *timermanager, - const ScreenInfo *scrn, - bool _dither, int _cpc, - unsigned long cache_timeout, - unsigned long cmax) { +ImageControl::ImageControl(const ScreenInfo *scrn, + bool _dither, int _cpc, + unsigned long cache_timeout, + unsigned long cmax) { if (! ctrl) ctrl = this; screeninfo = scrn; @@ -53,13 +52,10 @@ ImageControl::ImageControl(TimerQueueManager *timermanager, setColorsPerChannel(_cpc); cache_max = cmax; - if (cache_timeout) { - timer = new Timer(timermanager, (TimeoutHandler)timeout, this); - timer->setTimeout(cache_timeout); - timer->start(); - } else { + if (cache_timeout) + timer = new Timer(cache_timeout, (Timer::TimeoutHandler)timeout, this); + else timer = (Timer *) 0; - } colors = (XColor *) 0; ncolors = 0; @@ -75,7 +71,7 @@ ImageControl::ImageControl(TimerQueueManager *timermanager, colormap = screeninfo->colormap(); int count; - XPixmapFormatValues *pmv = XListPixmapFormats(Display::display, + XPixmapFormatValues *pmv = XListPixmapFormats(**display, &count); if (pmv) { bits_per_pixel = 0; @@ -168,7 +164,7 @@ ImageControl::ImageControl(TimerQueueManager *timermanager, } for (i = 0; i < ncolors; i++) { - if (! XAllocColor(Display::display, colormap, &colors[i])) { + if (! XAllocColor(**display, colormap, &colors[i])) { fprintf(stderr, "couldn't alloc color %i %i %i\n", colors[i].red, colors[i].green, colors[i].blue); colors[i].flags = 0; @@ -183,7 +179,7 @@ ImageControl::ImageControl(TimerQueueManager *timermanager, for (i = 0; i < incolors; i++) icolors[i].pixel = i; - XQueryColors(Display::display, colormap, icolors, incolors); + XQueryColors(**display, colormap, icolors, incolors); for (i = 0; i < ncolors; i++) { if (! colors[i].flags) { unsigned long chk = 0xffffffff, pixel, close = 0; @@ -205,7 +201,7 @@ ImageControl::ImageControl(TimerQueueManager *timermanager, colors[i].green = icolors[close].green; colors[i].blue = icolors[close].blue; - if (XAllocColor(Display::display, colormap, + if (XAllocColor(**display, colormap, &colors[i])) { colors[i].flags = DoRed|DoGreen|DoBlue; break; @@ -262,7 +258,7 @@ ImageControl::ImageControl(TimerQueueManager *timermanager, colors[i].blue = (i * 0xffff) / (colors_per_channel - 1);; colors[i].flags = DoRed|DoGreen|DoBlue; - if (! XAllocColor(Display::display, colormap, + if (! XAllocColor(**display, colormap, &colors[i])) { fprintf(stderr, "couldn't alloc color %i %i %i\n", colors[i].red, colors[i].green, colors[i].blue); @@ -279,7 +275,7 @@ ImageControl::ImageControl(TimerQueueManager *timermanager, for (i = 0; i < incolors; i++) icolors[i].pixel = i; - XQueryColors(Display::display, colormap, icolors, incolors); + XQueryColors(**display, colormap, icolors, incolors); for (i = 0; i < ncolors; i++) { if (! colors[i].flags) { unsigned long chk = 0xffffffff, pixel, close = 0; @@ -301,7 +297,7 @@ ImageControl::ImageControl(TimerQueueManager *timermanager, colors[i].green = icolors[close].green; colors[i].blue = icolors[close].blue; - if (XAllocColor(Display::display, colormap, + if (XAllocColor(**display, colormap, &colors[i])) { colors[i].flags = DoRed|DoGreen|DoBlue; break; @@ -335,7 +331,7 @@ ImageControl::~ImageControl(void) { for (int i = 0; i < ncolors; i++) *(pixels + i) = (*(colors + i)).pixel; - XFreeColors(Display::display, colormap, pixels, ncolors, 0); + XFreeColors(**display, colormap, pixels, ncolors, 0); delete [] colors; } @@ -348,12 +344,10 @@ ImageControl::~ImageControl(void) { CacheContainer::iterator it = cache.begin(); const CacheContainer::iterator end = cache.end(); for (; it != end; ++it) - XFreePixmap(Display::display, it->pixmap); + XFreePixmap(**display, it->pixmap); } - if (timer) { - timer->stop(); + if (timer) delete timer; - } } @@ -499,7 +493,7 @@ void ImageControl::getGradientBuffers(unsigned int w, void ImageControl::installRootColormap(void) { int ncmap = 0; Colormap *cmaps = - XListInstalledColormaps(Display::display, window, &ncmap); + XListInstalledColormaps(**display, window, &ncmap); if (cmaps) { bool install = True; @@ -508,7 +502,7 @@ void ImageControl::installRootColormap(void) { install = False; if (install) - XInstallColormap(Display::display, colormap); + XInstallColormap(**display, colormap); XFree(cmaps); } @@ -548,7 +542,7 @@ struct CacheCleaner { CacheCleaner() {} inline void operator()(const ImageControl::CachedImage& image) const { if (ref_check(image)) - XFreePixmap(Display::display, image.pixmap); + XFreePixmap(**display, image.pixmap); } };