*** empty log message ***
authorroot <root>
Tue, 31 Jan 2006 16:19:16 +0000 (16:19 +0000)
committerroot <root>
Tue, 31 Jan 2006 16:19:16 +0000 (16:19 +0000)
src/init.C
src/main.C
src/rxvttoolkit.C
src/rxvttoolkit.h

index 22526317ee9881049ece6cc7f7daa9d3b17487af..fe578e25116a8c262661636add2a33241fd2b81c 100644 (file)
@@ -705,7 +705,11 @@ rxvt_term::Get_Colours ()
 #ifdef OFF_FOCUS_FADING
   if (rs[Rs_fade])
     for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++)
-      pix_colors_unfocused[i] = pix_colors_focused[i].fade (this, atoi (rs[Rs_fade]), pix_colors[Color_fade]);
+      {
+        rxvt_rgba c;
+        pix_colors[Color_fade].get (this, c);
+        pix_colors_unfocused[i] = pix_colors_focused[i].fade (this, atoi (rs[Rs_fade]), c);
+      }
 #endif
 
   if (depth <= 2)
index d37523acd32b753a66b75eb46c90e86292b65172..d12e2b0360ee69b622a2a62acd89faff0a48a3fa 100644 (file)
@@ -944,7 +944,11 @@ done:
 
 #if OFF_FOCUS_FADING
   if (rs[Rs_fade])
-    pix_colors_unfocused[idx] = pix_colors_focused[idx].fade (this, atoi (rs[Rs_fade]), pix_colors[Color_fade]);
+    {
+      rxvt_rgba c;
+      pix_colors [Color_fade].get (this, c);
+      pix_colors_unfocused [idx] = pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), c);
+    }
 #endif
 
   /*TODO: handle Color_BD, scrollbar background, etc. */
index fe485c671a01dbfb3d9f2eddc38b156507b871df..897671362993cbd13ea0b9a8e3447a5ed1a90694 100644 (file)
@@ -562,7 +562,7 @@ refcache<rxvt_display> displays;
 /////////////////////////////////////////////////////////////////////////////
  
 bool
-rxvt_color::alloc (rxvt_screen *screen, rxvt_rgba rgba)
+rxvt_color::alloc (rxvt_screen *screen, const rxvt_rgba &color)
 {
 #if XFT
   XRenderPictFormat *format;
@@ -574,15 +574,15 @@ rxvt_color::alloc (rxvt_screen *screen, rxvt_rgba rgba)
       && (format = XRenderFindVisualFormat (screen->xdisp, screen->visual)))
     {
       // the fun lies in doing everything manually...
-      c.color.red   = rgba.r;
-      c.color.green = rgba.g;
-      c.color.blue  = rgba.b;
-      c.color.alpha = rgba.a;
+      c.color.red   = color.r;
+      c.color.green = color.g;
+      c.color.blue  = color.b;
+      c.color.alpha = color.a;
 
-      c.pixel = ((rgba.r * format->direct.redMask   / rxvt_rgba::MAX_CC) << format->direct.red  )
-              | ((rgba.g * format->direct.greenMask / rxvt_rgba::MAX_CC) << format->direct.green)
-              | ((rgba.b * format->direct.blueMask  / rxvt_rgba::MAX_CC) << format->direct.blue )
-              | ((rgba.a * format->direct.alphaMask / rxvt_rgba::MAX_CC) << format->direct.alpha);
+      c.pixel = ((color.r * format->direct.redMask   / rxvt_rgba::MAX_CC) << format->direct.red  )
+              | ((color.g * format->direct.greenMask / rxvt_rgba::MAX_CC) << format->direct.green)
+              | ((color.b * format->direct.blueMask  / rxvt_rgba::MAX_CC) << format->direct.blue )
+              | ((color.a * format->direct.alphaMask / rxvt_rgba::MAX_CC) << format->direct.alpha);
 
       return true;
     }
