repo: rxvt-unicode-sixel
action: commit
revision: 
path_from: 
revision_from: e2156e87226738be6e5c27de42e7ca895aaaa154:
path_to: 
revision_to: 
git.thebackupbox.net
rxvt-unicode-sixel
git clone git://git.thebackupbox.net/rxvt-unicode-sixel
commit e2156e87226738be6e5c27de42e7ca895aaaa154
Author: Marc Lehmann 
Date:   Sat Dec 13 12:24:33 2014 +0000

    *** empty log message ***

diff --git a/Changes b/Changes
index 48601413861ac62f852e87afa354c67f03271415..
index ..4a7a44d76f869d032b9a2c9ffaa2f23f637d17cf 100644
--- a/Changes
+++ b/Changes
@@ -36,6 +36,7 @@ TODO IMPL: recalc bg always on bg colour change
 TODO: document typical actions in rxvt.1.pod keysyms
 TODO: warn with a graphical message when env has been modified

+TODO: open question, what does the nested set_color calls in get_coplours actualyl do? we can fail, but we always allocyte a replacement color.
 	- NOTICE: this release updates terminfo.
 	- fix pixel droppings on overdraw when a secondary core font has the
           same height but different ascent.
@@ -86,6 +87,8 @@ TODO: warn with a graphical message when env has been modified
           only relevant for antique 8bpp frame buffers).
 	- do not specialcase 2 or 4 colour visuals, leading to
           simpler and actually more correct code.
+        - hopefully no longer leak colours on !truecolor visuals.
+        - use consistent method names (scr_recolour => scr_recolor).

 9.20 Sat Apr 26 16:22:27 CEST 2014
         - (libptytty) fix bug that prevented urxvtd from writing utmp
diff --git a/src/background.C b/src/background.C
index 5451b5f1f4dc00e8de1909acf915c8d93d6235bf..
index ..0ec1044fcd4e4146db42a13f95a43f7cc97ba50e 100644
--- a/src/background.C
+++ b/src/background.C
@@ -504,7 +504,7 @@ rxvt_term::bg_render ()
     render_image (fimage);
 # endif

-  scr_recolour (false);
+  scr_recolor (false);
   bg_flags |= BG_NEEDS_REFRESH;

   bg_valid_since = ev::now ();
diff --git a/src/command.C b/src/command.C
index 05e6f65addd6fe64f6010a2e9680ed2aa163b690..
index ..d212764bad0c1975747c0a76a7f140c9e9acf3dc 100644
--- a/src/command.C
+++ b/src/command.C
@@ -1241,7 +1241,7 @@ void ecb_cold
 rxvt_term::pointer_unblank ()
 {
   XDefineCursor (dpy, vt, TermWin_cursor);
-  recolour_cursor ();
+  recolor_cursor ();

 #ifdef POINTER_BLANK
   hidden_pointer = 0;
@@ -1781,7 +1781,7 @@ rxvt_term::focus_in ()
       if (rs[Rs_fade])
         {
           pix_colors = pix_colors_focused;
-          scr_recolour ();
+          scr_recolor ();
         }
 #endif
 #if ENABLE_FRILLS
@@ -1828,7 +1828,7 @@ rxvt_term::focus_out ()
       if (rs[Rs_fade])
         {
           pix_colors = pix_colors_unfocused;
-          scr_recolour ();
+          scr_recolor ();
         }
 #endif

@@ -1837,11 +1837,14 @@ rxvt_term::focus_out ()
 }

 void ecb_cold
