author | Anselm R. Garbe <garbeam@gmail.com> |
Sat, 15 Sep 2007 20:39:31 +0200 | |
changeset 989 | 5f7018237edb |
parent 988 | aea51354bbe6 |
permissions | -rw-r--r-- |
910
c13cb8c6b7a5
referred to LICENSE file
Anselm R. Garbe <arg@suckless.org>
parents:
909
diff
changeset
|
1 |
/* See LICENSE file for copyright and license details. */ |
793
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
2 |
#include "dwm.h" |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
3 |
#include <string.h> |
988
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
4 |
#include <stdio.h> |
793
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
5 |
|
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
6 |
/* static */ |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
7 |
|
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
8 |
static void |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
9 |
drawsquare(Bool filled, Bool empty, unsigned long col[ColLast]) { |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
10 |
int x; |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
11 |
XGCValues gcv; |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
12 |
XRectangle r = { dc.x, dc.y, dc.w, dc.h }; |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
13 |
|
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
14 |
gcv.foreground = col[ColFG]; |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
15 |
XChangeGC(dpy, dc.gc, GCForeground, &gcv); |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
16 |
x = (dc.font.ascent + dc.font.descent + 2) / 4; |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
17 |
r.x = dc.x + 1; |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
18 |
r.y = dc.y + 1; |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
19 |
if(filled) { |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
20 |
r.width = r.height = x + 1; |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
21 |
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
22 |
} |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
23 |
else if(empty) { |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
24 |
r.width = r.height = x; |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
25 |
XDrawRectangles(dpy, dc.drawable, dc.gc, &r, 1); |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
26 |
} |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
27 |
} |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
28 |
|
988
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
29 |
static unsigned long |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
30 |
initcolor(const char *colstr) { |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
31 |
Colormap cmap = DefaultColormap(dpy, screen); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
32 |
XColor color; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
33 |
|
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
34 |
if(!XAllocNamedColor(dpy, cmap, colstr, &color, &color)) |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
35 |
eprint("error, cannot allocate color '%s'\n", colstr); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
36 |
return color.pixel; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
37 |
} |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
38 |
|
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
39 |
static void |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
40 |
initfont(const char *fontstr) { |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
41 |
char *def, **missing; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
42 |
int i, n; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
43 |
|
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
44 |
missing = NULL; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
45 |
if(dc.font.set) |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
46 |
XFreeFontSet(dpy, dc.font.set); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
47 |
dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
48 |
if(missing) { |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
49 |
while(n--) |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
50 |
fprintf(stderr, "dwm: missing fontset: %s\n", missing[n]); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
51 |
XFreeStringList(missing); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
52 |
} |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
53 |
if(dc.font.set) { |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
54 |
XFontSetExtents *font_extents; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
55 |
XFontStruct **xfonts; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
56 |
char **font_names; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
57 |
dc.font.ascent = dc.font.descent = 0; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
58 |
font_extents = XExtentsOfFontSet(dc.font.set); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
59 |
n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
60 |
for(i = 0, dc.font.ascent = 0, dc.font.descent = 0; i < n; i++) { |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
61 |
if(dc.font.ascent < (*xfonts)->ascent) |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
62 |
dc.font.ascent = (*xfonts)->ascent; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
63 |
if(dc.font.descent < (*xfonts)->descent) |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
64 |
dc.font.descent = (*xfonts)->descent; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
65 |
xfonts++; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
66 |
} |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
67 |
} |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
68 |
else { |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
69 |
if(dc.font.xfont) |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
70 |
XFreeFont(dpy, dc.font.xfont); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
71 |
dc.font.xfont = NULL; |
989
5f7018237edb
new colorscheme (16-bit compliant)
Anselm R. Garbe <garbeam@gmail.com>
parents:
988
diff
changeset
|
72 |
if(!(dc.font.xfont = XLoadQueryFont(dpy, fontstr)) |
5f7018237edb
new colorscheme (16-bit compliant)
Anselm R. Garbe <garbeam@gmail.com>
parents:
988
diff
changeset
|
73 |
|| !(dc.font.xfont = XLoadQueryFont(dpy, "fixed"))) |
988
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
74 |
eprint("error, cannot load font: '%s'\n", fontstr); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
75 |
dc.font.ascent = dc.font.xfont->ascent; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
76 |
dc.font.descent = dc.font.xfont->descent; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
77 |
} |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
78 |
dc.font.height = dc.font.ascent + dc.font.descent; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
79 |
} |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
80 |
|
793
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
81 |
static Bool |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
82 |
isoccupied(unsigned int t) { |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
83 |
Client *c; |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
84 |
|
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
85 |
for(c = clients; c; c = c->next) |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
86 |
if(c->tags[t]) |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
87 |
return True; |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
88 |
return False; |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
89 |
} |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
90 |
|
794 | 91 |
static unsigned int |
92 |
textnw(const char *text, unsigned int len) { |
|
93 |
XRectangle r; |
|
94 |
||
95 |
if(dc.font.set) { |
|
96 |
XmbTextExtents(dc.font.set, text, len, NULL, &r); |
|
97 |
return r.width; |
|
98 |
} |
|
99 |
return XTextWidth(dc.font.xfont, text, len); |
|
100 |
} |
|
101 |
||
988
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
102 |
static void |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
103 |
drawtext(const char *text, unsigned long col[ColLast]) { |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
104 |
int x, y, w, h; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
105 |
static char buf[256]; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
106 |
unsigned int len, olen; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
107 |
XRectangle r = { dc.x, dc.y, dc.w, dc.h }; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
108 |
|
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
109 |
XSetForeground(dpy, dc.gc, col[ColBG]); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
110 |
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
111 |
if(!text) |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
112 |
return; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
113 |
w = 0; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
114 |
olen = len = strlen(text); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
115 |
if(len >= sizeof buf) |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
116 |
len = sizeof buf - 1; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
117 |
memcpy(buf, text, len); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
118 |
buf[len] = 0; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
119 |
h = dc.font.ascent + dc.font.descent; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
120 |
y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
121 |
x = dc.x + (h / 2); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
122 |
/* shorten text if necessary */ |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
123 |
while(len && (w = textnw(buf, len)) > dc.w - h) |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
124 |
buf[--len] = 0; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
125 |
if(len < olen) { |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
126 |
if(len > 1) |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
127 |
buf[len - 1] = '.'; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
128 |
if(len > 2) |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
129 |
buf[len - 2] = '.'; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
130 |
if(len > 3) |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
131 |
buf[len - 3] = '.'; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
132 |
} |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
133 |
if(w > dc.w) |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
134 |
return; /* too long */ |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
135 |
XSetForeground(dpy, dc.gc, col[ColFG]); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
136 |
if(dc.font.set) |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
137 |
XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
138 |
else |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
139 |
XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
140 |
} |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
141 |
|
793
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
142 |
/* extern */ |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
143 |
|
988
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
144 |
unsigned int bh; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
145 |
unsigned int bpos = BARPOS; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
146 |
DC dc = {0}; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
147 |
Window barwin; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
148 |
|
793
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
149 |
void |
987
ea0cef59c3a3
renamed drawstatus into drawbar
Anselm R. Garbe <garbeam@gmail.com>
parents:
960
diff
changeset
|
150 |
drawbar(void) { |
793
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
151 |
int i, x; |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
152 |
|
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
153 |
dc.x = dc.y = 0; |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
154 |
for(i = 0; i < ntags; i++) { |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
155 |
dc.w = textw(tags[i]); |
960
b5f856fcef4c
renamed seltag into seltags
Anselm R. Garbe <garbeam@gmail.com>
parents:
946
diff
changeset
|
156 |
if(seltags[i]) { |
793
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
157 |
drawtext(tags[i], dc.sel); |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
158 |
drawsquare(sel && sel->tags[i], isoccupied(i), dc.sel); |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
159 |
} |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
160 |
else { |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
161 |
drawtext(tags[i], dc.norm); |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
162 |
drawsquare(sel && sel->tags[i], isoccupied(i), dc.norm); |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
163 |
} |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
164 |
dc.x += dc.w; |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
165 |
} |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
166 |
dc.w = blw; |
946
b938876de936
made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents:
910
diff
changeset
|
167 |
drawtext(getsymbol(), dc.norm); |
793
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
168 |
x = dc.x + dc.w; |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
169 |
dc.w = textw(stext); |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
170 |
dc.x = sw - dc.w; |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
171 |
if(dc.x < x) { |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
172 |
dc.x = x; |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
173 |
dc.w = sw - x; |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
174 |
} |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
175 |
drawtext(stext, dc.norm); |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
176 |
if((dc.w = dc.x - x) > bh) { |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
177 |
dc.x = x; |
817
90435b444620
dwm draws a small caret before the client title if it's a versatile client
Anselm R. Garbe <arg@suckless.org>
parents:
794
diff
changeset
|
178 |
if(sel) { |
90435b444620
dwm draws a small caret before the client title if it's a versatile client
Anselm R. Garbe <arg@suckless.org>
parents:
794
diff
changeset
|
179 |
drawtext(sel->name, dc.sel); |
837
123231b9eb87
renamed untiled into floating, keeping tiled instead of tiling (afaik tiled sounds more correct) - English speakers convinced me
Anselm R. Garbe <arg@suckless.org>
parents:
830
diff
changeset
|
180 |
drawsquare(sel->ismax, sel->isfloating, dc.sel); |
817
90435b444620
dwm draws a small caret before the client title if it's a versatile client
Anselm R. Garbe <arg@suckless.org>
parents:
794
diff
changeset
|
181 |
} |
90435b444620
dwm draws a small caret before the client title if it's a versatile client
Anselm R. Garbe <arg@suckless.org>
parents:
794
diff
changeset
|
182 |
else |
90435b444620
dwm draws a small caret before the client title if it's a versatile client
Anselm R. Garbe <arg@suckless.org>
parents:
794
diff
changeset
|
183 |
drawtext(NULL, dc.norm); |
793
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
184 |
} |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
185 |
XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, sw, bh, 0, 0); |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
186 |
XSync(dpy, False); |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
187 |
} |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
188 |
|
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
189 |
void |
989
5f7018237edb
new colorscheme (16-bit compliant)
Anselm R. Garbe <garbeam@gmail.com>
parents:
988
diff
changeset
|
190 |
initstyle(void) { |
988
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
191 |
dc.norm[ColBorder] = initcolor(NORMBORDERCOLOR); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
192 |
dc.norm[ColBG] = initcolor(NORMBGCOLOR); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
193 |
dc.norm[ColFG] = initcolor(NORMFGCOLOR); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
194 |
dc.sel[ColBorder] = initcolor(SELBORDERCOLOR); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
195 |
dc.sel[ColBG] = initcolor(SELBGCOLOR); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
196 |
dc.sel[ColFG] = initcolor(SELFGCOLOR); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
197 |
initfont(FONT); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
198 |
dc.h = bh = dc.font.height + 2; |
989
5f7018237edb
new colorscheme (16-bit compliant)
Anselm R. Garbe <garbeam@gmail.com>
parents:
988
diff
changeset
|
199 |
} |
5f7018237edb
new colorscheme (16-bit compliant)
Anselm R. Garbe <garbeam@gmail.com>
parents:
988
diff
changeset
|
200 |
|
5f7018237edb
new colorscheme (16-bit compliant)
Anselm R. Garbe <garbeam@gmail.com>
parents:
988
diff
changeset
|
201 |
void |
5f7018237edb
new colorscheme (16-bit compliant)
Anselm R. Garbe <garbeam@gmail.com>
parents:
988
diff
changeset
|
202 |
initbar(void) { |
5f7018237edb
new colorscheme (16-bit compliant)
Anselm R. Garbe <garbeam@gmail.com>
parents:
988
diff
changeset
|
203 |
XSetWindowAttributes wa; |
5f7018237edb
new colorscheme (16-bit compliant)
Anselm R. Garbe <garbeam@gmail.com>
parents:
988
diff
changeset
|
204 |
|
988
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
205 |
wa.override_redirect = 1; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
206 |
wa.background_pixmap = ParentRelative; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
207 |
wa.event_mask = ButtonPressMask | ExposureMask; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
208 |
barwin = XCreateWindow(dpy, root, sx, sy, sw, bh, 0, |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
209 |
DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen), |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
210 |
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
211 |
XDefineCursor(dpy, barwin, cursor[CurNormal]); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
212 |
updatebarpos(); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
213 |
XMapRaised(dpy, barwin); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
214 |
strcpy(stext, "dwm-"VERSION); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
215 |
dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen)); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
216 |
dc.gc = XCreateGC(dpy, root, 0, 0); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
217 |
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
218 |
if(!dc.font.set) |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
219 |
XSetFont(dpy, dc.gc, dc.font.xfont->fid); |
793
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
220 |
} |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
221 |
|
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
222 |
unsigned int |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
223 |
textw(const char *text) { |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
224 |
return textnw(text, strlen(text)) + dc.font.height; |
79cb72e82b21
added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
225 |
} |
988
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
226 |
|
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
227 |
void |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
228 |
togglebar(const char *arg) { |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
229 |
if(bpos == BarOff) |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
230 |
bpos = (BARPOS == BarOff) ? BarTop : BARPOS; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
231 |
else |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
232 |
bpos = BarOff; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
233 |
updatebarpos(); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
234 |
arrange(); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
235 |
} |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
236 |
|
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
237 |
void |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
238 |
updatebarpos(void) { |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
239 |
XEvent ev; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
240 |
|
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
241 |
wax = sx; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
242 |
way = sy; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
243 |
wah = sh; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
244 |
waw = sw; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
245 |
switch(bpos) { |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
246 |
default: |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
247 |
wah -= bh; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
248 |
way += bh; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
249 |
XMoveWindow(dpy, barwin, sx, sy); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
250 |
break; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
251 |
case BarBot: |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
252 |
wah -= bh; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
253 |
XMoveWindow(dpy, barwin, sx, sy + wah); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
254 |
break; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
255 |
case BarOff: |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
256 |
XMoveWindow(dpy, barwin, sx, sy - bh); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
257 |
break; |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
258 |
} |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
259 |
XSync(dpy, False); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
260 |
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
261 |
} |
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
262 |
|
aea51354bbe6
moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents:
987
diff
changeset
|
263 |