Fixed the image cache when dealing with borders.
authorScott Moynes <smoynes@nexus.carleton.ca>
Sat, 1 Feb 2003 06:24:11 +0000 (06:24 +0000)
committerScott Moynes <smoynes@nexus.carleton.ca>
Sat, 1 Feb 2003 06:24:11 +0000 (06:24 +0000)
CHANGELOG
src/Image.hh
src/ImageControl.cc

index c6b9629ea5bc348ee7f5a2b10ef3de588e90556f..358f29c02f3ff63e07ad52b9469b21219a4566b8 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,9 @@
 Changelog for Openbox:
 
 2.2.4:
+ * Fixed a bug in the image cache that would draw      (Scott Moynes)
+   borders incorrectly in rare circumstances.
+
  * Draw window titles in the titlebars and toolbar with (Ben Jansens)
    UTF encoding when they are set with the NETWM (UTF)
    hints.
index 94cb3c6015507ef2b1527411cb154d16d41be4e6..b496b2aa54c659cf92ea689daaa1c2bb3d8fca18 100644 (file)
@@ -91,7 +91,7 @@ public:
     Pixmap pixmap;
 
     unsigned int count, width, height;
-    unsigned long pixel1, pixel2, texture;
+    unsigned long pixel1, pixel2, texture, borderColor;
   };
 
   BImageControl(BaseDisplay *dpy, const ScreenInfo *scrn,
@@ -160,7 +160,8 @@ private:
 
   Pixmap searchCache(const unsigned int width, const unsigned int height,
                      const unsigned long texture,
-                     const BColor &c1, const BColor &c2);
+                     const BColor &c1, const BColor &c2, 
+                     const BColor &borderColor);
 };
 
 
index c93a40f9cf5376e68d88575ec9800ce2e284e9d5..59387b004ac163313d0faf363a014d2d6de145e6 100644 (file)
@@ -394,7 +394,8 @@ BImageControl::~BImageControl(void) {
 Pixmap BImageControl::searchCache(const unsigned int width,
                                   const unsigned int height,
                                   const unsigned long texture,
-                                  const BColor &c1, const BColor &c2) {
+                                  const BColor &c1, const BColor &c2,
+                                  const BColor &bc) {
   if (cache.empty())
     return None;
 
@@ -404,11 +405,14 @@ Pixmap BImageControl::searchCache(const unsigned int width,
     CachedImage& tmp = *it;
     if (tmp.width == width && tmp.height == height &&
         tmp.texture == texture && tmp.pixel1 == c1.pixel())
-      if (texture & BTexture::Gradient) {
-        if (tmp.pixel2 == c2.pixel()) {
+      if (texture & BTexture::Gradient && tmp.pixel2 == c2.pixel()) {
+        if(texture & BTexture::Border && tmp.borderColor == bc.pixel()){
           tmp.count++;
           return tmp.pixmap;
         }
+      } else if(texture & BTexture::Border && tmp.borderColor == bc.pixel()){
+        tmp.count++;
+        return tmp.pixmap;
       } else {
         tmp.count++;
         return tmp.pixmap;
@@ -423,7 +427,8 @@ Pixmap BImageControl::renderImage(unsigned int width, unsigned int height,
   if (texture.texture() & BTexture::Parent_Relative) return ParentRelative;
 
   Pixmap pixmap = searchCache(width, height, texture.texture(),
-                             texture.color(), texture.colorTo());
+                             texture.color(), texture.colorTo(), 
+                              texture.borderColor());
   if (pixmap) return pixmap;
 
   BImage image(this, width, height);
@@ -446,6 +451,11 @@ Pixmap BImageControl::renderImage(unsigned int width, unsigned int height,
   else
     tmp.pixel2 = 0l;
 
+  if (texture.texture() & BTexture::Border)
+    tmp.borderColor = texture.borderColor().pixel();
+  else
+    tmp.borderColor = 0l;
+
   cache.push_back(tmp);
 
   if (cache.size() > cache_max) {