annotate draw.c @ 699:fd5eb7cd7f36

Added tag 3.1 for changeset e1c8bef05e6e
author Anselm R. Garbe <arg@suckless.org>
date Tue, 16 Jan 2007 11:41:56 +0100
parents 4d12382fef8e
children 295c8ca7a27a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
643
e90bf387bf6f next version will contain updated copyright notice
arg@mig29
parents: 627
diff changeset
1 /* (C)opyright MMIV-MMVII Anselm R. Garbe <garbeam at gmail dot com>
2
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
2 * See LICENSE file for license details.
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
3 */
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
4 #include "dwm.h"
2
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
5 #include <stdio.h>
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
6 #include <string.h>
32
082c75b937b5 removed unnecessary crap
Anselm R. Garbe <garbeam@wmii.de>
parents: 30
diff changeset
7
84
052fe7498930 ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents: 79
diff changeset
8 /* static */
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
9
572
427708bf5f36 added a similiar patch to Daves solution to indicate if there are clients with a specific tag
arg@mig29
parents: 571
diff changeset
10 static Bool
427708bf5f36 added a similiar patch to Daves solution to indicate if there are clients with a specific tag
arg@mig29
parents: 571
diff changeset
11 isoccupied(unsigned int t)
427708bf5f36 added a similiar patch to Daves solution to indicate if there are clients with a specific tag
arg@mig29
parents: 571
diff changeset
12 {
427708bf5f36 added a similiar patch to Daves solution to indicate if there are clients with a specific tag
arg@mig29
parents: 571
diff changeset
13 Client *c;
427708bf5f36 added a similiar patch to Daves solution to indicate if there are clients with a specific tag
arg@mig29
parents: 571
diff changeset
14 for(c = clients; c; c = c->next)
427708bf5f36 added a similiar patch to Daves solution to indicate if there are clients with a specific tag
arg@mig29
parents: 571
diff changeset
15 if(c->tags[t])
427708bf5f36 added a similiar patch to Daves solution to indicate if there are clients with a specific tag
arg@mig29
parents: 571
diff changeset
16 return True;
427708bf5f36 added a similiar patch to Daves solution to indicate if there are clients with a specific tag
arg@mig29
parents: 571
diff changeset
17 return False;
427708bf5f36 added a similiar patch to Daves solution to indicate if there are clients with a specific tag
arg@mig29
parents: 571
diff changeset
18 }
427708bf5f36 added a similiar patch to Daves solution to indicate if there are clients with a specific tag
arg@mig29
parents: 571
diff changeset
19
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
20 static unsigned int
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 377
diff changeset
21 textnw(const char *text, unsigned int len) {
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
22 XRectangle r;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 93
diff changeset
23
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
24 if(dc.font.set) {
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
25 XmbTextExtents(dc.font.set, text, len, NULL, &r);
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
26 return r.width;
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
27 }
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
28 return XTextWidth(dc.font.xfont, text, len);
75
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 74
diff changeset
29 }
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 74
diff changeset
30
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
31 static void
607
16762f7414de if client is focused, the emptysquare don't needs to be drawed
arg@mig29
parents: 606
diff changeset
32 drawtext(const char *text, unsigned long col[ColLast], Bool filledsquare, Bool emptysquare) {
344
93192711a36a changing tag indicator through underline
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
33 int x, y, w, h;
93192711a36a changing tag indicator through underline
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
34 static char buf[256];
93192711a36a changing tag indicator through underline
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
35 unsigned int len, olen;
352
5a8bdc3b37cb back to 3 colors
Anselm R. Garbe <arg@10kloc.org>
parents: 351
diff changeset
36 XGCValues gcv;
344
93192711a36a changing tag indicator through underline
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
37 XRectangle r = { dc.x, dc.y, dc.w, dc.h };
606
44b5617c78b3 and the winner is
arg@mig29
parents: 605
diff changeset
38 XPoint pt[5];
344
93192711a36a changing tag indicator through underline
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
39
353
8a06efe5b563 new color stuff/new rendering stuff
Anselm R. Garbe <arg@10kloc.org>
parents: 352
diff changeset
40 XSetForeground(dpy, dc.gc, col[ColBG]);
344
93192711a36a changing tag indicator through underline
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
41 XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
3
e969f3575b7a several new changes, made gridmenu working
Anselm R. Garbe <garbeam@wmii.de>
parents: 2
diff changeset
42 if(!text)
2
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
43 return;
218
c674a0baac63 changed signature of drawtext
arg@10ksloc.org
parents: 208
diff changeset
44 w = 0;
269
bf6792e3e700 fixed string cutting in draw.c
Anselm R.Garbe <arg@10ksloc.org>
parents: 262
diff changeset
45 olen = len = strlen(text);
581
601842ee4484 applied Jukka's sizeof K&R compliance patch, applied Manuels' last-line printage proposal for stdin reading.
arg@mig29
parents: 572
diff changeset
46 if(len >= sizeof buf)
601842ee4484 applied Jukka's sizeof K&R compliance patch, applied Manuels' last-line printage proposal for stdin reading.
arg@mig29
parents: 572
diff changeset
47 len = sizeof buf - 1;
3
e969f3575b7a several new changes, made gridmenu working
Anselm R. Garbe <garbeam@wmii.de>
parents: 2
diff changeset
48 memcpy(buf, text, len);
2
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
49 buf[len] = 0;
34
cd30cce52b78 added logo+description
Anselm R. Garbe <garbeam@wmii.de>
parents: 33
diff changeset
50 h = dc.font.ascent + dc.font.descent;
cd30cce52b78 added logo+description
Anselm R. Garbe <garbeam@wmii.de>
parents: 33
diff changeset
51 y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent;
cd30cce52b78 added logo+description
Anselm R. Garbe <garbeam@wmii.de>
parents: 33
diff changeset
52 x = dc.x + (h / 2);
2
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
53 /* shorten text if necessary */
43
989178822938 changed default colors
Anselm R. Garbe <garbeam@wmii.de>
parents: 34
diff changeset
54 while(len && (w = textnw(buf, len)) > dc.w - h)
2
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
55 buf[--len] = 0;
269
bf6792e3e700 fixed string cutting in draw.c
Anselm R.Garbe <arg@10ksloc.org>
parents: 262
diff changeset
56 if(len < olen) {
273
ffc73b32084a fixed string cutting
Anselm R.Garbe <arg@10ksloc.org>
parents: 269
diff changeset
57 if(len > 1)
ffc73b32084a fixed string cutting
Anselm R.Garbe <arg@10ksloc.org>
parents: 269
diff changeset
58 buf[len - 1] = '.';
ffc73b32084a fixed string cutting
Anselm R.Garbe <arg@10ksloc.org>
parents: 269
diff changeset
59 if(len > 2)
ffc73b32084a fixed string cutting
Anselm R.Garbe <arg@10ksloc.org>
parents: 269
diff changeset
60 buf[len - 2] = '.';
269
bf6792e3e700 fixed string cutting in draw.c
Anselm R.Garbe <arg@10ksloc.org>
parents: 262
diff changeset
61 if(len > 3)
273
ffc73b32084a fixed string cutting
Anselm R.Garbe <arg@10ksloc.org>
parents: 269
diff changeset
62 buf[len - 3] = '.';
269
bf6792e3e700 fixed string cutting in draw.c
Anselm R.Garbe <arg@10ksloc.org>
parents: 262
diff changeset
63 }
34
cd30cce52b78 added logo+description
Anselm R. Garbe <garbeam@wmii.de>
parents: 33
diff changeset
64 if(w > dc.w)
2
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
65 return; /* too long */
353
8a06efe5b563 new color stuff/new rendering stuff
Anselm R. Garbe <arg@10kloc.org>
parents: 352
diff changeset
66 gcv.foreground = col[ColFG];
352
5a8bdc3b37cb back to 3 colors
Anselm R. Garbe <arg@10kloc.org>
parents: 351
diff changeset
67 if(dc.font.set) {
353
8a06efe5b563 new color stuff/new rendering stuff
Anselm R. Garbe <arg@10kloc.org>
parents: 352
diff changeset
68 XChangeGC(dpy, dc.gc, GCForeground, &gcv);
342
a1901753deef updated man page
Anselm R. Garbe <arg@10kloc.org>
parents: 340
diff changeset
69 XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);
352
5a8bdc3b37cb back to 3 colors
Anselm R. Garbe <arg@10kloc.org>
parents: 351
diff changeset
70 }
2
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
71 else {
352
5a8bdc3b37cb back to 3 colors
Anselm R. Garbe <arg@10kloc.org>
parents: 351
diff changeset
72 gcv.font = dc.font.xfont->fid;
353
8a06efe5b563 new color stuff/new rendering stuff
Anselm R. Garbe <arg@10kloc.org>
parents: 352
diff changeset
73 XChangeGC(dpy, dc.gc, GCForeground | GCFont, &gcv);
342
a1901753deef updated man page
Anselm R. Garbe <arg@10kloc.org>
parents: 340
diff changeset
74 XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
a1901753deef updated man page
Anselm R. Garbe <arg@10kloc.org>
parents: 340
diff changeset
75 }
606
44b5617c78b3 and the winner is
arg@mig29
parents: 605
diff changeset
76 x = (h + 2) / 4;
607
16762f7414de if client is focused, the emptysquare don't needs to be drawed
arg@mig29
parents: 606
diff changeset
77 if(filledsquare) {
608
ecfc43176b2d made squares equally sized, and 1px bigger
arg@mig29
parents: 607
diff changeset
78 r.x = dc.x + 1;
ecfc43176b2d made squares equally sized, and 1px bigger
arg@mig29
parents: 607
diff changeset
79 r.y = dc.y + 1;
ecfc43176b2d made squares equally sized, and 1px bigger
arg@mig29
parents: 607
diff changeset
80 r.width = r.height = x + 1;
605
755d8dcb8a05 sander1 proposal
arg@mig29
parents: 604
diff changeset
81 XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
2
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
82 }
607
16762f7414de if client is focused, the emptysquare don't needs to be drawed
arg@mig29
parents: 606
diff changeset
83 else if(emptysquare) {
608
ecfc43176b2d made squares equally sized, and 1px bigger
arg@mig29
parents: 607
diff changeset
84 pt[0].x = dc.x + 1;
ecfc43176b2d made squares equally sized, and 1px bigger
arg@mig29
parents: 607
diff changeset
85 pt[0].y = dc.y + 1;
606
44b5617c78b3 and the winner is
arg@mig29
parents: 605
diff changeset
86 pt[1].x = x;
44b5617c78b3 and the winner is
arg@mig29
parents: 605
diff changeset
87 pt[1].y = 0;
44b5617c78b3 and the winner is
arg@mig29
parents: 605
diff changeset
88 pt[2].x = 0;
44b5617c78b3 and the winner is
arg@mig29
parents: 605
diff changeset
89 pt[2].y = x;
44b5617c78b3 and the winner is
arg@mig29
parents: 605
diff changeset
90 pt[3].x = -x;
44b5617c78b3 and the winner is
arg@mig29
parents: 605
diff changeset
91 pt[3].y = 0;
44b5617c78b3 and the winner is
arg@mig29
parents: 605
diff changeset
92 pt[4].x = 0;
44b5617c78b3 and the winner is
arg@mig29
parents: 605
diff changeset
93 pt[4].y = -x;
44b5617c78b3 and the winner is
arg@mig29
parents: 605
diff changeset
94 XDrawLines(dpy, dc.drawable, dc.gc, pt, 5, CoordModePrevious);
604
arg@mig29
parents: 602
diff changeset
95 }
arg@mig29
parents: 602
diff changeset
96 }
2
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
97
84
052fe7498930 ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents: 79
diff changeset
98 /* extern */
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
99
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
100 void
487
be4f90c03582 applied Jukkas patch
arg@mmvi
parents: 486
diff changeset
101 drawstatus(void) {
124
75576e44c1d8 made status bar drawing more robust, implemented togglemax and togglemode, works quite well
arg@10ksloc.org
parents: 123
diff changeset
102 int i, x;
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
103
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
104 dc.x = dc.y = 0;
178
e848966a1ac6 removed TLast tag enum, now tags is simple defined as char *[] array, the rest is calculated correctly, rules take an int array for the tags
arg@10ksloc.org
parents: 173
diff changeset
105 for(i = 0; i < ntags; i++) {
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
106 dc.w = textw(tags[i]);
353
8a06efe5b563 new color stuff/new rendering stuff
Anselm R. Garbe <arg@10kloc.org>
parents: 352
diff changeset
107 if(seltag[i])
572
427708bf5f36 added a similiar patch to Daves solution to indicate if there are clients with a specific tag
arg@mig29
parents: 571
diff changeset
108 drawtext(tags[i], dc.sel, sel && sel->tags[i], isoccupied(i));
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
109 else
572
427708bf5f36 added a similiar patch to Daves solution to indicate if there are clients with a specific tag
arg@mig29
parents: 571
diff changeset
110 drawtext(tags[i], dc.norm, sel && sel->tags[i], isoccupied(i));
362
ba6c55e1b9b2 trying a different configuration
Anselm R. Garbe <arg@10kloc.org>
parents: 361
diff changeset
111 dc.x += dc.w;
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
112 }
362
ba6c55e1b9b2 trying a different configuration
Anselm R. Garbe <arg@10kloc.org>
parents: 361
diff changeset
113 dc.w = bmw;
689
cbec08a54a15 implemented new color scheme accordingly to Sanders proposal
Anselm R. Garbe <arg@suckless.org>
parents: 688
diff changeset
114 drawtext(arrange == dofloat ? FLOATSYMBOL : TILESYMBOL, dc.norm, False, False);
361
728e74820e1d removed small 1px gap, somehow without it things feel better
Anselm R. Garbe <arg@10kloc.org>
parents: 360
diff changeset
115 x = dc.x + dc.w;
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
116 dc.w = textw(stext);
697
4d12382fef8e removed unnecessary bx, by, bw variables
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
117 dc.x = sw - dc.w;
342
a1901753deef updated man page
Anselm R. Garbe <arg@10kloc.org>
parents: 340
diff changeset
118 if(dc.x < x) {
a1901753deef updated man page
Anselm R. Garbe <arg@10kloc.org>
parents: 340
diff changeset
119 dc.x = x;
697
4d12382fef8e removed unnecessary bx, by, bw variables
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
120 dc.w = sw - x;
342
a1901753deef updated man page
Anselm R. Garbe <arg@10kloc.org>
parents: 340
diff changeset
121 }
689
cbec08a54a15 implemented new color scheme accordingly to Sanders proposal
Anselm R. Garbe <arg@suckless.org>
parents: 688
diff changeset
122 drawtext(stext, dc.norm, False, False);
371
fc9d35252ab4 applied sanders somepatches.patch
Anselm R. Garbe <arg@10kloc.org>
parents: 362
diff changeset
123 if((dc.w = dc.x - x) > bh) {
342
a1901753deef updated man page
Anselm R. Garbe <arg@10kloc.org>
parents: 340
diff changeset
124 dc.x = x;
572
427708bf5f36 added a similiar patch to Daves solution to indicate if there are clients with a specific tag
arg@mig29
parents: 571
diff changeset
125 drawtext(sel ? sel->name : NULL, sel ? dc.sel : dc.norm, False, False);
124
75576e44c1d8 made status bar drawing more robust, implemented togglemax and togglemode, works quite well
arg@10ksloc.org
parents: 123
diff changeset
126 }
697
4d12382fef8e removed unnecessary bx, by, bw variables
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
127 XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, sw, bh, 0, 0);
79
aabebd6e61f3 fixed XSync handling and finished man page
Anselm R. Garbe <garbeam@wmii.de>
parents: 77
diff changeset
128 XSync(dpy, False);
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
129 }
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
130
43
989178822938 changed default colors
Anselm R. Garbe <garbeam@wmii.de>
parents: 34
diff changeset
131 unsigned long
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 377
diff changeset
132 getcolor(const char *colstr) {
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 93
diff changeset
133 Colormap cmap = DefaultColormap(dpy, screen);
2
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
134 XColor color;
43
989178822938 changed default colors
Anselm R. Garbe <garbeam@wmii.de>
parents: 34
diff changeset
135
495
3a812750f983 added slight error check to getcolor
arg@mmvi
parents: 487
diff changeset
136 if(!XAllocNamedColor(dpy, cmap, colstr, &color, &color))
3a812750f983 added slight error check to getcolor
arg@mmvi
parents: 487
diff changeset
137 eprint("error, cannot allocate color '%s'\n", colstr);
2
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
138 return color.pixel;
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
139 }
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
140
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
141 void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 377
diff changeset
142 setfont(const char *fontstr) {
619
bda4880c462d with this patch everything works fine for me
arg@mig29
parents: 618
diff changeset
143 char *def, **missing;
33
e90449e03167 new stuff (some warning elimination)
Anselm R. Garbe <garbeam@wmii.de>
parents: 32
diff changeset
144 int i, n;
2
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
145
7
49e2fc9fb94f new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 5
diff changeset
146 missing = NULL;
43
989178822938 changed default colors
Anselm R. Garbe <garbeam@wmii.de>
parents: 34
diff changeset
147 if(dc.font.set)
989178822938 changed default colors
Anselm R. Garbe <garbeam@wmii.de>
parents: 34
diff changeset
148 XFreeFontSet(dpy, dc.font.set);
989178822938 changed default colors
Anselm R. Garbe <garbeam@wmii.de>
parents: 34
diff changeset
149 dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def);
2
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
150 if(missing) {
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
151 while(n--)
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
152 fprintf(stderr, "missing fontset: %s\n", missing[n]);
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
153 XFreeStringList(missing);
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
154 }
43
989178822938 changed default colors
Anselm R. Garbe <garbeam@wmii.de>
parents: 34
diff changeset
155 if(dc.font.set) {
2
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
156 XFontSetExtents *font_extents;
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
157 XFontStruct **xfonts;
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
158 char **font_names;
43
989178822938 changed default colors
Anselm R. Garbe <garbeam@wmii.de>
parents: 34
diff changeset
159 dc.font.ascent = dc.font.descent = 0;
989178822938 changed default colors
Anselm R. Garbe <garbeam@wmii.de>
parents: 34
diff changeset
160 font_extents = XExtentsOfFontSet(dc.font.set);
989178822938 changed default colors
Anselm R. Garbe <garbeam@wmii.de>
parents: 34
diff changeset
161 n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names);
989178822938 changed default colors
Anselm R. Garbe <garbeam@wmii.de>
parents: 34
diff changeset
162 for(i = 0, dc.font.ascent = 0, dc.font.descent = 0; i < n; i++) {
989178822938 changed default colors
Anselm R. Garbe <garbeam@wmii.de>
parents: 34
diff changeset
163 if(dc.font.ascent < (*xfonts)->ascent)
989178822938 changed default colors
Anselm R. Garbe <garbeam@wmii.de>
parents: 34
diff changeset
164 dc.font.ascent = (*xfonts)->ascent;
989178822938 changed default colors
Anselm R. Garbe <garbeam@wmii.de>
parents: 34
diff changeset
165 if(dc.font.descent < (*xfonts)->descent)
989178822938 changed default colors
Anselm R. Garbe <garbeam@wmii.de>
parents: 34
diff changeset
166 dc.font.descent = (*xfonts)->descent;
2
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
167 xfonts++;
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
168 }
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
169 }
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
170 else {
43
989178822938 changed default colors
Anselm R. Garbe <garbeam@wmii.de>
parents: 34
diff changeset
171 if(dc.font.xfont)
989178822938 changed default colors
Anselm R. Garbe <garbeam@wmii.de>
parents: 34
diff changeset
172 XFreeFont(dpy, dc.font.xfont);
989178822938 changed default colors
Anselm R. Garbe <garbeam@wmii.de>
parents: 34
diff changeset
173 dc.font.xfont = NULL;
626
2644c951fc74 removed the hardcoded fixed fallback, it is useless in non-Latin1 environments
arg@mig29
parents: 619
diff changeset
174 if(!(dc.font.xfont = XLoadQueryFont(dpy, fontstr)))
627
f83ac177a3a0 fixed diagnostic error message
arg@mig29
parents: 626
diff changeset
175 eprint("error, cannot load font: '%s'\n", fontstr);
43
989178822938 changed default colors
Anselm R. Garbe <garbeam@wmii.de>
parents: 34
diff changeset
176 dc.font.ascent = dc.font.xfont->ascent;
989178822938 changed default colors
Anselm R. Garbe <garbeam@wmii.de>
parents: 34
diff changeset
177 dc.font.descent = dc.font.xfont->descent;
2
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
178 }
43
989178822938 changed default colors
Anselm R. Garbe <garbeam@wmii.de>
parents: 34
diff changeset
179 dc.font.height = dc.font.ascent + dc.font.descent;
2
a79188fe4a40 added new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
180 }
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
181
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
182 unsigned int
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 377
diff changeset
183 textw(const char *text) {
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
184 return textnw(text, strlen(text)) + dc.font.height;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
185 }