Line 0
Link Here
|
|
|
1 |
--- draw.c.orig 2013-09-23 11:57:39.000000000 +0200 |
2 |
+++ draw.c 2014-12-06 20:30:50.785932524 +0100 |
3 |
@@ -395,21 +395,20 @@ |
4 |
XpmColorSymbol xpms; |
5 |
#endif |
6 |
|
7 |
+ /* icon cache */ |
8 |
+ int ip; |
9 |
+ |
10 |
#ifdef DZEN_XFT |
11 |
XftDraw *xftd=NULL; |
12 |
XftColor xftc; |
13 |
char *xftcs; |
14 |
- int xftcs_f=0; |
15 |
char *xftcs_bg; |
16 |
- int xftcs_bgf=0; |
17 |
|
18 |
- xftcs = (char *)dzen.fg; |
19 |
- xftcs_bg = (char *)dzen.bg; |
20 |
+ /* set default fg/bg for XFT */ |
21 |
+ xftcs = estrdup(dzen.fg); |
22 |
+ xftcs_bg = estrdup(dzen.bg); |
23 |
#endif |
24 |
|
25 |
- /* icon cache */ |
26 |
- int ip; |
27 |
- |
28 |
/* parse line and return the text without control commands */ |
29 |
if(nodraw) { |
30 |
rbuf = emalloc(MAX_LINE_LEN); |
31 |
@@ -446,8 +445,7 @@ |
32 |
xpms.pixel = dzen.norm[ColBG]; |
33 |
#endif |
34 |
#ifdef DZEN_XFT |
35 |
- xftcs_bg = (char *)dzen.bg; |
36 |
- xftcs_bgf = 0; |
37 |
+ xftcs_bg = estrdup(dzen.bg); |
38 |
#endif |
39 |
} |
40 |
else { |
41 |
@@ -679,15 +677,9 @@ |
42 |
case bg: |
43 |
lastbg = tval[0] ? (unsigned)getcolor(tval) : dzen.norm[ColBG]; |
44 |
#ifdef DZEN_XFT |
45 |
- if(xftcs_bgf) free(xftcs_bg); |
46 |
- if(tval[0]) { |
47 |
- xftcs_bg = estrdup(tval); |
48 |
- xftcs_bgf = 1; |
49 |
- } else { |
50 |
- xftcs_bg = (char *)dzen.bg; |
51 |
- xftcs_bgf = 0; |
52 |
- } |
53 |
-#endif |
54 |
+ if(xftcs_bg) free(xftcs_bg); |
55 |
+ xftcs_bg = estrdup(tval[0] ? tval : dzen.bg); |
56 |
+#endif |
57 |
|
58 |
break; |
59 |
|
60 |
@@ -695,19 +687,14 @@ |
61 |
lastfg = tval[0] ? (unsigned)getcolor(tval) : dzen.norm[ColFG]; |
62 |
XSetForeground(dzen.dpy, dzen.tgc, lastfg); |
63 |
#ifdef DZEN_XFT |
64 |
- if(tval[0]) { |
65 |
- xftcs = estrdup(tval); |
66 |
- xftcs_f = 1; |
67 |
- } else { |
68 |
- xftcs = (char *)dzen.fg; |
69 |
- xftcs_f = 0; |
70 |
- } |
71 |
-#endif |
72 |
+ if (xftcs) free(xftcs); |
73 |
+ xftcs = estrdup(tval[0] ? tval : dzen.fg); |
74 |
+#endif |
75 |
break; |
76 |
|
77 |
case fn: |
78 |
if(tval[0]) { |
79 |
-#ifndef DZEN_XFT |
80 |
+#ifndef DZEN_XFT |
81 |
if(!strncmp(tval, "dfnt", 4)) { |
82 |
cur_fnt = &(dzen.fnpl[atoi(tval+4)]); |
83 |
|
84 |
@@ -816,18 +803,8 @@ |
85 |
DefaultColormap(dzen.dpy, dzen.screen), xftcs, &xftc); |
86 |
} |
87 |
|
88 |
- XftDrawStringUtf8(xftd, &xftc, |
89 |
+ XftDrawStringUtf8(xftd, &xftc, |
90 |
cur_fnt->xftfont, px, py + dzen.font.xftfont->ascent, (const FcChar8 *)lbuf, strlen(lbuf)); |
91 |
- |
92 |
- if(xftcs_f) { |
93 |
- free(xftcs); |
94 |
- xftcs_f = 0; |
95 |
- } |
96 |
- if(xftcs_bgf) { |
97 |
- free(xftcs_bg); |
98 |
- xftcs_bgf = 0; |
99 |
- } |
100 |
- |
101 |
#endif |
102 |
|
103 |
max_y = MAX(max_y, py+dzen.font.height); |
104 |
@@ -920,6 +897,11 @@ |
105 |
#endif |
106 |
} |
107 |
|
108 |
+#ifdef DZEN_XFT |
109 |
+ if(xftcs) free(xftcs); |
110 |
+ if(xftcs_bg) free(xftcs_bg); |
111 |
+#endif |
112 |
+ |
113 |
return nodraw ? rbuf : NULL; |
114 |
} |
115 |
|