[hackers] [st] Reload colors in reset || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Fri, 02 Aug 2013 07:43:04 +0200

commit aaee0e8b28a353c215b6d1c8fc06d20038d7b426
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
Date: Sat Jul 20 21:52:40 2013 +0200

    Reload colors in reset
    
    Colors definition can be changed using a OSC sequence, so
    we have to reload them if we want be sure all the colors
    are the correct.
    
    Could be desirable free the colors allocated due to rgb
    colors and inverse colors (XftColorAllocValues in xdraws),
    but it is impossible due we use the same structure for all
    of them.

diff --git a/st.c b/st.c
index 097244c..362de23 100644
--- a/st.c
+++ b/st.c
_AT_@ -2428,6 +2428,7 @@ tputc(char *c, int len) {
                                 treset();
                                 term.esc = 0;
                                 xresettitle();
+ xloadcols();
                                 break;
                         case '=': /* DECPAM -- Application keypad */
                                 term.mode |= MODE_APPKEYPAD;
_AT_@ -2589,6 +2590,13 @@ void
 xloadcols(void) {
         int i, r, g, b;
         XRenderColor color = { .alpha = 0xffff };
+ static bool loaded;
+ Colour *cp;
+
+ if(loaded) {
+ for (cp = dc.col; cp < dc.col + LEN(dc.col); ++cp)
+ XftColorFree(xw.dpy, xw.vis, xw.cmap, cp);
+ }
 
         /* load colors [0-15] colors and [256-LEN(colorname)[ (config.h) */
         for(i = 0; i < LEN(colorname); i++) {
_AT_@ -2621,6 +2629,7 @@ xloadcols(void) {
                         die("Could not allocate color %d
", i);
                 }
         }
+ loaded = true;
 }
 
 int
Received on Fri Aug 02 2013 - 07:43:04 CEST

This archive was generated by hypermail 2.3.0 : Fri Aug 02 2013 - 07:48:27 CEST