removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities cd7ebaad
arg@suckless.org · 2007-10-18 10:28 3 file(s) · +190 −194
Makefile +2 −2
3 3
4 4
include config.mk
5 5
6 -
SRC += dwm.c
6 +
SRC = dwm.c
7 7
OBJ = ${SRC:.c=.o}
8 8
9 9
all: options dwm
35 35
dist: clean
36 36
	@echo creating dist tarball
37 37
	@mkdir -p dwm-${VERSION}
38 -
	@cp -R LICENSE Makefile README config.def.h config.mk dwm.h \
38 +
	@cp -R LICENSE Makefile README config.def.h config.mk \
39 39
		dwm.1 ${SRC} dwm-${VERSION}
40 40
	@tar -cf dwm-${VERSION}.tar dwm-${VERSION}
41 41
	@gzip dwm-${VERSION}.tar
dwm.c +188 −2
43 43
#include <X11/Xproto.h>
44 44
#include <X11/Xutil.h>
45 45
46 -
#include "dwm.h"
47 -
48 46
/* macros */
49 47
#define BUTTONMASK		(ButtonPressMask | ButtonReleaseMask)
50 48
#define CLEANMASK(mask)		(mask & ~(numlockmask | LockMask))
51 49
#define MOUSEMASK		(BUTTONMASK | PointerMotionMask)
52 50
51 +
/* enums */
52 +
enum { BarTop, BarBot, BarOff };			/* bar position */
53 +
enum { CurNormal, CurResize, CurMove, CurLast };	/* cursor */
54 +
enum { ColBorder, ColFG, ColBG, ColLast };		/* color */
55 +
enum { NetSupported, NetWMName, NetLast };		/* EWMH atoms */
56 +
enum { WMProtocols, WMDelete, WMName, WMState, WMLast };/* default atoms */
57 +
58 +
/* typedefs */
59 +
typedef struct Client Client;
60 +
struct Client {
61 +
	char name[256];
62 +
	int x, y, w, h;
63 +
	int rx, ry, rw, rh; /* revert geometry */
64 +
	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
65 +
	int minax, maxax, minay, maxay;
66 +
	long flags;
67 +
	unsigned int border, oldborder;
68 +
	Bool isbanned, isfixed, ismax, isfloating, wasfloating;
69 +
	Bool *tags;
70 +
	Client *next;
71 +
	Client *prev;
72 +
	Client *snext;
73 +
	Window win;
74 +
};
75 +
76 +
typedef struct {
77 +
	int x, y, w, h;
78 +
	unsigned long norm[ColLast];
79 +
	unsigned long sel[ColLast];
80 +
	Drawable drawable;
81 +
	GC gc;
82 +
	struct {
83 +
		int ascent;
84 +
		int descent;
85 +
		int height;
86 +
		XFontSet set;
87 +
		XFontStruct *xfont;
88 +
	} font;
89 +
} DC; /* draw context */
90 +
91 +
typedef struct {
92 +
	unsigned long mod;
93 +
	KeySym keysym;
94 +
	void (*func)(const char *arg);
95 +
	const char *arg;
96 +
} Key;
97 +
98 +
typedef struct {
99 +
	const char *symbol;
100 +
	void (*arrange)(void);
101 +
} Layout;
102 +
103 +
typedef struct {
104 +
	const char *prop;
105 +
	const char *tags;
106 +
	Bool isfloating;
107 +
} Rule;
108 +
109 +
typedef struct {
110 +
	regex_t *propregex;
111 +
	regex_t *tagregex;
112 +
} Regs;
113 +
114 +
/* functions */
115 +
void applyrules(Client *c);
116 +
void arrange(void);
117 +
void attach(Client *c);
118 +
void attachstack(Client *c);
119 +
void ban(Client *c);
120 +
void buttonpress(XEvent *e);
121 +
void checkotherwm(void);
122 +
void cleanup(void);
123 +
void compileregs(void);
124 +
void configure(Client *c);
125 +
void configurenotify(XEvent *e);
126 +
void configurerequest(XEvent *e);
127 +
void destroynotify(XEvent *e);
128 +
void detach(Client *c);
129 +
void detachstack(Client *c);
130 +
void drawbar(void);
131 +
void drawsquare(Bool filled, Bool empty, unsigned long col[ColLast]);
132 +
void drawtext(const char *text, unsigned long col[ColLast]);
133 +
void *emallocz(unsigned int size);
134 +
void enternotify(XEvent *e);
135 +
void eprint(const char *errstr, ...);
136 +
void expose(XEvent *e);
137 +
void floating(void); /* default floating layout */
138 +
void focus(Client *c);
139 +
void focusnext(const char *arg);
140 +
void focusprev(const char *arg);
141 +
Client *getclient(Window w);
142 +
unsigned long getcolor(const char *colstr);
143 +
long getstate(Window w);
144 +
Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
145 +
void grabbuttons(Client *c, Bool focused);
146 +
unsigned int idxoftag(const char *tag);
147 +
void initfont(const char *fontstr);
148 +
Bool isarrange(void (*func)());
149 +
Bool isoccupied(unsigned int t);
150 +
Bool isprotodel(Client *c);
151 +
Bool isvisible(Client *c);
152 +
void keypress(XEvent *e);
153 +
void killclient(const char *arg);
154 +
void leavenotify(XEvent *e);
155 +
void manage(Window w, XWindowAttributes *wa);
156 +
void mappingnotify(XEvent *e);
157 +
void maprequest(XEvent *e);
158 +
void movemouse(Client *c);
159 +
Client *nexttiled(Client *c);
160 +
void propertynotify(XEvent *e);
161 +
void quit(const char *arg);
162 +
void resize(Client *c, int x, int y, int w, int h, Bool sizehints);
163 +
void resizemouse(Client *c);
164 +
void restack(void);
165 +
void run(void);
166 +
void scan(void);
167 +
void setclientstate(Client *c, long state);
168 +
void setlayout(const char *arg);
169 +
void setmwfact(const char *arg);
170 +
void setup(void);
171 +
void spawn(const char *arg);
172 +
void tag(const char *arg);
173 +
unsigned int textnw(const char *text, unsigned int len);
174 +
unsigned int textw(const char *text);
175 +
void tile(void);
176 +
void togglebar(const char *arg);
177 +
void togglefloating(const char *arg);
178 +
void togglemax(const char *arg);
179 +
void toggletag(const char *arg);
180 +
void toggleview(const char *arg);
181 +
void unban(Client *c);
182 +
void unmanage(Client *c);
183 +
void unmapnotify(XEvent *e);
184 +
void updatebarpos(void);
185 +
void updatesizehints(Client *c);
186 +
void updatetitle(Client *c);
187 +
void view(const char *arg);
188 +
void viewprevtag(const char *arg);	/* views previous selected tags */
189 +
int xerror(Display *dpy, XErrorEvent *ee);
190 +
int xerrordummy(Display *dsply, XErrorEvent *ee);
191 +
int xerrorstart(Display *dsply, XErrorEvent *ee);
192 +
void zoom(const char *arg);
193 +
194 +
/* variables */
195 +
char stext[256];
196 +
double mwfact;
197 +
int screen, sx, sy, sw, sh, wax, way, waw, wah;
198 +
int (*xerrorxlib)(Display *, XErrorEvent *);
199 +
unsigned int bh, bpos;
200 +
unsigned int blw = 0;
201 +
unsigned int ltidx = 0; /* default */
202 +
unsigned int nlayouts = 0;
203 +
unsigned int nrules = 0;
204 +
unsigned int numlockmask = 0;
205 +
void (*handler[LASTEvent]) (XEvent *) = {
206 +
	[ButtonPress] = buttonpress,
207 +
	[ConfigureRequest] = configurerequest,
208 +
	[ConfigureNotify] = configurenotify,
209 +
	[DestroyNotify] = destroynotify,
210 +
	[EnterNotify] = enternotify,
211 +
	[LeaveNotify] = leavenotify,
212 +
	[Expose] = expose,
213 +
	[KeyPress] = keypress,
214 +
	[MappingNotify] = mappingnotify,
215 +
	[MapRequest] = maprequest,
216 +
	[PropertyNotify] = propertynotify,
217 +
	[UnmapNotify] = unmapnotify
218 +
};
219 +
Atom wmatom[WMLast], netatom[NetLast];
220 +
Bool otherwm, readin;
221 +
Bool running = True;
222 +
Bool selscreen = True;
223 +
Client *clients = NULL;
224 +
Client *sel = NULL;
225 +
Client *stack = NULL;
226 +
Cursor cursor[CurLast];
227 +
Display *dpy;
228 +
DC dc = {0};
229 +
Window barwin, root;
230 +
Regs *regs = NULL;
231 +
232 +
/* configuration, allows nested code to access above variables */
233 +
#include "config.h"
234 +
235 +
/* statically define the number of tags. */
236 +
unsigned int ntags = sizeof tags / sizeof tags[0];
237 +
Bool seltags[sizeof tags / sizeof tags[0]] = {[0] = True};
238 +
Bool prevtags[sizeof tags / sizeof tags[0]] = {[0] = True};
53 239
void
54 240
applyrules(Client *c) {
55 241
	static char buf[512];
dwm.h (deleted) +0 −190
1 -
/* See LICENSE file for copyright and license details. */
2 -
3 -
/* enums */
4 -
enum { BarTop, BarBot, BarOff };			/* bar position */
5 -
enum { CurNormal, CurResize, CurMove, CurLast };	/* cursor */
6 -
enum { ColBorder, ColFG, ColBG, ColLast };		/* color */
7 -
enum { NetSupported, NetWMName, NetLast };		/* EWMH atoms */
8 -
enum { WMProtocols, WMDelete, WMName, WMState, WMLast };/* default atoms */
9 -
10 -
/* typedefs */
11 -
typedef struct Client Client;
12 -
struct Client {
13 -
	char name[256];
14 -
	int x, y, w, h;
15 -
	int rx, ry, rw, rh; /* revert geometry */
16 -
	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
17 -
	int minax, maxax, minay, maxay;
18 -
	long flags;
19 -
	unsigned int border, oldborder;
20 -
	Bool isbanned, isfixed, ismax, isfloating, wasfloating;
21 -
	Bool *tags;
22 -
	Client *next;
23 -
	Client *prev;
24 -
	Client *snext;
25 -
	Window win;
26 -
};
27 -
28 -
typedef struct {
29 -
	int x, y, w, h;
30 -
	unsigned long norm[ColLast];
31 -
	unsigned long sel[ColLast];
32 -
	Drawable drawable;
33 -
	GC gc;
34 -
	struct {
35 -
		int ascent;
36 -
		int descent;
37 -
		int height;
38 -
		XFontSet set;
39 -
		XFontStruct *xfont;
40 -
	} font;
41 -
} DC; /* draw context */
42 -
43 -
typedef struct {
44 -
	unsigned long mod;
45 -
	KeySym keysym;
46 -
	void (*func)(const char *arg);
47 -
	const char *arg;
48 -
} Key;
49 -
50 -
typedef struct {
51 -
	const char *symbol;
52 -
	void (*arrange)(void);
53 -
} Layout;
54 -
55 -
typedef struct {
56 -
	const char *prop;
57 -
	const char *tags;
58 -
	Bool isfloating;
59 -
} Rule;
60 -
61 -
typedef struct {
62 -
	regex_t *propregex;
63 -
	regex_t *tagregex;
64 -
} Regs;
65 -
66 -
/* functions */
67 -
void applyrules(Client *c);
68 -
void arrange(void);
69 -
void attach(Client *c);
70 -
void attachstack(Client *c);
71 -
void ban(Client *c);
72 -
void buttonpress(XEvent *e);
73 -
void checkotherwm(void);
74 -
void cleanup(void);
75 -
void compileregs(void);
76 -
void configure(Client *c);
77 -
void configurenotify(XEvent *e);
78 -
void configurerequest(XEvent *e);
79 -
void destroynotify(XEvent *e);
80 -
void detach(Client *c);
81 -
void detachstack(Client *c);
82 -
void drawbar(void);
83 -
void drawsquare(Bool filled, Bool empty, unsigned long col[ColLast]);
84 -
void drawtext(const char *text, unsigned long col[ColLast]);
85 -
void *emallocz(unsigned int size);
86 -
void enternotify(XEvent *e);
87 -
void eprint(const char *errstr, ...);
88 -
void expose(XEvent *e);
89 -
void floating(void); /* default floating layout */
90 -
void focus(Client *c);
91 -
void focusnext(const char *arg);
92 -
void focusprev(const char *arg);
93 -
Client *getclient(Window w);
94 -
unsigned long getcolor(const char *colstr);
95 -
long getstate(Window w);
96 -
Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
97 -
void grabbuttons(Client *c, Bool focused);
98 -
unsigned int idxoftag(const char *tag);
99 -
void initfont(const char *fontstr);
100 -
Bool isarrange(void (*func)());
101 -
Bool isoccupied(unsigned int t);
102 -
Bool isprotodel(Client *c);
103 -
Bool isvisible(Client *c);
104 -
void keypress(XEvent *e);
105 -
void killclient(const char *arg);
106 -
void leavenotify(XEvent *e);
107 -
void manage(Window w, XWindowAttributes *wa);
108 -
void mappingnotify(XEvent *e);
109 -
void maprequest(XEvent *e);
110 -
void movemouse(Client *c);
111 -
Client *nexttiled(Client *c);
112 -
void propertynotify(XEvent *e);
113 -
void quit(const char *arg);
114 -
void resize(Client *c, int x, int y, int w, int h, Bool sizehints);
115 -
void resizemouse(Client *c);
116 -
void restack(void);
117 -
void run(void);
118 -
void scan(void);
119 -
void setclientstate(Client *c, long state);
120 -
void setlayout(const char *arg);
121 -
void setmwfact(const char *arg);
122 -
void setup(void);
123 -
void spawn(const char *arg);
124 -
void tag(const char *arg);
125 -
unsigned int textnw(const char *text, unsigned int len);
126 -
unsigned int textw(const char *text);
127 -
void tile(void);
128 -
void togglebar(const char *arg);
129 -
void togglefloating(const char *arg);
130 -
void togglemax(const char *arg);
131 -
void toggletag(const char *arg);
132 -
void toggleview(const char *arg);
133 -
void unban(Client *c);
134 -
void unmanage(Client *c);
135 -
void unmapnotify(XEvent *e);
136 -
void updatebarpos(void);
137 -
void updatesizehints(Client *c);
138 -
void updatetitle(Client *c);
139 -
void view(const char *arg);
140 -
void viewprevtag(const char *arg);	/* views previous selected tags */
141 -
int xerror(Display *dpy, XErrorEvent *ee);
142 -
int xerrordummy(Display *dsply, XErrorEvent *ee);
143 -
int xerrorstart(Display *dsply, XErrorEvent *ee);
144 -
void zoom(const char *arg);
145 -
146 -
/* variables */
147 -
char stext[256];
148 -
double mwfact;
149 -
int screen, sx, sy, sw, sh, wax, way, waw, wah;
150 -
int (*xerrorxlib)(Display *, XErrorEvent *);
151 -
unsigned int bh, bpos;
152 -
unsigned int blw = 0;
153 -
unsigned int ltidx = 0; /* default */
154 -
unsigned int nlayouts = 0;
155 -
unsigned int nrules = 0;
156 -
unsigned int numlockmask = 0;
157 -
void (*handler[LASTEvent]) (XEvent *) = {
158 -
	[ButtonPress] = buttonpress,
159 -
	[ConfigureRequest] = configurerequest,
160 -
	[ConfigureNotify] = configurenotify,
161 -
	[DestroyNotify] = destroynotify,
162 -
	[EnterNotify] = enternotify,
163 -
	[LeaveNotify] = leavenotify,
164 -
	[Expose] = expose,
165 -
	[KeyPress] = keypress,
166 -
	[MappingNotify] = mappingnotify,
167 -
	[MapRequest] = maprequest,
168 -
	[PropertyNotify] = propertynotify,
169 -
	[UnmapNotify] = unmapnotify
170 -
};
171 -
Atom wmatom[WMLast], netatom[NetLast];
172 -
Bool otherwm, readin;
173 -
Bool running = True;
174 -
Bool selscreen = True;
175 -
Client *clients = NULL;
176 -
Client *sel = NULL;
177 -
Client *stack = NULL;
178 -
Cursor cursor[CurLast];
179 -
Display *dpy;
180 -
DC dc = {0};
181 -
Window barwin, root;
182 -
Regs *regs = NULL;
183 -
184 -
/* configuration, allows nested code to access above variables */
185 -
#include "config.h"
186 -
187 -
/* statically define the number of tags. */
188 -
unsigned int ntags = sizeof tags / sizeof tags[0];
189 -
Bool seltags[sizeof tags / sizeof tags[0]] = {[0] = True};
190 -
Bool prevtags[sizeof tags / sizeof tags[0]] = {[0] = True};