@@ -590,22 +590,22 @@ rxvt_color::alloc (rxvt_screen *screen, rxvt_rgba rgba)
     {
       XRenderColor d;
 
-      d.red   = rgba.r;
-      d.green = rgba.g;
-      d.blue  = rgba.b;
-      d.alpha = rgba.a;
+      d.red   = color.r;
+      d.green = color.g;
+      d.blue  = color.b;
+      d.alpha = color.a;
 
       return XftColorAllocValue (screen->xdisp, screen->visual, screen->cmap, &d, &c);
     }
 #else
   if (screen->visual->c_class == TrueColor || screen->visual->c_class == DirectColor)
     {
-      p = (rgba.r * (screen->visual->red_mask   >> ctz (screen->visual->red_mask  ))
-                  / rxvt_rgba::MAX_CC) << ctz (screen->visual->red_mask  )
-        | (rgba.g * (screen->visual->green_mask >> ctz (screen->visual->green_mask))
-                  / rxvt_rgba::MAX_CC) << ctz (screen->visual->green_mask)
-        | (rgba.b * (screen->visual->blue_mask  >> ctz (screen->visual->blue_mask ))
-                  / rxvt_rgba::MAX_CC) << ctz (screen->visual->blue_mask );
+      p = (color.r * (screen->visual->red_mask   >> ctz (screen->visual->red_mask  ))
+                   / rxvt_rgba::MAX_CC) << ctz (screen->visual->red_mask  )
+        | (color.g * (screen->visual->green_mask >> ctz (screen->visual->green_mask))
+                   / rxvt_rgba::MAX_CC) << ctz (screen->visual->green_mask)
+        | (color.b * (screen->visual->blue_mask  >> ctz (screen->visual->blue_mask ))
+                   / rxvt_rgba::MAX_CC) << ctz (screen->visual->blue_mask );
 
       return true;
     }
@@ -613,9 +613,9 @@ rxvt_color::alloc (rxvt_screen *screen, rxvt_rgba rgba)
     {
       XColor xc;
 
-      xc.red   = rgba.r;
-      xc.green = rgba.g;
-      xc.blue  = rgba.b;
+      xc.red   = color.r;
+      xc.green = color.g;
+      xc.blue  = color.b;
 
       if (XAllocColor (screen->xdisp, screen->cmap, &xc))
        {
@@ -623,7 +623,7 @@ rxvt_color::alloc (rxvt_screen *screen, rxvt_rgba rgba)
          return true;
        }
       else
-        p = (rgba.r + rgba.g + rgba.b) > 128*3
+        p = (color.r + color.g + color.b) > 128*3
             ? WhitePixelOfScreen (DefaultScreenOfDisplay (screen->xdisp))
             : BlackPixelOfScreen (DefaultScreenOfDisplay (screen->xdisp));
     }
@@ -679,9 +679,9 @@ rxvt_color::set (rxvt_screen *screen, const char *name)
 }
 
 bool
