aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Lohmann <20h@r-36.net>2014-06-01 16:52:19 +0200
committerChristoph Lohmann <20h@r-36.net>2014-06-01 16:52:19 +0200
commit8b4cfcea73a37ab6d67c06c69e9af3de304185e3 (patch)
tree85264ab3c7c376dd6cb6da2709e329ae5aac606a
parenta32c5f5726f514b49bd396f27aab0e78c40126d3 (diff)
downloadst-8b4cfcea73a37ab6d67c06c69e9af3de304185e3.tar.gz
st-8b4cfcea73a37ab6d67c06c69e9af3de304185e3.zip
Revert "Refactor xsetcolorname()"
This reverts commit a32c5f5726f514b49bd396f27aab0e78c40126d3.
-rw-r--r--st.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/st.c b/st.c
index beae9bc..79a4e0a 100644
--- a/st.c
+++ b/st.c
@@ -2757,28 +2757,32 @@ xloadcols(void) {
2757int 2757int
2758xsetcolorname(int x, const char *name) { 2758xsetcolorname(int x, const char *name) {
2759 XRenderColor color = { .alpha = 0xffff }; 2759 XRenderColor color = { .alpha = 0xffff };
2760 2760 Colour colour;
2761 if(!BETWEEN(x, 0, LEN(colorname))) 2761 if(!BETWEEN(x, 0, LEN(colorname)))
2762 return -1; 2762 return -1;
2763 if(!name) { 2763 if(!name) {
2764 if(BETWEEN(x, 16, 6*6*6+16)) { /* 256 colour */ 2764 if(BETWEEN(x, 16, 16 + 215)) {
2765 color.red = sixd_to_16bit( ((x-16)/36)%6 ); 2765 int r = (x - 16) / 36, g = ((x - 16) % 36) / 6, b = (x - 16) % 6;
2766 color.green = sixd_to_16bit( ((x-16)/6) %6 ); 2766 color.red = sixd_to_16bit(r);
2767 color.blue = sixd_to_16bit( ((x-16)/1) %6 ); 2767 color.green = sixd_to_16bit(g);
2768 if(!XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &color, &dc.col[x])) 2768 color.blue = sixd_to_16bit(b);
2769 die("Could not allocate color %d\n", x); 2769 if(!XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &color, &colour))
2770 return 0; /* something went wrong */
2771 dc.col[x] = colour;
2770 return 1; 2772 return 1;
2771 } else if(BETWEEN(x, 6*6*6+16, 255)) { /* grayscale */ 2773 } else if(BETWEEN(x, 16 + 216, 255)) {
2772 color.red = color.green = color.blue = 0x0808 + 0x0a0a * (x-(6*6*6+16)); 2774 color.red = color.green = color.blue = 0x0808 + 0x0a0a * (x - (16 + 216));
2773 if(!XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &color, &dc.col[x])) 2775 if(!XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &color, &colour))
2774 die("Could not allocate color %d\n", x); 2776 return 0; /* something went wrong */
2777 dc.col[x] = colour;
2775 return 1; 2778 return 1;
2776 } else { /* system colours */ 2779 } else {
2777 name = colorname[x]; 2780 name = colorname[x];
2778 } 2781 }
2779 } 2782 }
2780 if(!XftColorAllocName(xw.dpy, xw.vis, xw.cmap, name, &dc.col[x])) 2783 if(!XftColorAllocName(xw.dpy, xw.vis, xw.cmap, name, &colour))
2781 return 0; /* invalid name */ 2784 return 0;
2785 dc.col[x] = colour;
2782 return 1; 2786 return 1;
2783} 2787}
2784 2788