Debian Codegraph @

drw.c

raw symbols SCIP
1 /* See LICENSE file for copyright and license details. */cxx . . $ `<file>/drw.c`/
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
5 #include <X11/Xlib.h>
6 #include <X11/Xft/Xft.h>
7
8 #include "drw.h"cxx . . $ `<file>/drw.h`/
9 #include "util.h"cxx . . $ `<file>/util.h`/
10
11 #define UTF_INVALIDcxx . . $ `drw.c:11:9`! 0xFFFD
12 #define UTF_SIZcxx . . $ `drw.c:12:9`! 4
13
14 static const unsigned char utfbytecxx . . $ utfbyte.[UTF_SIZcxx . . $ `drw.c:12:9`! + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
15 static const unsigned char utfmaskcxx . . $ utfmask.[UTF_SIZcxx . . $ `drw.c:12:9`! + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
16 static const long utfmincxx . . $ utfmin.[UTF_SIZcxx . . $ `drw.c:12:9`! + 1] = { 0, 0, 0x80, 0x800, 0x10000};
17 static const long utfmaxcxx . . $ utfmax.[UTF_SIZcxx . . $ `drw.c:12:9`! + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF};
18
19 static long
20 utf8decodebytecxx . . $ utf8decodebyte(5717d3b9d593c142).(const char c, size_t *i)
21 {
22 for (*i = 0; *i < (UTF_SIZcxx . . $ `drw.c:12:9`! + 1); ++(*i))
23 if (((unsigned char)c & utfmaskcxx . . $ utfmask.[*i]) == utfbytecxx . . $ utfbyte.[*i])
24 return (unsigned char)c & ~utfmaskcxx . . $ utfmask.[*i];
25 return 0;
26 }
27
28 static size_t
29 utf8validatecxx . . $ utf8validate(7ebe238079ec0052).(long *u, size_t i)
30 {
31 if (!BETWEENcxx . . $ `util.h:5:9`!(*u, utfmin[i], utfmax[i]) || BETWEENcxx . . $ `util.h:5:9`!(*u, 0xD800, 0xDFFF))
32 *u = UTF_INVALIDcxx . . $ `drw.c:11:9`!;
33 for (i = 1; *u > utfmaxcxx . . $ utfmax.[i]; ++i)
34 ;
35 return i;
36 }
37
38 static size_t
39 utf8decodecxx . . $ utf8decode(ca033bbf39a8d4eb).(const char *c, long *u, size_t clen)
40 {
41 size_t i, j, len, type;
42 long udecoded;
43
44 *u = UTF_INVALIDcxx . . $ `drw.c:11:9`!;
45 if (!clen)
46 return 0;
47 udecoded = utf8decodebytecxx . . $ utf8decodebyte(5717d3b9d593c142).(c[0], &len);
48 if (!BETWEENcxx . . $ `util.h:5:9`!(len, 1, UTF_SIZcxx . . $ `drw.c:12:9`!))
49 return 1;
50 for (i = 1, j = 1; i < clen && j < len; ++i, ++j) {
51 udecoded = (udecoded << 6) | utf8decodebytecxx . . $ utf8decodebyte(5717d3b9d593c142).(c[i], &type);
52 if (type)
53 return j;
54 }
55 if (j < len)
56 return 0;
57 *u = udecoded;
58 utf8validatecxx . . $ utf8validate(7ebe238079ec0052).(u, len);
59
60 return len;
61 }
62
63 Drwcxx . . $ Drw# *
64 drw_createcxx . . $ drw_create(383bceeabb247e2e).(Displaycxx . . $ Display# *dpy, int screen, Windowcxx . . $ Window# root, unsigned int w, unsigned int h)
65 {
66 Drwcxx . . $ Drw# *drw = ecalloccxx . . $ ecalloc(63a7bf2941bfcd7a).(1, sizeof(Drwcxx . . $ Drw#));
67
68 drw->dpycxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#dpy. = dpy;
69 drw->screencxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#screen. = screen;
70 drw->rootcxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#root. = root;
71 drw->wcxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#w. = w;
72 drw->hcxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#h. = h;
73 drw->drawablecxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#drawable. = XCreatePixmapcxx . . $ XCreatePixmap(22c037a85c11f920).(dpy, root, w, h, DefaultDepthcxx . . $ `<external>/7073035915403465041/Xlib.h:109:9`!(dpy, screen));
74 drw->gccxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#gc. = XCreateGCcxx . . $ XCreateGC(183ad189da2d988e).(dpy, root, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
75 XSetLineAttributescxx . . $ XSetLineAttributes(83a8bc64537ee104).(dpy, drw->gccxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#gc., 1, LineSolidcxx . . $ `<external>/1208737181511191802/X.h:504:9`!, CapButtcxx . . $ `<external>/1208737181511191802/X.h:511:9`!, JoinMitercxx . . $ `<external>/1208737181511191802/X.h:517:9`!);
76
77 return drw;
78 }
79
80 void
81 drw_resizecxx . . $ drw_resize(8ce1eee632a66a2d).(Drwcxx . . $ Drw# *drw, unsigned int w, unsigned int h)
82 {
83 if (!drw)
84 return;
85
86 drw->wcxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#w. = w;
87 drw->hcxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#h. = h;
88 if (drw->drawablecxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#drawable.)
89 XFreePixmapcxx . . $ XFreePixmap(5223c1f954fb9eb9).(drw->dpycxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#dpy., drw->drawablecxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#drawable.);
90 drw->drawablecxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#drawable. = XCreatePixmapcxx . . $ XCreatePixmap(22c037a85c11f920).(drw->dpycxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#dpy., drw->rootcxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#root., w, h, DefaultDepthcxx . . $ `<external>/7073035915403465041/Xlib.h:109:9`!(drw->dpy, drw->screen));
91 }
92
93 void
94 drw_freecxx . . $ drw_free(9f8a8a57df31cd06).(Drwcxx . . $ Drw# *drw)
95 {
96 XFreePixmapcxx . . $ XFreePixmap(5223c1f954fb9eb9).(drw->dpycxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#dpy., drw->drawablecxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#drawable.);
97 XFreeGCcxx . . $ XFreeGC(92f5b971658625f7).(drw->dpycxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#dpy., drw->gccxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#gc.);
98 freecxx . . $ free(5d22bdacc48458e8).(drw);
99 }
100
101 /* This function is an implementation detail. Library users should use
102 * drw_fontset_create instead.
103 */
104 static Fntcxx . . $ Fnt# *
105 xfont_createcxx . . $ xfont_create(a60d3d1e47d32ad5).(Drwcxx . . $ Drw# *drw, const char *fontname, FcPatterncxx . . $ FcPattern# *fontpattern)
106 {
107 Fntcxx . . $ Fnt# *font;
108 XftFontcxx . . $ XftFont# *xfont = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
109 FcPatterncxx . . $ FcPattern# *pattern = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
110
111 if (fontname) {
112 /* Using the pattern found at font->xfont->pattern does not yield the
113 * same substitution results as using the pattern returned by
114 * FcNameParse; using the latter results in the desired fallback
115 * behaviour whereas the former just results in missing-character
116 * rectangles being drawn, at least with some fonts. */
117 if (!(xfont = XftFontOpenNamecxx . . $ XftFontOpenName(2a80ce9130983b57).(drw->dpycxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#dpy., drw->screencxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#screen., fontname))) {
118 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "error, cannot load font from name: '%s'\n", fontname);
119 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
120 }
121 if (!(pattern = FcNameParsecxx . . $ FcNameParse(5a4df57c4e4d23da).((FcChar8cxx . . $ FcChar8# *) fontname))) {
122 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "error, cannot parse font name to pattern: '%s'\n", fontname);
123 XftFontClosecxx . . $ XftFontClose(3dee2d4ca7dda191).(drw->dpycxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#dpy., xfont);
124 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
125 }
126 } else if (fontpattern) {
127 if (!(xfont = XftFontOpenPatterncxx . . $ XftFontOpenPattern(7c3644730b65771f).(drw->dpycxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#dpy., fontpattern))) {
128 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "error, cannot load font from pattern.\n");
129 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
130 }
131 } else {
132 diecxx . . $ die(326aeb464d16410c).("no font specified.");
133 }
134
135 font = ecalloccxx . . $ ecalloc(63a7bf2941bfcd7a).(1, sizeof(Fntcxx . . $ Fnt#));
136 font->xfontcxx . . $ Fnt#xfont. = xfont;
137 font->patterncxx . . $ Fnt#pattern. = pattern;
138 font->hcxx . . $ Fnt#h. = xfont->ascentcxx . . $ _XftFont#ascent. + xfont->descentcxx . . $ _XftFont#descent.;
139 font->dpycxx . . $ Fnt#dpy. = drw->dpycxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#dpy.;
140
141 return font;
142 }
143
144 static void
145 xfont_freecxx . . $ xfont_free(24a24cfeadec3a17).(Fntcxx . . $ Fnt# *font)
146 {
147 if (!font)
148 return;
149 if (font->patterncxx . . $ Fnt#pattern.)
150 FcPatternDestroycxx . . $ FcPatternDestroy(33243afccfed920a).(font->patterncxx . . $ Fnt#pattern.);
151 XftFontClosecxx . . $ XftFontClose(3dee2d4ca7dda191).(font->dpycxx . . $ Fnt#dpy., font->xfontcxx . . $ Fnt#xfont.);
152 freecxx . . $ free(5d22bdacc48458e8).(font);
153 }
154
155 Fntcxx . . $ Fnt#*
156 drw_fontset_createcxx . . $ drw_fontset_create(2c3ebfe73e2d42a2).(Drwcxx . . $ Drw#* drw, const char *fonts[], size_t fontcount)
157 {
158 Fntcxx . . $ Fnt# *cur, *ret = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
159 size_t i;
160
161 if (!drw || !fonts)
162 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
163
164 for (i = 1; i <= fontcount; i++) {
165 if ((cur = xfont_createcxx . . $ xfont_create(a60d3d1e47d32ad5).(drw, fonts[fontcount - i], NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!))) {
166 cur->nextcxx . . $ Fnt#next. = ret;
167 ret = cur;
168 }
169 }
170 return (drw->fontscxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#fonts. = ret);
171 }
172
173 void
174 drw_fontset_freecxx . . $ drw_fontset_free(24a24cfeadec3a17).(Fntcxx . . $ Fnt# *font)
175 {
176 if (font) {
177 drw_fontset_freecxx . . $ drw_fontset_free(24a24cfeadec3a17).(font->nextcxx . . $ Fnt#next.);
178 xfont_freecxx . . $ xfont_free(24a24cfeadec3a17).(font);
179 }
180 }
181
182 void
183 drw_clr_createcxx . . $ drw_clr_create(c82f3736bd6d2eb0).(Drwcxx . . $ Drw# *drw, Clrcxx . . $ Clr# *dest, const char *clrname)
184 {
185 if (!drw || !dest || !clrname)
186 return;
187
188 if (!XftColorAllocNamecxx . . $ XftColorAllocName(74ff402107316186).(drw->dpycxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#dpy., DefaultVisualcxx . . $ `<external>/7073035915403465041/Xlib.h:91:9`!(drw->dpy, drw->screen),
189 DefaultColormapcxx . . $ `<external>/7073035915403465041/Xlib.h:110:9`!(drw->dpy, drw->screen),
190 clrname, dest))
191 diecxx . . $ die(326aeb464d16410c).("error, cannot allocate color '%s'", clrname);
192 }
193
194 /* Wrapper to create color schemes. The caller has to call free(3) on the
195 * returned color scheme when done using it. */
196 Clrcxx . . $ Clr# *
197 drw_scm_createcxx . . $ drw_scm_create(878101a786c67ee5).(Drwcxx . . $ Drw# *drw, const char *clrnames[], size_t clrcount)
198 {
199 size_t i;
200 Clrcxx . . $ Clr# *ret;
201
202 /* need at least two colors for a scheme */
203 if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloccxx . . $ ecalloc(63a7bf2941bfcd7a).(clrcount, sizeof(XftColorcxx . . $ XftColor#))))
204 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
205
206 for (i = 0; i < clrcount; i++)
207 drw_clr_createcxx . . $ drw_clr_create(c82f3736bd6d2eb0).(drw, &ret[i], clrnames[i]);
208 return ret;
209 }
210
211 void
212 drw_setfontsetcxx . . $ drw_setfontset(2efbef2cdcecf91c).(Drwcxx . . $ Drw# *drw, Fntcxx . . $ Fnt# *set)
213 {
214 if (drw)
215 drw->fontscxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#fonts. = set;
216 }
217
218 void
219 drw_setschemecxx . . $ drw_setscheme(d73c2bf9bbeb9f1a).(Drwcxx . . $ Drw# *drw, Clrcxx . . $ Clr# *scm)
220 {
221 if (drw)
222 drw->schemecxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#scheme. = scm;
223 }
224
225 void
226 drw_rectcxx . . $ drw_rect(1b458623c78a9550).(Drwcxx . . $ Drw# *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert)
227 {
228 if (!drw || !drw->schemecxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#scheme.)
229 return;
230 XSetForegroundcxx . . $ XSetForeground(d7c9d36fcaf627b2).(drw->dpycxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#dpy., drw->gccxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#gc., invert ? drw->schemecxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#scheme.[ColBgcxx . . $ ColBg.].pixelcxx . . $ _XftColor#pixel. : drw->schemecxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#scheme.[ColFgcxx . . $ ColFg.].pixelcxx . . $ _XftColor#pixel.);
231 if (filled)
232 XFillRectanglecxx . . $ XFillRectangle(be8231154a6fb35c).(drw->dpycxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#dpy., drw->drawablecxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#drawable., drw->gccxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#gc., x, y, w, h);
233 else
234 XDrawRectanglecxx . . $ XDrawRectangle(be8231154a6fb35c).(drw->dpycxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#dpy., drw->drawablecxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#drawable., drw->gccxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#gc., x, y, w - 1, h - 1);
235 }
236
237 int
238 drw_textcxx . . $ drw_text(deadee800938824).(Drwcxx . . $ Drw# *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert)
239 {
240 char buf[1024];
241 int ty;
242 unsigned int ew;
243 XftDrawcxx . . $ XftDraw# *d = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
244 Fntcxx . . $ Fnt# *usedfont, *curfont, *nextfont;
245 size_t i, len;
246 int utf8strlen, utf8charlen, render = x || y || w || h;
247 long utf8codepoint = 0;
248 const char *utf8str;
249 FcCharSetcxx . . $ FcCharSet# *fccharset;
250 FcPatterncxx . . $ FcPattern# *fcpattern;
251 FcPatterncxx . . $ FcPattern# *match;
252 XftResultcxx . . $ XftResult# result;
253 int charexists = 0;
254
255 if (!drw || (render && !drw->schemecxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#scheme.) || !text || !drw->fontscxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#fonts.)
256 return 0;
257
258 if (!render) {
259 w = ~w;
260 } else {
261 XSetForegroundcxx . . $ XSetForeground(d7c9d36fcaf627b2).(drw->dpycxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#dpy., drw->gccxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#gc., drw->schemecxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#scheme.[invert ? ColFgcxx . . $ ColFg. : ColBgcxx . . $ ColBg.].pixelcxx . . $ _XftColor#pixel.);
262 XFillRectanglecxx . . $ XFillRectangle(be8231154a6fb35c).(drw->dpycxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#dpy., drw->drawablecxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#drawable., drw->gccxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#gc., x, y, w, h);
263 d = XftDrawCreatecxx . . $ XftDrawCreate(8eee25e52655c64a).(drw->dpycxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#dpy., drw->drawablecxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#drawable.,
264 DefaultVisualcxx . . $ `<external>/7073035915403465041/Xlib.h:91:9`!(drw->dpy, drw->screen),
265 DefaultColormapcxx . . $ `<external>/7073035915403465041/Xlib.h:110:9`!(drw->dpy, drw->screen));
266 x += lpad;
267 w -= lpad;
268 }
269
270 usedfont = drw->fontscxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#fonts.;
271 while (1) {
272 utf8strlen = 0;
273 utf8str = text;
274 nextfont = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
275 while (*text) {
276 utf8charlen = utf8decodecxx . . $ utf8decode(ca033bbf39a8d4eb).(text, &utf8codepoint, UTF_SIZcxx . . $ `drw.c:12:9`!);
277 for (curfont = drw->fontscxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#fonts.; curfont; curfont = curfont->nextcxx . . $ Fnt#next.) {
278 charexists = charexists || XftCharExistscxx . . $ XftCharExists(153fd5be6ab4414a).(drw->dpycxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#dpy., curfont->xfontcxx . . $ Fnt#xfont., utf8codepoint);
279 if (charexists) {
280 if (curfont == usedfont) {
281 utf8strlen += utf8charlen;
282 text += utf8charlen;
283 } else {
284 nextfont = curfont;
285 }
286 break;
287 }
288 }
289
290 if (!charexists || nextfont)
291 break;
292 else
293 charexists = 0;
294 }
295
296 if (utf8strlen) {
297 drw_font_getextscxx . . $ drw_font_getexts(ebc5ece8b7c1cb0b).(usedfont, utf8str, utf8strlen, &ew, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
298 /* shorten text if necessary */
299 for (len = MINcxx . . $ `util.h:4:9`!(utf8strlen, sizeof(buf) - 1); len && ew > w; len--)
300 drw_font_getextscxx . . $ drw_font_getexts(ebc5ece8b7c1cb0b).(usedfont, utf8str, len, &ew, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
301
302 if (len) {
303 memcpycxx . . $ memcpy(cc817cb175f282d).(buf, utf8str, len);
304 buf[len] = '\0';
305 if (len < utf8strlen)
306 for (i = len; i && i > len - 3; buf[--i] = '.')
307 ; /* NOP */
308
309 if (render) {
310 ty = y + (h - usedfont->hcxx . . $ Fnt#h.) / 2 + usedfont->xfontcxx . . $ Fnt#xfont.->ascentcxx . . $ _XftFont#ascent.;
311 XftDrawStringUtf8cxx . . $ XftDrawStringUtf8(29de59977d6678e7).(d, &drw->schemecxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#scheme.[invert ? ColBgcxx . . $ ColBg. : ColFgcxx . . $ ColFg.],
312 usedfont->xfontcxx . . $ Fnt#xfont., x, ty, (XftChar8cxx . . $ XftChar8# *)buf, len);
313 }
314 x += ew;
315 w -= ew;
316 }
317 }
318
319 if (!*text) {
320 break;
321 } else if (nextfont) {
322 charexists = 0;
323 usedfont = nextfont;
324 } else {
325 /* Regardless of whether or not a fallback font is found, the
326 * character must be drawn. */
327 charexists = 1;
328
329 fccharset = FcCharSetCreatecxx . . $ FcCharSetCreate(a81199f928c2d3a8).();
330 FcCharSetAddCharcxx . . $ FcCharSetAddChar(6ad8135ea1e998fa).(fccharset, utf8codepoint);
331
332 if (!drw->fontscxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#fonts.->patterncxx . . $ Fnt#pattern.) {
333 /* Refer to the comment in xfont_create for more information. */
334 diecxx . . $ die(326aeb464d16410c).("the first font in the cache must be loaded from a font string.");
335 }
336
337 fcpattern = FcPatternDuplicatecxx . . $ FcPatternDuplicate(6bc767ae9ae88ab2).(drw->fontscxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#fonts.->patterncxx . . $ Fnt#pattern.);
338 FcPatternAddCharSetcxx . . $ FcPatternAddCharSet(46a59afd4544e977).(fcpattern, FC_CHARSETcxx . . $ `<external>/13613261626220836809/fontconfig.h:112:9`!, fccharset);
339 FcPatternAddBoolcxx . . $ FcPatternAddBool(71b7628a2710b4ce).(fcpattern, FC_SCALABLEcxx . . $ `<external>/13613261626220836809/fontconfig.h:103:9`!, FcTruecxx . . $ `<external>/13613261626220836809/fontconfig.h:78:9`!);
340
341 FcConfigSubstitutecxx . . $ FcConfigSubstitute(787453b4c0bb8116).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, fcpattern, FcMatchPatterncxx . . $ FcMatchPattern.);
342 FcDefaultSubstitutecxx . . $ FcDefaultSubstitute(33243afccfed920a).(fcpattern);
343 match = XftFontMatchcxx . . $ XftFontMatch(f4ea1848089423d0).(drw->dpycxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#dpy., drw->screencxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#screen., fcpattern, &result);
344
345 FcCharSetDestroycxx . . $ FcCharSetDestroy(782227fefe5967d3).(fccharset);
346 FcPatternDestroycxx . . $ FcPatternDestroy(33243afccfed920a).(fcpattern);
347
348 if (match) {
349 usedfont = xfont_createcxx . . $ xfont_create(a60d3d1e47d32ad5).(drw, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, match);
350 if (usedfont && XftCharExistscxx . . $ XftCharExists(153fd5be6ab4414a).(drw->dpycxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#dpy., usedfont->xfontcxx . . $ Fnt#xfont., utf8codepoint)) {
351 for (curfont = drw->fontscxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#fonts.; curfont->nextcxx . . $ Fnt#next.; curfont = curfont->nextcxx . . $ Fnt#next.)
352 ; /* NOP */
353 curfont->nextcxx . . $ Fnt#next. = usedfont;
354 } else {
355 xfont_freecxx . . $ xfont_free(24a24cfeadec3a17).(usedfont);
356 usedfont = drw->fontscxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#fonts.;
357 }
358 }
359 }
360 }
361 if (d)
362 XftDrawDestroycxx . . $ XftDrawDestroy(f07dfd703c945385).(d);
363
364 return x + (render ? w : 0);
365 }
366
367 void
368 drw_mapcxx . . $ drw_map(dbd1941aae78263e).(Drwcxx . . $ Drw# *drw, Windowcxx . . $ Window# win, int x, int y, unsigned int w, unsigned int h)
369 {
370 if (!drw)
371 return;
372
373 XCopyAreacxx . . $ XCopyArea(6b1ba6de71507f13).(drw->dpycxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#dpy., drw->drawablecxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#drawable., win, drw->gccxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#gc., x, y, w, h, x, y);
374 XSynccxx . . $ XSync(3212536831777fd4).(drw->dpycxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#dpy., Falsecxx . . $ `<external>/7073035915403465041/Xlib.h:81:9`!);
375 }
376
377 unsigned int
378 drw_fontset_getwidthcxx . . $ drw_fontset_getwidth(d6c993fe6b1c750a).(Drwcxx . . $ Drw# *drw, const char *text)
379 {
380 if (!drw || !drw->fontscxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#fonts. || !text)
381 return 0;
382 return drw_textcxx . . $ drw_text(deadee800938824).(drw, 0, 0, 0, 0, 0, text, 0);
383 }
384
385 void
386 drw_font_getextscxx . . $ drw_font_getexts(ebc5ece8b7c1cb0b).(Fntcxx . . $ Fnt# *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h)
387 {
388 XGlyphInfocxx . . $ XGlyphInfo# ext;
389
390 if (!font || !text)
391 return;
392
393 XftTextExtentsUtf8cxx . . $ XftTextExtentsUtf8(bd3e40634d567473).(font->dpycxx . . $ Fnt#dpy., font->xfontcxx . . $ Fnt#xfont., (XftChar8cxx . . $ XftChar8# *)text, len, &ext);
394 if (w)
395 *w = ext.xOffcxx . . $ _XGlyphInfo#xOff.;
396 if (h)
397 *h = font->hcxx . . $ Fnt#h.;
398 }
399
400 Curcxx . . $ Cur# *
401 drw_cur_createcxx . . $ drw_cur_create(f16b114f8304ddf7).(Drwcxx . . $ Drw# *drw, int shape)
402 {
403 Curcxx . . $ Cur# *cur;
404
405 if (!drw || !(cur = ecalloccxx . . $ ecalloc(63a7bf2941bfcd7a).(1, sizeof(Curcxx . . $ Cur#))))
406 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
407
408 cur->cursorcxx . . $ $anonymous_type_bb5ce8a44c4f204f_0#cursor. = XCreateFontCursorcxx . . $ XCreateFontCursor(f83b4de9beb267f9).(drw->dpycxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#dpy., shape);
409
410 return cur;
411 }
412
413 void
414 drw_cur_freecxx . . $ drw_cur_free(9c3d32debd956b4b).(Drwcxx . . $ Drw# *drw, Curcxx . . $ Cur# *cursor)
415 {
416 if (!cursor)
417 return;
418
419 XFreeCursorcxx . . $ XFreeCursor(5223c1f954fb9eb9).(drw->dpycxx . . $ $anonymous_type_bb5ce8a44c4f204f_2#dpy., cursor->cursorcxx . . $ $anonymous_type_bb5ce8a44c4f204f_0#cursor.);
420 freecxx . . $ free(5d22bdacc48458e8).(cursor);
421 }