-rxvt_color::set (rxvt_screen *screen, rxvt_rgba rgba)
+rxvt_color::set (rxvt_screen *screen, const rxvt_rgba &color)
 {
-  bool got = alloc (screen, rgba);
+  bool got = alloc (screen, color);
 
 #if !ENABLE_MINIMAL
   int cmap_size = screen->visual->map_entries;
@@ -702,9 +702,9 @@ rxvt_color::set (rxvt_screen *screen, rxvt_rgba rgba)
 
       for (int i = 0; i < cmap_size; i++)
         {
-          int d = (squared_diff<int> (rgba.r >> 2, colors [i].red   >> 2))
-                + (squared_diff<int> (rgba.g >> 2, colors [i].green >> 2))
-                + (squared_diff<int> (rgba.b >> 2, colors [i].blue  >> 2));
+          int d = (squared_diff<int> (color.r >> 2, colors [i].red   >> 2))
+                + (squared_diff<int> (color.g >> 2, colors [i].green >> 2))
+                + (squared_diff<int> (color.b >> 2, colors [i].blue  >> 2));
 
           if (d < diff)
             {
@@ -714,7 +714,7 @@ rxvt_color::set (rxvt_screen *screen, rxvt_rgba rgba)
         }
 
       //rxvt_warn ("could not allocate %04x %04x %04x, getting %04x %04x %04x instead (%d)\n",
-      //    rgba.r, rgba.g, rgba.b, best->red, best->green, best->blue, diff);
+      //    color.r, color.g, color.b, best->red, best->green, best->blue, diff);
           
       got = alloc (screen, rxvt_rgba (best->red, best->green, best->blue));
 
@@ -726,23 +726,23 @@ rxvt_color::set (rxvt_screen *screen, rxvt_rgba rgba)
 }
 
 void
-rxvt_color::get (rxvt_screen *screen, rxvt_rgba &rgba)
+rxvt_color::get (rxvt_screen *screen, rxvt_rgba &color)
 {
 #if XFT
-  rgba.r = c.color.red;
-  rgba.g = c.color.green;
-  rgba.b = c.color.blue;
-  rgba.a = c.color.alpha;
+  color.r = c.color.red;
+  color.g = c.color.green;
+  color.b = c.color.blue;
+  color.a = c.color.alpha;
 #else
   XColor c;
 
   c.pixel = p;
   XQueryColor (screen->xdisp, screen->cmap, &c);
 
-  rgba.r = c.red;
-  rgba.g = c.green;
-  rgba.b = c.blue;
-  rgba.a = rxvt_rgba::MAX_CC;
+  color.r = c.red;
+  color.g = c.green;
+  color.b = c.blue;
+  color.a = rxvt_rgba::MAX_CC;
 #endif
 }
 
@@ -757,38 +757,19 @@ rxvt_color::free (rxvt_screen *screen)
 }
 
 rxvt_color
-rxvt_color::fade (rxvt_screen *screen, int percent)
+rxvt_color::fade (rxvt_screen *screen, int percent, const rxvt_rgba &to)
 {
-  rxvt_color faded;
-
   rxvt_rgba c;
   get (screen, c);
 
-  c.r = lerp (0, c.r, percent);
-  c.g = lerp (0, c.g, percent);
-  c.b = lerp (0, c.b, percent);
-
-  faded.set (screen, c);
-
-  return faded;
-}
-
-rxvt_color
-rxvt_color::fade (rxvt_screen *screen, int percent, rxvt_color &fadeto)
-{
-  rxvt_rgba c, fc;
   rxvt_color faded;
-  
-  get (screen, c);
-  fadeto.get (screen, fc);
-
   faded.set (
     screen,
     rxvt_rgba (
-      lerp (fc.r, c.r, percent),
-      lerp (fc.g, c.g, percent),
-      lerp (fc.b, c.b, percent),
-      lerp (fc.a, c.a, percent)
+      lerp (to.r, c.r, percent),
+      lerp (to.g, c.g, percent),
+      lerp (to.b, c.b, percent),
+      lerp (to.a, c.a, percent)
     )
   );
 
index 4d25101836f73161850b919d4f9f73760d5b5572..4ac66832f5cfea7155a50e86c06eb4a16b693c60 100644 (file)
@@ -249,16 +249,15 @@ struct rxvt_color {
   bool operator == (const rxvt_color &b) const { return Pixel (*this) == Pixel (b); }
   bool operator != (const rxvt_color &b) const { return Pixel (*this) != Pixel (b); }
 
-  bool alloc (rxvt_screen *screen, rxvt_rgba rgba);
+  bool alloc (rxvt_screen *screen, const rxvt_rgba &color);
   void free (rxvt_screen *screen);
 
-  void get (rxvt_screen *screen, rxvt_rgba &rgba);
+  void get (rxvt_screen *screen, rxvt_rgba &color);
  
   bool set (rxvt_screen *screen, const char *name);
-  bool set (rxvt_screen *screen, rxvt_rgba rgba);
+  bool set (rxvt_screen *screen, const rxvt_rgba &color);
 
-  rxvt_color fade (rxvt_screen *screen, int percent); // fades to black
-  rxvt_color fade (rxvt_screen *screen, int percent, rxvt_color &fadeto);
+  rxvt_color fade (rxvt_screen *screen, int percent, const rxvt_rgba &to = rxvt_rgba (0, 0, 0));
 };
 
 #endif