-rxvt_term::update_fade_color (unsigned int idx)
+rxvt_term::update_fade_color (unsigned int idx, bool first_time)
 {
 #if OFF_FOCUS_FADING
   if (rs[Rs_fade])
     {
+      if (!first_time)
+        pix_colors_focused [idx].free (this);
+
       rgba c;
       pix_colors [Color_fade].get (c);
       pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c);
diff --git a/src/init.C b/src/init.C
index 301b6b2ba3a799e42b11928b7beebc8a8bb5b70b..
index ..52fc9e215fd4d074bb5b12e7a225ab53c18a3dbb 100644
--- a/src/init.C
+++ b/src/init.C
@@ -1058,7 +1058,7 @@ rxvt_term::init_command (const char *const *argv)

 /*----------------------------------------------------------------------*/
 void
-rxvt_term::get_colours ()
+rxvt_term::get_colors ()
 {
   int i;

@@ -1066,7 +1066,7 @@ rxvt_term::get_colours ()
   pix_colors = pix_colors_focused;
 #endif

-  for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++)
+  for (i = 0; i < NRS_COLORS; i++)
     {
       const char *name = rs[Rs_color + i];

@@ -1087,6 +1087,8 @@ rxvt_term::get_colours ()
           if (!name)
             continue;

+          xcol.free (this);
+
           if (!set_color (xcol, name))
             {
               switch (i)
@@ -1115,13 +1117,6 @@ rxvt_term::get_colours ()
       rs[Rs_color + i] = name;
     }

-  if (depth <= 2)
-    {
-      if (!rs[Rs_color + Color_pointer_fg]) alias_color (Color_pointer_fg, Color_fg);
-      if (!rs[Rs_color + Color_pointer_bg]) alias_color (Color_pointer_bg, Color_bg);
-      if (!rs[Rs_color + Color_border]    ) alias_color (Color_border,     Color_fg);
-    }
-
   /*
    * get scrollBar shadow colors
    *
@@ -1129,35 +1124,25 @@ rxvt_term::get_colours ()
    * from the fvwm window manager.
    */
 #ifdef RXVT_SCROLLBAR
-  if (depth <= 2)
-    {
-      /* Monochrome */
-      alias_color (Color_scroll,       Color_fg);
-      alias_color (Color_topShadow,    Color_bg);
-      alias_color (Color_bottomShadow, Color_bg);
-    }
-  else
-    {
-      pix_colors [Color_scroll].fade (this, 50, pix_colors [Color_bottomShadow]);
-
-      rgba cscroll;
-      pix_colors [Color_scroll].get (cscroll);
-
-      /* topShadowColor */
-      if (!pix_colors[Color_topShadow].set (this,
-                       rgba (
-                         min ((int)rgba::MAX_CC, max (cscroll.r / 5, cscroll.r) * 7 / 5),
-                         min ((int)rgba::MAX_CC, max (cscroll.g / 5, cscroll.g) * 7 / 5),
-                         min ((int)rgba::MAX_CC, max (cscroll.b / 5, cscroll.b) * 7 / 5),
-                         cscroll.a)
-                       ))
-        alias_color (Color_topShadow, Color_White);
-    }
+  pix_colors [Color_scroll].fade (this, 50, pix_colors [Color_bottomShadow]);
+
+  rgba cscroll;
+  pix_colors [Color_scroll].get (cscroll);
+
+  /* topShadowColor */
+  if (!pix_colors[Color_topShadow].set (this,
+                   rgba (
+                     min ((int)rgba::MAX_CC, max (cscroll.r / 5, cscroll.r) * 7 / 5),
+                     min ((int)rgba::MAX_CC, max (cscroll.g / 5, cscroll.g) * 7 / 5),
+                     min ((int)rgba::MAX_CC, max (cscroll.b / 5, cscroll.b) * 7 / 5),
+                     cscroll.a)
+                   ))
+    alias_color (Color_topShadow, Color_White);
 #endif

 #ifdef OFF_FOCUS_FADING
-  for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++)
-    update_fade_color (i);
+  for (i = 0; i < NRS_COLORS; i++)
+    update_fade_color (i, true);
 #endif
 }

@@ -1346,7 +1331,7 @@ rxvt_term::create_windows (int argc, const char *const *argv)
   dLocal (Display *, dpy);

   /* grab colors before netscape does */
-  get_colours ();
+  get_colors ();

   if (!set_fonts ())
     rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n");
@@ -1509,7 +1494,7 @@ rxvt_term::create_windows (int argc, const char *const *argv)
 #endif

   pointer_unblank ();
-  scr_recolour ();
+  scr_recolor ();
 }

 /*----------------------------------------------------------------------*/
diff --git a/src/main.C b/src/main.C
index eb200df824bcb11a39026ad14ef49f4aa79197de..
index ..4b8b62d84e69c73c2fc0f99f1786f971d9a33566 100644
--- a/src/main.C
+++ b/src/main.C
@@ -944,8 +944,6 @@ void
 rxvt_term::set_window_color (int idx, const char *color)
 {
 #ifdef XTERM_COLOR_CHANGE
-  rxvt_color xcol;
-
   if (color == NULL || *color == '\0')
     return;

@@ -961,38 +959,32 @@ rxvt_term::set_window_color (int idx, const char *color)
       if (i >= 8 && i <= 15)
         {
           /* bright colors */
-          pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i - 8];
+          alias_color (idx, minBrightCOLOR + i - 8);
           goto done;
         }

       if (i >= 0 && i <= 7)
         {
           /* normal colors */
-          pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i];
+          alias_color (idx, minCOLOR + i);
           goto done;
         }
     }

