]> Dogcows Code - chaz/openbox/blobdiff - otk/imagecontrol.cc
add the swig generated files
[chaz/openbox] / otk / imagecontrol.cc
index 7d091bb80cbbcee2fad15ced1487826f7dfc38a5..09823b8e2499e8f30ed8ee0d3dead765727de8b3 100644 (file)
@@ -1,4 +1,4 @@
-// -*- mode: C++; indent-tabs-mode: nil; -*-
+// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
 
 #ifdef    HAVE_CONFIG_H
 #  include "../config.h"
@@ -18,12 +18,13 @@ extern "C" {
 
 #include <algorithm>
 
-#include "blackbox.hh"
-#include "basedisplay.hh"
+#include "display.hh"
 #include "color.hh"
 #include "image.hh"
 #include "texture.hh"
 
+namespace otk {
+
 static unsigned long bsqrt(unsigned long x) {
   if (x <= 0) return 0;
   if (x == 1) return 1;
@@ -40,24 +41,24 @@ static unsigned long bsqrt(unsigned long x) {
 
 BImageControl *ctrl = 0;
 
-BImageControl::BImageControl(BaseDisplay *dpy, const ScreenInfo *scrn,
+BImageControl::BImageControl(OBTimerQueueManager *timermanager,
+                             const ScreenInfo *scrn,
                              bool _dither, int _cpc,
                              unsigned long cache_timeout,
                              unsigned long cmax) {
   if (! ctrl) ctrl = this;
 
-  basedisplay = dpy;
   screeninfo = scrn;
   setDither(_dither);
   setColorsPerChannel(_cpc);
 
   cache_max = cmax;
   if (cache_timeout) {
-    timer = new BTimer(basedisplay, this);
+    timer = new OBTimer(timermanager, (OBTimeoutHandler)timeout, this);
     timer->setTimeout(cache_timeout);
     timer->start();
   } else {
-    timer = (BTimer *) 0;
+    timer = (OBTimer *) 0;
   }
 
   colors = (XColor *) 0;
@@ -68,13 +69,13 @@ BImageControl::BImageControl(BaseDisplay *dpy, const ScreenInfo *scrn,
 
   sqrt_table = (unsigned long *) 0;
 
-  screen_depth = screeninfo->getDepth();
-  window = screeninfo->getRootWindow();
-  screen_number = screeninfo->getScreenNumber();
-  colormap = screeninfo->getColormap();
+  screen_depth = screeninfo->depth();
+  window = screeninfo->rootWindow();
+  screen_number = screeninfo->screen();
+  colormap = screeninfo->colormap();
 
   int count;
-  XPixmapFormatValues *pmv = XListPixmapFormats(basedisplay->getXDisplay(),
+  XPixmapFormatValues *pmv = XListPixmapFormats(OBDisplay::display,
                                                 &count);
   if (pmv) {
     bits_per_pixel = 0;
@@ -167,7 +168,7 @@ BImageControl::BImageControl(BaseDisplay *dpy, const ScreenInfo *scrn,
        }
 
     for (i = 0; i < ncolors; i++) {
-      if (! XAllocColor(basedisplay->getXDisplay(), colormap, &colors[i])) {
+      if (! XAllocColor(OBDisplay::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;
@@ -182,7 +183,7 @@ BImageControl::BImageControl(BaseDisplay *dpy, const ScreenInfo *scrn,
     for (i = 0; i < incolors; i++)
       icolors[i].pixel = i;
 
-    XQueryColors(basedisplay->getXDisplay(), colormap, icolors, incolors);
+    XQueryColors(OBDisplay::display, colormap, icolors, incolors);
     for (i = 0; i < ncolors; i++) {
       if (! colors[i].flags) {
        unsigned long chk = 0xffffffff, pixel, close = 0;
@@ -204,7 +205,7 @@ BImageControl::BImageControl(BaseDisplay *dpy, const ScreenInfo *scrn,
            colors[i].green = icolors[close].green;
            colors[i].blue = icolors[close].blue;
 
-           if (XAllocColor(basedisplay->getXDisplay(), colormap,
+           if (XAllocColor(OBDisplay::display, colormap,
                            &colors[i])) {
              colors[i].flags = DoRed|DoGreen|DoBlue;
              break;
@@ -261,7 +262,7 @@ BImageControl::BImageControl(BaseDisplay *dpy, const ScreenInfo *scrn,
       colors[i].blue = (i * 0xffff) / (colors_per_channel - 1);;
       colors[i].flags = DoRed|DoGreen|DoBlue;
 
-      if (! XAllocColor(basedisplay->getXDisplay(), colormap,
+      if (! XAllocColor(OBDisplay::display, colormap,
                        &colors[i])) {
        fprintf(stderr, "couldn't alloc color %i %i %i\n",
                colors[i].red, colors[i].green, colors[i].blue);
@@ -278,7 +279,7 @@ BImageControl::BImageControl(BaseDisplay *dpy, const ScreenInfo *scrn,
     for (i = 0; i < incolors; i++)
       icolors[i].pixel = i;
 
-    XQueryColors(basedisplay->getXDisplay(), colormap, icolors, incolors);
+    XQueryColors(OBDisplay::display, colormap, icolors, incolors);
     for (i = 0; i < ncolors; i++) {
       if (! colors[i].flags) {
        unsigned long chk = 0xffffffff, pixel, close = 0;
@@ -300,7 +301,7 @@ BImageControl::BImageControl(BaseDisplay *dpy, const ScreenInfo *scrn,
            colors[i].green = icolors[close].green;
            colors[i].blue = icolors[close].blue;
 
-           if (XAllocColor(basedisplay->getXDisplay(), colormap,
+           if (XAllocColor(OBDisplay::display, colormap,
                            &colors[i])) {
              colors[i].flags = DoRed|DoGreen|DoBlue;
              break;
@@ -334,7 +335,7 @@ BImageControl::~BImageControl(void) {
     for (int i = 0; i < ncolors; i++)
       *(pixels + i) = (*(colors + i)).pixel;
 
-    XFreeColors(basedisplay->getXDisplay(), colormap, pixels, ncolors, 0);
+    XFreeColors(OBDisplay::display, colormap, pixels, ncolors, 0);
 
     delete [] colors;
   }
@@ -347,7 +348,7 @@ BImageControl::~BImageControl(void) {
     CacheContainer::iterator it = cache.begin();
     const CacheContainer::iterator end = cache.end();
     for (; it != end; ++it)
-      XFreePixmap(basedisplay->getXDisplay(), it->pixmap);
+      XFreePixmap(OBDisplay::display, it->pixmap);
   }
   if (timer) {
     timer->stop();
@@ -419,7 +420,7 @@ Pixmap BImageControl::renderImage(unsigned int width, unsigned int height,
       "forcing cleanout\n");
 #endif // DEBUG
 
-    timeout();
+    timeout(this);
   }
 
   return pixmap;
@@ -439,7 +440,7 @@ void BImageControl::removeImage(Pixmap pixmap) {
   }
 
   if (! timer)
-    timeout();
+    timeout(this);
 }
 
 
@@ -498,7 +499,7 @@ void BImageControl::getGradientBuffers(unsigned int w,
 void BImageControl::installRootColormap(void) {
   int ncmap = 0;
   Colormap *cmaps =
-    XListInstalledColormaps(basedisplay->getXDisplay(), window, &ncmap);
+    XListInstalledColormaps(OBDisplay::display, window, &ncmap);
 
   if (cmaps) {
     bool install = True;
@@ -507,7 +508,7 @@ void BImageControl::installRootColormap(void) {
        install = False;
 
     if (install)
-      XInstallColormap(basedisplay->getXDisplay(), colormap);
+      XInstallColormap(OBDisplay::display, colormap);
 
     XFree(cmaps);
   }
@@ -543,19 +544,19 @@ struct ZeroRefCheck {
 };
 
 struct CacheCleaner {
-  Display *display;
   ZeroRefCheck ref_check;
-  CacheCleaner(Display *d): display(d) {}
+  CacheCleaner() {}
   inline void operator()(const BImageControl::CachedImage& image) const {
     if (ref_check(image))
-      XFreePixmap(display, image.pixmap);
+      XFreePixmap(OBDisplay::display, image.pixmap);
   }
 };
 
 
-void BImageControl::timeout(void) {
-  CacheCleaner cleaner(basedisplay->getXDisplay());
-  std::for_each(cache.begin(), cache.end(), cleaner);
-  cache.remove_if(cleaner.ref_check);
+void BImageControl::timeout(BImageControl *t) {
+  CacheCleaner cleaner;
+  std::for_each(t->cache.begin(), t->cache.end(), cleaner);
+  t->cache.remove_if(cleaner.ref_check);
 }
 
+}
This page took 0.030608 seconds and 4 git commands to generate.