summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnselm R. Garbe <garbeam@wmii.de>2006-07-10 22:16:48 +0200
committerAnselm R. Garbe <garbeam@wmii.de>2006-07-10 22:16:48 +0200
commit439e15d09f6fa9271d3b49ef97194f0c80ebe161 (patch)
tree0f1abd8629f3fc226bb313ce29f00b6b8424f375
parentrenamed gridmenu.c into menu.c (diff)
downloaddwm-439e15d09f6fa9271d3b49ef97194f0c80ebe161.tar.gz
dwm-439e15d09f6fa9271d3b49ef97194f0c80ebe161.zip
added several other stuff
Diffstat (limited to '')
-rw-r--r--Makefile4
-rw-r--r--bar.c18
-rw-r--r--client.c89
-rw-r--r--config.h4
-rw-r--r--draw.c6
-rw-r--r--draw.h1
-rw-r--r--event.c264
-rw-r--r--menu.c9
-rw-r--r--util.c23
-rw-r--r--util.h6
-rw-r--r--wm.c51
-rw-r--r--wm.h40
12 files changed, 476 insertions, 39 deletions
diff --git a/Makefile b/Makefile
index 7a74149..c5c8db4 100644
--- a/Makefile
+++ b/Makefile
@@ -3,11 +3,11 @@
3 3
4include config.mk 4include config.mk
5 5
6WMSRC = wm.c draw.c util.c 6WMSRC = bar.c client.c draw.c event.c util.c wm.c
7WMOBJ = ${WMSRC:.c=.o} 7WMOBJ = ${WMSRC:.c=.o}
8MENSRC = menu.c draw.c util.c 8MENSRC = menu.c draw.c util.c
9MENOBJ = ${MENSRC:.c=.o} 9MENOBJ = ${MENSRC:.c=.o}
10MAN = gridwm.1 10MAN1 = gridwm.1 gridmenu.1
11BIN = gridwm gridmenu 11BIN = gridwm gridmenu
12 12
13all: config gridwm gridmenu 13all: config gridwm gridmenu
diff --git a/bar.c b/bar.c
new file mode 100644
index 0000000..8d4fb36
--- /dev/null
+++ b/bar.c
@@ -0,0 +1,18 @@
1/*
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details.
4 */
5
6#include "wm.h"
7
8void
9draw_bar()
10{
11 brush.rect = barrect;
12 brush.rect.x = brush.rect.y = 0;
13 draw(dpy, &brush, False, 0);
14
15 XCopyArea(dpy, brush.drawable, barwin, brush.gc, 0, 0, barrect.width,
16 barrect.height, 0, 0);
17 XFlush(dpy);
18}
diff --git a/client.c b/client.c
new file mode 100644
index 0000000..a5141ea
--- /dev/null
+++ b/client.c
@@ -0,0 +1,89 @@
1/*
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details.
4 */
5
6#include <string.h>
7#include <X11/Xatom.h>
8
9#include "util.h"
10#include "wm.h"
11
12static void
13update_client_name(Client *c)
14{
15 XTextProperty name;
16 int n;
17 char **list = 0;
18
19 name.nitems = 0;
20 c->name[0] = 0;
21 XGetTextProperty(dpy, c->win, &name, net_atom[NetWMName]);
22 if(!name.nitems)
23 XGetWMName(dpy, c->win, &name);
24 if(!name.nitems)
25 return;
26 if(name.encoding == XA_STRING)
27 strncpy(c->name, (char *)name.value, sizeof(c->name));
28 else {
29 if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
30 && n > 0 && *list)
31 {
32 strncpy(c->name, *list, sizeof(c->name));
33 XFreeStringList(list);
34 }
35 }
36 XFree(name.value);
37}
38
39Client *
40create_client(Window w, XWindowAttributes *wa)
41{
42 Client *c;
43 XSetWindowAttributes twa;
44 long msize;
45
46 c = emallocz(sizeof(Client));
47 c->win = w;
48 c->r[RFloat].x = wa->x;
49 c->r[RFloat].y = wa->y;
50 c->r[RFloat].width = wa->width;
51 c->r[RFloat].height = wa->height;
52 c->border = wa->border_width;
53 XSetWindowBorderWidth(dpy, c->win, 0);
54 c->proto = win_proto(c->win);
55 XGetTransientForHint(dpy, c->win, &c->trans);
56 if(!XGetWMNormalHints(dpy, c->win, &c->size, &msize) || !c->size.flags)
57 c->size.flags = PSize;
58 c->fixedsize =
59 (c->size.flags & PMinSize && c->size.flags & PMaxSize
60 && c->size.min_width == c->size.max_width
61 && c->size.min_height == c->size.max_height);
62 XAddToSaveSet(dpy, c->win);
63 update_client_name(c);
64 twa.override_redirect = 1;
65 twa.background_pixmap = ParentRelative;
66 twa.event_mask = ExposureMask;
67
68 c->title = XCreateWindow(dpy, root, c->r[RFloat].x, c->r[RFloat].y,
69 c->r[RFloat].width, barrect.height, 0,
70 DefaultDepth(dpy, screen), CopyFromParent,
71 DefaultVisual(dpy, screen),
72 CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
73 XFlush(dpy);
74
75#if 0
76 for(t=&client, i=0; *t; t=&(*t)->next, i++);
77 c->next = *t; /* *t == nil */
78 *t = c;
79#endif
80 return c;
81}
82
83void
84manage(Client *c)
85{
86 XMapRaised(dpy, c->win);
87 XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
88 XFlush(dpy);
89}
diff --git a/config.h b/config.h
index 6a768b6..ca05aa2 100644
--- a/config.h
+++ b/config.h
@@ -4,6 +4,6 @@
4 */ 4 */
5 5
6#define FONT "-*-terminus-medium-*-*-*-14-*-*-*-*-*-iso10646-*" 6#define FONT "-*-terminus-medium-*-*-*-14-*-*-*-*-*-iso10646-*"
7#define FGCOLOR "#000000" 7#define BGCOLOR "#000000"
8#define BGCOLOR "#ffaa00" 8#define FGCOLOR "#ffaa00"
9#define BORDERCOLOR "#000000" 9#define BORDERCOLOR "#000000"
diff --git a/draw.c b/draw.c
index cf7f14e..b89c365 100644
--- a/draw.c
+++ b/draw.c
@@ -162,3 +162,9 @@ loadfont(Display *dpy, Fnt *font, const char *fontstr)
162 } 162 }
163 font->height = font->ascent + font->descent; 163 font->height = font->ascent + font->descent;
164} 164}
165
166unsigned int
167labelheight(Fnt *font)
168{
169 return font->height + 4;
170}
diff --git a/draw.h b/draw.h
index 710087f..6c3d886 100644
--- a/draw.h
+++ b/draw.h
@@ -33,3 +33,4 @@ extern void loadcolors(Display *dpy, int screen, Brush *b,
33extern void loadfont(Display *dpy, Fnt *font, const char *fontstr); 33extern void loadfont(Display *dpy, Fnt *font, const char *fontstr);
34extern unsigned int textwidth_l(Fnt *font, char *text, unsigned int len); 34extern unsigned int textwidth_l(Fnt *font, char *text, unsigned int len);
35extern unsigned int textwidth(Fnt *font, char *text); 35extern unsigned int textwidth(Fnt *font, char *text);
36extern unsigned int labelheight(Fnt *font);
diff --git a/event.c b/event.c
new file mode 100644
index 0000000..d6977d3
--- /dev/null
+++ b/event.c
@@ -0,0 +1,264 @@
1/*
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details.
4 */
5
6#include <fcntl.h>
7#include <stdlib.h>
8#include <string.h>
9#include <X11/keysym.h>
10
11#include "wm.h"
12
13/* local functions */
14static void configurerequest(XEvent *e);
15static void destroynotify(XEvent *e);
16static void enternotify(XEvent *e);
17static void leavenotify(XEvent *e);
18static void expose(XEvent *e);
19static void keypress(XEvent *e);
20static void keymapnotify(XEvent *e);
21static void maprequest(XEvent *e);
22static void propertynotify(XEvent *e);
23static void unmapnotify(XEvent *e);
24
25void (*handler[LASTEvent]) (XEvent *) = {
26 [ConfigureRequest] = configurerequest,
27 [DestroyNotify] = destroynotify,
28 [EnterNotify] = enternotify,
29 [LeaveNotify] = leavenotify,
30 [Expose] = expose,
31 [KeyPress] = keypress,
32 [KeymapNotify] = keymapnotify,
33 [MapRequest] = maprequest,
34 [PropertyNotify] = propertynotify,
35 [UnmapNotify] = unmapnotify
36};
37
38unsigned int
39flush_masked_events(long even_mask)
40{
41 XEvent ev;
42 unsigned int n = 0;
43 while(XCheckMaskEvent(dpy, even_mask, &ev)) n++;
44 return n;
45}
46
47static void
48configurerequest(XEvent *e)
49{
50#if 0
51 XConfigureRequestEvent *ev = &e->xconfigurerequest;
52 XWindowChanges wc;
53 XRectangle *frect;
54 Client *c;
55
56 c = client_of_win(ev->window);
57 ev->value_mask &= ~CWSibling;
58 if(c) {
59 gravitate_client(c, True);
60
61 if(ev->value_mask & CWX)
62 c->rect.x = ev->x;
63 if(ev->value_mask & CWY)
64 c->rect.y = ev->y;
65 if(ev->value_mask & CWWidth)
66 c->rect.width = ev->width;
67 if(ev->value_mask & CWHeight)
68 c->rect.height = ev->height;
69 if(ev->value_mask & CWBorderWidth)
70 c->border = ev->border_width;
71
72 gravitate_client(c, False);
73
74 if(c->frame) {
75 if(c->sel->area->floating)
76 frect=&c->sel->rect;
77 else
78 frect=&c->sel->revert;
79
80 if(c->rect.width >= screen->rect.width && c->rect.height >= screen->rect.height) {
81 frect->y = wc.y = -height_of_bar();
82 frect->x = wc.x = -def.border;
83 }
84 else {
85 frect->y = wc.y = c->rect.y - height_of_bar();
86 frect->x = wc.x = c->rect.x - def.border;
87 }
88 frect->width = wc.width = c->rect.width + 2 * def.border;
89 frect->height = wc.height = c->rect.height + def.border
90 + height_of_bar();
91 wc.border_width = 1;
92 wc.sibling = None;
93 wc.stack_mode = ev->detail;
94 if(c->sel->area->view != screen->sel)
95 wc.x += 2 * screen->rect.width;
96 if(c->sel->area->floating) {
97 XConfigureWindow(dpy, c->framewin, ev->value_mask, &wc);
98 configure_client(c);
99 }
100 }
101 }
102
103 wc.x = ev->x;
104 wc.y = ev->y;
105 wc.width = ev->width;
106 wc.height = ev->height;
107
108 if(c && c->frame) {
109 wc.x = def.border;
110 wc.y = height_of_bar();
111 wc.width = c->sel->rect.width - 2 * def.border;
112 wc.height = c->sel->rect.height - def.border - height_of_bar();
113 }
114
115 wc.border_width = 0;
116 wc.sibling = None;
117 wc.stack_mode = Above;
118 ev->value_mask &= ~CWStackMode;
119 ev->value_mask |= CWBorderWidth;
120 XConfigureWindow(dpy, ev->window, ev->value_mask, &wc);
121
122 XFlush(dpy);
123#endif
124}
125
126static void
127destroynotify(XEvent *e)
128{
129#if 0
130 Client *c;
131 XDestroyWindowEvent *ev = &e->xdestroywindow;
132
133 if((c = client_of_win(ev->window)))
134 destroy_client(c);
135#endif
136}
137
138static void
139enternotify(XEvent *e)
140{
141#if 0
142 XCrossingEvent *ev = &e->xcrossing;
143 Client *c;
144
145 if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
146 return;
147
148 if((c = client_of_win(ev->window))) {
149 Frame *f = c->sel;
150 Area *a = f->area;
151 if(a->mode == Colmax)
152 c = a->sel->client;
153 focus(c, False);
154 }
155 else if(ev->window == root) {
156 sel_screen = True;
157 draw_frames();
158 }
159#endif
160}
161
162static void
163leavenotify(XEvent *e)
164{
165 XCrossingEvent *ev = &e->xcrossing;
166
167 if((ev->window == root) && !ev->same_screen) {
168 sel_screen = True;
169 /*draw_frames();*/
170 }
171}
172
173static void
174expose(XEvent *e)
175{
176 XExposeEvent *ev = &e->xexpose;
177
178 if(ev->count == 0) {
179 if(ev->window == barwin)
180 draw_bar();
181 }
182}
183
184static void
185keypress(XEvent *e)
186{
187#if 0
188 XKeyEvent *ev = &e->xkey;
189 KeySym k = 0;
190 char buf[32];
191 int n;
192 static Frame *f;
193
194
195 ev->state &= valid_mask;
196 if((f = frame_of_win(ev->window))) {
197 buf[0] = 0;
198 n = XLookupString(ev, buf, sizeof(buf), &k, 0);
199 if(IsFunctionKey(k) || IsKeypadKey(k) || IsMiscFunctionKey(k)
200 || IsPFKey(k) || IsPrivateKeypadKey(k))
201 return;
202 buf[n] = 0;
203 blitz_kpress_input(&f->tagbar, ev->state, k, buf);
204 }
205 else
206 key(root, ev->state, (KeyCode) ev->keycode);
207#endif
208}
209
210static void
211keymapnotify(XEvent *e)
212{
213#if 0
214 update_keys();
215#endif
216}
217
218static void
219maprequest(XEvent *e)
220{
221#if 0
222 XMapRequestEvent *ev = &e->xmaprequest;
223 static XWindowAttributes wa;
224
225 if(!XGetWindowAttributes(dpy, ev->window, &wa))
226 return;
227
228 if(wa.override_redirect) {
229 XSelectInput(dpy, ev->window,
230 (StructureNotifyMask | PropertyChangeMask));
231 return;
232 }
233
234 if(!client_of_win(ev->window))
235 manage_client(create_client(ev->window, &wa));
236#endif
237}
238
239static void
240propertynotify(XEvent *e)
241{
242#if 0
243 XPropertyEvent *ev = &e->xproperty;
244 Client *c;
245
246 if(ev->state == PropertyDelete)
247 return; /* ignore */
248
249 if((c = client_of_win(ev->window)))
250 prop_client(c, ev);
251#endif
252}
253
254static void
255unmapnotify(XEvent *e)
256{
257#if 0
258 Client *c;
259 XUnmapEvent *ev = &e->xunmap;
260
261 if((c = client_of_win(ev->window)))
262 destroy_client(c);
263#endif
264}
diff --git a/menu.c b/menu.c
index b4e08d4..7c84305 100644
--- a/menu.c
+++ b/menu.c
@@ -53,7 +53,7 @@ static const int seek = 30; /* 30px */
53 53
54static Brush brush = {0}; 54static Brush brush = {0};
55 55
56static void draw_menu(void); 56static void draw_menu();
57static void kpress(XKeyEvent * e); 57static void kpress(XKeyEvent * e);
58 58
59static char version[] = "gridmenu - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n"; 59static char version[] = "gridmenu - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
@@ -397,11 +397,10 @@ main(int argc, char *argv[])
397 397
398 wa.override_redirect = 1; 398 wa.override_redirect = 1;
399 wa.background_pixmap = ParentRelative; 399 wa.background_pixmap = ParentRelative;
400 wa.event_mask = ExposureMask | ButtonPressMask | KeyPressMask 400 wa.event_mask = ExposureMask | ButtonPressMask | KeyPressMask;
401 | SubstructureRedirectMask | SubstructureNotifyMask;
402 401
403 rect.width = DisplayWidth(dpy, screen); 402 rect.width = DisplayWidth(dpy, screen);
404 rect.height = brush.font.height + 4; 403 rect.height = labelheight(&brush.font);
405 rect.y = DisplayHeight(dpy, screen) - rect.height; 404 rect.y = DisplayHeight(dpy, screen) - rect.height;
406 rect.x = 0; 405 rect.x = 0;
407 406
@@ -413,7 +412,7 @@ main(int argc, char *argv[])
413 XFlush(dpy); 412 XFlush(dpy);
414 413
415 /* pixmap */ 414 /* pixmap */
416 brush.gc = XCreateGC(dpy, win, 0, 0); 415 brush.gc = XCreateGC(dpy, root, 0, 0);
417 brush.drawable = XCreatePixmap(dpy, win, rect.width, rect.height, 416 brush.drawable = XCreatePixmap(dpy, win, rect.width, rect.height,
418 DefaultDepth(dpy, screen)); 417 DefaultDepth(dpy, screen));
419 XFlush(dpy); 418 XFlush(dpy);
diff --git a/util.c b/util.c
index 99842e9..435069f 100644
--- a/util.c
+++ b/util.c
@@ -7,6 +7,11 @@
7#include <stdio.h> 7#include <stdio.h>
8#include <stdlib.h> 8#include <stdlib.h>
9#include <string.h> 9#include <string.h>
10#include <sys/types.h>
11#include <sys/wait.h>
12#include <unistd.h>
13
14#include "util.h"
10 15
11void 16void
12error(char *errstr, ...) { 17error(char *errstr, ...) {
@@ -75,3 +80,21 @@ swap(void **p1, void **p2)
75 *p1 = *p2; 80 *p1 = *p2;
76 *p2 = tmp; 81 *p2 = tmp;
77} 82}
83
84void
85spawn(Display *dpy, const char *shell, const char *cmd)
86{
87 if(!cmd || !shell)
88 return;
89 if(fork() == 0) {
90 if(fork() == 0) {
91 if(dpy)
92 close(ConnectionNumber(dpy));
93 execl(shell, shell, "-c", cmd, (const char *)0);
94 fprintf(stderr, "gridwm: execl %s", shell);
95 perror(" failed");
96 }
97 exit (0);
98 }
99 wait(0);
100}
diff --git a/util.h b/util.h
index 8ba444b..cac3df0 100644
--- a/util.h
+++ b/util.h
@@ -2,6 +2,7 @@
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details. 3 * See LICENSE file for license details.
4 */ 4 */
5#include <X11/Xlib.h>
5 6
6extern void error(char *errstr, ...); 7extern void error(char *errstr, ...);
7extern void *emallocz(unsigned int size); 8extern void *emallocz(unsigned int size);
@@ -12,5 +13,6 @@ extern char *estrdup(const char *str);
12 if(!(a)) \ 13 if(!(a)) \
13 failed_assert(#a, __FILE__, __LINE__); \ 14 failed_assert(#a, __FILE__, __LINE__); \
14 } while (0) 15 } while (0)
15void failed_assert(char *a, char *file, int line); 16extern void failed_assert(char *a, char *file, int line);
16void swap(void **p1, void **p2); 17extern void swap(void **p1, void **p2);
18extern void spawn(Display *dpy, const char *shell, const char *cmd);
diff --git a/wm.c b/wm.c
index c8bb0a4..b8b3053 100644
--- a/wm.c
+++ b/wm.c
@@ -15,15 +15,15 @@
15 15
16/* X structs */ 16/* X structs */
17Display *dpy; 17Display *dpy;
18Window root; 18Window root, barwin;
19XRectangle rect; 19Atom wm_atom[WMLast], net_atom[NetLast];
20Pixmap pmap;
21Atom wm_atom[WMLast];
22Atom net_atom[NetLast];
23Cursor cursor[CurLast]; 20Cursor cursor[CurLast];
21XRectangle rect, barrect;
22Bool running = True;
24 23
24char *bartext, *shell;
25int screen, sel_screen; 25int screen, sel_screen;
26unsigned int kmask, numlock_mask; 26unsigned int lock_mask, numlock_mask;
27 27
28/* draw structs */ 28/* draw structs */
29Brush brush = {0}; 29Brush brush = {0};
@@ -166,7 +166,7 @@ init_lock_keys()
166 } 166 }
167 XFreeModifiermap(modmap); 167 XFreeModifiermap(modmap);
168 168
169 kmask = 255 & ~(numlock_mask | LockMask); 169 lock_mask = 255 & ~(numlock_mask | LockMask);
170} 170}
171 171
172static void 172static void
@@ -187,6 +187,7 @@ main(int argc, char *argv[])
187 XSetWindowAttributes wa; 187 XSetWindowAttributes wa;
188 unsigned int mask; 188 unsigned int mask;
189 Window w; 189 Window w;
190 XEvent ev;
190 191
191 /* command line args */ 192 /* command line args */
192 for(i = 1; (i < argc) && (argv[i][0] == '-'); i++) { 193 for(i = 1; (i < argc) && (argv[i][0] == '-'); i++) {
@@ -218,6 +219,9 @@ main(int argc, char *argv[])
218 if(other_wm_running) 219 if(other_wm_running)
219 error("gridwm: another window manager is already running\n"); 220 error("gridwm: another window manager is already running\n");
220 221
222 if(!(shell = getenv("SHELL")))
223 shell = "/bin/sh";
224
221 rect.x = rect.y = 0; 225 rect.x = rect.y = 0;
222 rect.width = DisplayWidth(dpy, screen); 226 rect.width = DisplayWidth(dpy, screen);
223 rect.height = DisplayHeight(dpy, screen); 227 rect.height = DisplayHeight(dpy, screen);
@@ -244,19 +248,42 @@ main(int argc, char *argv[])
244 248
245 init_lock_keys(); 249 init_lock_keys();
246 250
247 pmap = XCreatePixmap(dpy, root, rect.width, rect.height, 251 brush.drawable = XCreatePixmap(dpy, root, rect.width, rect.height,
248 DefaultDepth(dpy, screen)); 252 DefaultDepth(dpy, screen));
249 253 brush.gc = XCreateGC(dpy, root, 0, 0);
250 wa.event_mask = SubstructureRedirectMask | EnterWindowMask | LeaveWindowMask;
251 wa.cursor = cursor[CurNormal];
252 XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
253 254
254 /* style */ 255 /* style */
255 loadcolors(dpy, screen, &brush, BGCOLOR, FGCOLOR, BORDERCOLOR); 256 loadcolors(dpy, screen, &brush, BGCOLOR, FGCOLOR, BORDERCOLOR);
256 loadfont(dpy, &brush.font, FONT); 257 loadfont(dpy, &brush.font, FONT);
257 258
259 wa.override_redirect = 1;
260 wa.background_pixmap = ParentRelative;
261 wa.event_mask = ExposureMask;
262
263 barrect = rect;
264 barrect.height = labelheight(&brush.font);
265 barrect.y = rect.height - barrect.height;
266 barwin = XCreateWindow(dpy, root, barrect.x, barrect.y,
267 barrect.width, barrect.height, 0, DefaultDepth(dpy, screen),
268 CopyFromParent, DefaultVisual(dpy, screen),
269 CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
270 bartext = 0;
271 XDefineCursor(dpy, barwin, cursor[CurNormal]);
272 XMapRaised(dpy, barwin);
273 draw_bar();
274
275 wa.event_mask = SubstructureRedirectMask | EnterWindowMask | LeaveWindowMask;
276 wa.cursor = cursor[CurNormal];
277 XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
278
258 scan_wins(); 279 scan_wins();
259 280
281 while(running) {
282 XNextEvent(dpy, &ev);
283 if(handler[ev.type])
284 (handler[ev.type]) (&ev); /* call handler */
285 }
286
260 cleanup(); 287 cleanup();
261 XCloseDisplay(dpy); 288 XCloseDisplay(dpy);
262 289
diff --git a/wm.h b/wm.h
index 6bf0d5e..038078f 100644
--- a/wm.h
+++ b/wm.h
@@ -9,16 +9,14 @@
9 9
10#include <X11/Xutil.h> 10#include <X11/Xutil.h>
11 11
12/* WM atoms */ 12/* atoms */
13enum { WMState, WMProtocols, WMDelete, WMLast }; 13enum { WMState, WMProtocols, WMDelete, WMLast };
14
15/* NET atoms */
16enum { NetSupported, NetWMName, NetLast }; 14enum { NetSupported, NetWMName, NetLast };
17 15
18/* Cursor */ 16/* cursor */
19enum { CurNormal, CurResize, CurMove, CurInput, CurLast }; 17enum { CurNormal, CurResize, CurMove, CurInput, CurLast };
20 18
21/* Rects */ 19/* rects */
22enum { RFloat, RGrid, RLast }; 20enum { RFloat, RGrid, RLast };
23 21
24typedef struct Client Client; 22typedef struct Client Client;
@@ -28,35 +26,45 @@ struct Client {
28 Tag *tag; 26 Tag *tag;
29 char name[256]; 27 char name[256];
30 int proto; 28 int proto;
29 unsigned int border;
30 Bool fixedsize;
31 Window win; 31 Window win;
32 Window trans; 32 Window trans;
33 Window title; 33 Window title;
34 GC gc;
35 XSizeHints size; 34 XSizeHints size;
36 XRectangle r[RLast]; 35 XRectangle r[RLast];
37 Client *next; 36 Client *next;
38 Client *tnext; 37 Client *snext;
39 Client *tprev;
40}; 38};
41 39
42struct Tag { 40struct Tag {
43 char name[256]; 41 char name[256];
44 Client *clients; 42 Client *stack;
45 Client *sel;
46 XRectangle r; 43 XRectangle r;
44 Tag *next;
45 Tag *cnext;
47}; 46};
48 47
49extern Display *dpy; 48extern Display *dpy;
50extern Window root; 49extern Window root, barwin;
51extern XRectangle rect; 50extern Atom wm_atom[WMLast], net_atom[NetLast];
52extern Atom wm_atom[WMLast];
53extern Atom net_atom[NetLast];
54extern Cursor cursor[CurLast]; 51extern Cursor cursor[CurLast];
55extern Pixmap pmap; 52extern XRectangle rect, barrect;
53extern Bool running;
54extern void (*handler[LASTEvent]) (XEvent *);
56 55
57extern int screen, sel_screen; 56extern int screen, sel_screen;
58extern unsigned int kmask, numlock_mask; 57extern unsigned int lock_mask, numlock_mask;
58extern char *bartext, *shell;
59 59
60extern Brush brush; 60extern Brush brush;
61 61
62/* bar.c */
63extern void draw_bar();
64
65/* client.c */
66extern Client *create_client(Window w, XWindowAttributes *wa);
67extern void manage(Client *c);
68
62/* wm.c */ 69/* wm.c */
70extern int win_proto(Window w);