-  set_color (xcol, color);
-
-  /*
-   * FIXME: should free colors here, but no idea how to do it so instead,
-   * so just keep gobbling up the colormap
-   */
-
-  pix_colors_focused[idx] = xcol;
+  pix_colors_focused[idx].free (this);
+  set_color (pix_colors_focused[idx], color);

 done:
   /*TODO: handle Color_BD, scrollbar background, etc. */

   update_fade_color (idx);
-  recolour_cursor ();
-  scr_recolour ();
+  recolor_cursor ();
+  scr_recolor ();
 #endif /* XTERM_COLOR_CHANGE */
 }

 void
-rxvt_term::recolour_cursor ()
+rxvt_term::recolor_cursor ()
 {
   XColor fg, bg;

diff --git a/src/perl/background b/src/perl/background
index 606a957f10f8af373c109b6b76ba643778dd4d20..
index ..bf81c6341131519d07aab09ccec9e58bd6cdeaa8 100644
--- a/src/perl/background
+++ b/src/perl/background
@@ -1188,7 +1188,7 @@ sub recalculate {
    # set background pixmap

    $self->set_background ($img, $self->{border});
-   $self->scr_recolour (0);
+   $self->scr_recolor (0);
    $self->want_refresh;
 }

diff --git a/src/rxvt.h b/src/rxvt.h
index ec381a7b773311918aff180c7e6e3e909482b838..
index ..e9fd1ae249d74b2b9a0936076a4228d2c2bb9773 100644
--- a/src/rxvt.h
+++ b/src/rxvt.h
@@ -1373,7 +1373,7 @@ struct rxvt_term : zero_initialized, rxvt_vars, rxvt_screen
 #else
   void set_urgency (bool enable) { }
 #endif
-  void update_fade_color (unsigned int idx);
+  void update_fade_color (unsigned int idx, bool first_time = false);
 #ifdef PRINTPIPE
   FILE *popen_printer ();
   int pclose_printer (FILE *stream);
@@ -1407,7 +1407,7 @@ struct rxvt_term : zero_initialized, rxvt_vars, rxvt_screen
   int run_child (const char *const *argv);
   void color_aliases (int idx);
   void create_windows (int argc, const char *const *argv);
-  void get_colours ();
+  void get_colors ();
   void get_ourmods ();
   void set_icon (const char *file);
   // main.C
@@ -1416,7 +1416,7 @@ struct rxvt_term : zero_initialized, rxvt_vars, rxvt_screen
   ~rxvt_term ();
   void destroy ();
   void emergency_cleanup ();
-  void recolour_cursor ();
+  void recolor_cursor ();
   void resize_all_windows (unsigned int newwidth, unsigned int newheight, int ignoreparent);
   void window_calc (unsigned int newwidth, unsigned int newheight);
   bool set_fonts ();
@@ -1492,7 +1492,7 @@ struct rxvt_term : zero_initialized, rxvt_vars, rxvt_screen
 #endif
   void scr_touch (bool refresh) NOTHROW;
   void scr_expose (int x, int y, int width, int height, bool refresh) NOTHROW;
-  void scr_recolour (bool refresh = true) NOTHROW;
+  void scr_recolor (bool refresh = true) NOTHROW;
   void scr_remap_chars () NOTHROW;
   void scr_remap_chars (line_t &l) NOTHROW;

diff --git a/src/rxvtperl.xs b/src/rxvtperl.xs
index 4fc0fb92c864f53e88f7e8740efdf1ff1f057ee0..
index ..822aad34db2c5d5ec11ad4ae492313d557236637 100644
--- a/src/rxvtperl.xs
+++ b/src/rxvtperl.xs
@@ -1997,7 +1997,7 @@ void
 rxvt_term::scr_bell ()

 void
-rxvt_term::scr_recolour (bool refresh = true);
+rxvt_term::scr_recolor (bool refresh = true);

 void
 rxvt_term::scr_change_screen (int screen)
diff --git a/src/screen.C b/src/screen.C
index c7271d154237a577891005f33b3f4b4123d5cdd0..
index ..1e941cf487badd513013a5c5cfc392cc6a52ec0c 100644
--- a/src/screen.C
+++ b/src/screen.C
@@ -2514,7 +2514,7 @@ rxvt_term::scr_remap_chars () NOTHROW
 }

 void ecb_cold
-rxvt_term::scr_recolour (bool refresh) NOTHROW
+rxvt_term::scr_recolor (bool refresh) NOTHROW
 {
   bool transparent = false;

-----END OF PAGE-----