cleaned up dwm.c/dwm.h somewhat that it allows easier integration of patches 5a04edec
Anselm R. Garbe · 2007-10-16 19:04 2 file(s) · +115 −115
dwm.c +1 −115
49 49
#define CLEANMASK(mask)		(mask & ~(numlockmask | LockMask))
50 50
#define MOUSEMASK		(BUTTONMASK | PointerMotionMask)
51 51
52 -
/* enums */
53 -
enum { BarTop, BarBot, BarOff };			/* bar position */
54 -
enum { CurNormal, CurResize, CurMove, CurLast };	/* cursor */
55 -
enum { ColBorder, ColFG, ColBG, ColLast };		/* color */
56 -
enum { NetSupported, NetWMName, NetLast };		/* EWMH atoms */
57 -
enum { WMProtocols, WMDelete, WMName, WMState, WMLast };/* default atoms */
58 -
59 -
/* typedefs */
60 -
typedef struct {
61 -
	int x, y, w, h;
62 -
	unsigned long norm[ColLast];
63 -
	unsigned long sel[ColLast];
64 -
	Drawable drawable;
65 -
	GC gc;
66 -
	struct {
67 -
		int ascent;
68 -
		int descent;
69 -
		int height;
70 -
		XFontSet set;
71 -
		XFontStruct *xfont;
72 -
	} font;
73 -
} DC; /* draw context */
74 -
75 -
typedef struct {
76 -
	unsigned long mod;
77 -
	KeySym keysym;
78 -
	void (*func)(const char *arg);
79 -
	const char *arg;
80 -
} Key;
81 -
82 -
typedef struct {
83 -
	const char *symbol;
84 -
	void (*arrange)(void);
85 -
} Layout;
86 -
52 +
/* local typedefs */
87 53
typedef struct {
88 54
	const char *prop;
89 55
	const char *tags;
94 60
	regex_t *propregex;
95 61
	regex_t *tagregex;
96 62
} Regs;
97 -
98 -
/* forward declarations */
99 -
void applyrules(Client *c);
100 -
void arrange(void);
101 -
void attach(Client *c);
102 -
void attachstack(Client *c);
103 -
void ban(Client *c);
104 -
void buttonpress(XEvent *e);
105 -
void checkotherwm(void);
106 -
void cleanup(void);
107 -
void compileregs(void);
108 -
void configure(Client *c);
109 -
void configurenotify(XEvent *e);
110 -
void configurerequest(XEvent *e);
111 -
void destroynotify(XEvent *e);
112 -
void detach(Client *c);
113 -
void detachstack(Client *c);
114 -
void drawbar(void);
115 -
void drawsquare(Bool filled, Bool empty, unsigned long col[ColLast]);
116 -
void drawtext(const char *text, unsigned long col[ColLast]);
117 -
void *emallocz(unsigned int size);
118 -
void enternotify(XEvent *e);
119 -
void eprint(const char *errstr, ...);
120 -
void expose(XEvent *e);
121 -
void floating(void); /* default floating layout */
122 -
void focus(Client *c);
123 -
void focusnext(const char *arg);
124 -
void focusprev(const char *arg);
125 -
Client *getclient(Window w);
126 -
unsigned long getcolor(const char *colstr);
127 -
long getstate(Window w);
128 -
Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
129 -
void grabbuttons(Client *c, Bool focused);
130 -
unsigned int idxoftag(const char *tag);
131 -
void initfont(const char *fontstr);
132 -
Bool isarrange(void (*func)());
133 -
Bool isoccupied(unsigned int t);
134 -
Bool isprotodel(Client *c);
135 -
Bool isvisible(Client *c);
136 -
void keypress(XEvent *e);
137 -
void killclient(const char *arg);
138 -
void leavenotify(XEvent *e);
139 -
void manage(Window w, XWindowAttributes *wa);
140 -
void mappingnotify(XEvent *e);
141 -
void maprequest(XEvent *e);
142 -
void movemouse(Client *c);
143 -
Client *nexttiled(Client *c);
144 -
void propertynotify(XEvent *e);
145 -
void quit(const char *arg);
146 -
void resize(Client *c, int x, int y, int w, int h, Bool sizehints);
147 -
void resizemouse(Client *c);
148 -
void restack(void);
149 -
void run(void);
150 -
void scan(void);
151 -
void setclientstate(Client *c, long state);
152 -
void setlayout(const char *arg);
153 -
void setmwfact(const char *arg);
154 -
void setup(void);
155 -
void spawn(const char *arg);
156 -
void tag(const char *arg);
157 -
unsigned int textnw(const char *text, unsigned int len);
158 -
unsigned int textw(const char *text);
159 -
void tile(void);
160 -
void togglebar(const char *arg);
161 -
void togglefloating(const char *arg);
162 -
void togglemax(const char *arg);
163 -
void toggletag(const char *arg);
164 -
void toggleview(const char *arg);
165 -
void unban(Client *c);
166 -
void unmanage(Client *c);
167 -
void unmapnotify(XEvent *e);
168 -
void updatebarpos(void);
169 -
void updatesizehints(Client *c);
170 -
void updatetitle(Client *c);
171 -
void view(const char *arg);
172 -
void viewprevtag(const char *arg);	/* views previous selected tags */
173 -
int xerror(Display *dpy, XErrorEvent *ee);
174 -
int xerrordummy(Display *dsply, XErrorEvent *ee);
175 -
int xerrorstart(Display *dsply, XErrorEvent *ee);
176 -
void zoom(const char *arg);
177 63
178 64
/* variables */
179 65
char stext[256];
dwm.h +114 −0
1 1
/* See LICENSE file for copyright and license details. */
2 2
#include <X11/Xlib.h>
3 3
4 +
/* enums */
5 +
enum { BarTop, BarBot, BarOff };			/* bar position */
6 +
enum { CurNormal, CurResize, CurMove, CurLast };	/* cursor */
7 +
enum { ColBorder, ColFG, ColBG, ColLast };		/* color */
8 +
enum { NetSupported, NetWMName, NetLast };		/* EWMH atoms */
9 +
enum { WMProtocols, WMDelete, WMName, WMState, WMLast };/* default atoms */
10 +
4 11
/* typedefs */
5 12
typedef struct Client Client;
6 13
struct Client {
18 25
	Client *snext;
19 26
	Window win;
20 27
};
28 +
29 +
typedef struct {
30 +
	int x, y, w, h;
31 +
	unsigned long norm[ColLast];
32 +
	unsigned long sel[ColLast];
33 +
	Drawable drawable;
34 +
	GC gc;
35 +
	struct {
36 +
		int ascent;
37 +
		int descent;
38 +
		int height;
39 +
		XFontSet set;
40 +
		XFontStruct *xfont;
41 +
	} font;
42 +
} DC; /* draw context */
43 +
44 +
typedef struct {
45 +
	unsigned long mod;
46 +
	KeySym keysym;
47 +
	void (*func)(const char *arg);
48 +
	const char *arg;
49 +
} Key;
50 +
51 +
typedef struct {
52 +
	const char *symbol;
53 +
	void (*arrange)(void);
54 +
} Layout;
55 +
56 +
/* functions */
57 +
void applyrules(Client *c);
58 +
void arrange(void);
59 +
void attach(Client *c);
60 +
void attachstack(Client *c);
61 +
void ban(Client *c);
62 +
void buttonpress(XEvent *e);
63 +
void checkotherwm(void);
64 +
void cleanup(void);
65 +
void compileregs(void);
66 +
void configure(Client *c);
67 +
void configurenotify(XEvent *e);
68 +
void configurerequest(XEvent *e);
69 +
void destroynotify(XEvent *e);
70 +
void detach(Client *c);
71 +
void detachstack(Client *c);
72 +
void drawbar(void);
73 +
void drawsquare(Bool filled, Bool empty, unsigned long col[ColLast]);
74 +
void drawtext(const char *text, unsigned long col[ColLast]);
75 +
void *emallocz(unsigned int size);
76 +
void enternotify(XEvent *e);
77 +
void eprint(const char *errstr, ...);
78 +
void expose(XEvent *e);
79 +
void floating(void); /* default floating layout */
80 +
void focus(Client *c);
81 +
void focusnext(const char *arg);
82 +
void focusprev(const char *arg);
83 +
Client *getclient(Window w);
84 +
unsigned long getcolor(const char *colstr);
85 +
long getstate(Window w);
86 +
Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
87 +
void grabbuttons(Client *c, Bool focused);
88 +
unsigned int idxoftag(const char *tag);
89 +
void initfont(const char *fontstr);
90 +
Bool isarrange(void (*func)());
91 +
Bool isoccupied(unsigned int t);
92 +
Bool isprotodel(Client *c);
93 +
Bool isvisible(Client *c);
94 +
void keypress(XEvent *e);
95 +
void killclient(const char *arg);
96 +
void leavenotify(XEvent *e);
97 +
void manage(Window w, XWindowAttributes *wa);
98 +
void mappingnotify(XEvent *e);
99 +
void maprequest(XEvent *e);
100 +
void movemouse(Client *c);
101 +
Client *nexttiled(Client *c);
102 +
void propertynotify(XEvent *e);
103 +
void quit(const char *arg);
104 +
void resize(Client *c, int x, int y, int w, int h, Bool sizehints);
105 +
void resizemouse(Client *c);
106 +
void restack(void);
107 +
void run(void);
108 +
void scan(void);
109 +
void setclientstate(Client *c, long state);
110 +
void setlayout(const char *arg);
111 +
void setmwfact(const char *arg);
112 +
void setup(void);
113 +
void spawn(const char *arg);
114 +
void tag(const char *arg);
115 +
unsigned int textnw(const char *text, unsigned int len);
116 +
unsigned int textw(const char *text);
117 +
void tile(void);
118 +
void togglebar(const char *arg);
119 +
void togglefloating(const char *arg);
120 +
void togglemax(const char *arg);
121 +
void toggletag(const char *arg);
122 +
void toggleview(const char *arg);
123 +
void unban(Client *c);
124 +
void unmanage(Client *c);
125 +
void unmapnotify(XEvent *e);
126 +
void updatebarpos(void);
127 +
void updatesizehints(Client *c);
128 +
void updatetitle(Client *c);
129 +
void view(const char *arg);
130 +
void viewprevtag(const char *arg);	/* views previous selected tags */
131 +
int xerror(Display *dpy, XErrorEvent *ee);
132 +
int xerrordummy(Display *dsply, XErrorEvent *ee);
133 +
int xerrorstart(Display *dsply, XErrorEvent *ee);
134 +
void zoom(const char *arg);