summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarg@suckless.org <unknown>2007-10-18 10:28:41 +0200
committerarg@suckless.org <unknown>2007-10-18 10:28:41 +0200
commitcd7ebaad25fa5f10a4442f9d80a05f344ca271d3 (patch)
tree22e97b3a40c446855927b6744fbdf081d8de289d
parentsmall cosmetic fix (diff)
downloaddwm-cd7ebaad25fa5f10a4442f9d80a05f344ca271d3.tar.gz
dwm-cd7ebaad25fa5f10a4442f9d80a05f344ca271d3.zip
removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
Diffstat (limited to '')
-rw-r--r--Makefile4
-rw-r--r--dwm.c190
-rw-r--r--dwm.h190
3 files changed, 190 insertions, 194 deletions
diff --git a/Makefile b/Makefile
index 1dde4b2..7c65e6f 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@
3 3
4include config.mk 4include config.mk
5 5
6SRC += dwm.c 6SRC = dwm.c
7OBJ = ${SRC:.c=.o} 7OBJ = ${SRC:.c=.o}
8 8
9all: options dwm 9all: options dwm
@@ -35,7 +35,7 @@ clean:
35dist: clean 35dist: clean
36 @echo creating dist tarball 36 @echo creating dist tarball
37 @mkdir -p dwm-${VERSION} 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 dwm.1 ${SRC} dwm-${VERSION} 39 dwm.1 ${SRC} dwm-${VERSION}
40 @tar -cf dwm-${VERSION}.tar dwm-${VERSION} 40 @tar -cf dwm-${VERSION}.tar dwm-${VERSION}
41 @gzip dwm-${VERSION}.tar 41 @gzip dwm-${VERSION}.tar
diff --git a/dwm.c b/dwm.c
index 8f5ed6d..99920d0 100644
--- a/dwm.c
+++ b/dwm.c
@@ -43,13 +43,199 @@
43#include <X11/Xproto.h> 43#include <X11/Xproto.h>
44#include <X11/Xutil.h> 44#include <X11/Xutil.h>
45 45
46#include "dwm.h"
47
48/* macros */ 46/* macros */
49#define BUTTONMASK (ButtonPressMask | ButtonReleaseMask) 47#define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
50#define CLEANMASK(mask) (mask & ~(numlockmask | LockMask)) 48#define CLEANMASK(mask) (mask & ~(numlockmask | LockMask))
51#define MOUSEMASK (BUTTONMASK | PointerMotionMask) 49#define MOUSEMASK (BUTTONMASK | PointerMotionMask)
52 50
51/* enums */
52enum { BarTop, BarBot, BarOff }; /* bar position */
53enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
54enum { ColBorder, ColFG, ColBG, ColLast }; /* color */
55enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */
56enum { WMProtocols, WMDelete, WMName, WMState, WMLast };/* default atoms */
57
58/* typedefs */
59typedef struct Client Client;
60struct 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
76typedef 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
91typedef struct {
92 unsigned long mod;
93 KeySym keysym;
94 void (*func)(const char *arg);
95 const char *arg;
96} Key;
97
98typedef struct {
99 const char *symbol;
100 void (*arrange)(void);
101} Layout;
102
103typedef struct {
104 const char *prop;
105 const char *tags;
106 Bool isfloating;
107} Rule;
108
109typedef struct {
110 regex_t *propregex;
111 regex_t *tagregex;
112} Regs;
113
114/* functions */
115void applyrules(Client *c);
116void arrange(void);
117void attach(Client *c);
118void attachstack(Client *c);
119void ban(Client *c);
120void buttonpress(XEvent *e);
121void checkotherwm(void);
122void cleanup(void);
123void compileregs(void);
124void configure(Client *c);
125void configurenotify(XEvent *e);
126void configurerequest(XEvent *e);
127void destroynotify(XEvent *e);
128void detach(Client *c);
129void detachstack(Client *c);
130void drawbar(void);
131void drawsquare(Bool filled, Bool empty, unsigned long col[ColLast]);
132void drawtext(const char *text, unsigned long col[ColLast]);
133void *emallocz(unsigned int size);
134void enternotify(XEvent *e);
135void eprint(const char *errstr, ...);
136void expose(XEvent *e);
137void floating(void); /* default floating layout */
138void focus(Client *c);
139void focusnext(const char *arg);
140void focusprev(const char *arg);
141Client *getclient(Window w);
142unsigned long getcolor(const char *colstr);
143long getstate(Window w);
144Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
145void grabbuttons(Client *c, Bool focused);
146unsigned int idxoftag(const char *tag);
147void initfont(const char *fontstr);
148Bool isarrange(void (*func)());
149Bool isoccupied(unsigned int t);
150Bool isprotodel(Client *c);
151Bool isvisible(Client *c);
152void keypress(XEvent *e);
153void killclient(const char *arg);
154void leavenotify(XEvent *e);
155void manage(Window w, XWindowAttributes *wa);
156void mappingnotify(XEvent *e);
157void maprequest(XEvent *e);
158void movemouse(Client *c);
159Client *nexttiled(Client *c);
160void propertynotify(XEvent *e);
161void quit(const char *arg);
162void resize(Client *c, int x, int y, int w, int h, Bool sizehints);
163void resizemouse(Client *c);
164void restack(void);
165void run(void);
166void scan(void);
167void setclientstate(Client *c, long state);
168void setlayout(const char *arg);
169void setmwfact(const char *arg);
170void setup(void);
171void spawn(const char *arg);
172void tag(const char *arg);
173unsigned int textnw(const char *text, unsigned int len);
174unsigned int textw(const char *text);
175void tile(void);
176void togglebar(const char *arg);
177void togglefloating(const char *arg);
178void togglemax(const char *arg);
179void toggletag(const char *arg);
180void toggleview(const char *arg);
181void unban(Client *c);
182void unmanage(Client *c);
183void unmapnotify(XEvent *e);
184void updatebarpos(void);
185void updatesizehints(Client *c);
186void updatetitle(Client *c);
187void view(const char *arg);
188void viewprevtag(const char *arg); /* views previous selected tags */
189int xerror(Display *dpy, XErrorEvent *ee);
190int xerrordummy(Display *dsply, XErrorEvent *ee);
191int xerrorstart(Display *dsply, XErrorEvent *ee);
192void zoom(const char *arg);
193
194/* variables */
195char stext[256];
196double mwfact;
197int screen, sx, sy, sw, sh, wax, way, waw, wah;
198int (*xerrorxlib)(Display *, XErrorEvent *);
199unsigned int bh, bpos;
200unsigned int blw = 0;
201unsigned int ltidx = 0; /* default */
202unsigned int nlayouts = 0;
203unsigned int nrules = 0;
204unsigned int numlockmask = 0;
205void (*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};
219Atom wmatom[WMLast], netatom[NetLast];
220Bool otherwm, readin;
221Bool running = True;
222Bool selscreen = True;
223Client *clients = NULL;
224Client *sel = NULL;
225Client *stack = NULL;
226Cursor cursor[CurLast];
227Display *dpy;
228DC dc = {0};
229Window barwin, root;
230Regs *regs = NULL;
231
232/* configuration, allows nested code to access above variables */
233#include "config.h"
234
235/* statically define the number of tags. */
236unsigned int ntags = sizeof tags / sizeof tags[0];
237Bool seltags[sizeof tags / sizeof tags[0]] = {[0] = True};
238Bool prevtags[sizeof tags / sizeof tags[0]] = {[0] = True};
53void 239void
54applyrules(Client *c) { 240applyrules(Client *c) {
55 static char buf[512]; 241 static char buf[512];
diff --git a/dwm.h b/dwm.h
deleted file mode 100644
index 94dbd8c..0000000
--- a/dwm.h
+++ /dev/null
@@ -1,190 +0,0 @@
1/* See LICENSE file for copyright and license details. */
2
3/* enums */
4enum { BarTop, BarBot, BarOff }; /* bar position */
5enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
6enum { ColBorder, ColFG, ColBG, ColLast }; /* color */
7enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */
8enum { WMProtocols, WMDelete, WMName, WMState, WMLast };/* default atoms */
9
10/* typedefs */
11typedef struct Client Client;
12struct 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
28typedef 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
43typedef struct {
44 unsigned long mod;
45 KeySym keysym;
46 void (*func)(const char *arg);
47 const char *arg;
48} Key;
49
50typedef struct {
51 const char *symbol;
52 void (*arrange)(void);
53} Layout;
54
55typedef struct {
56 const char *prop;
57 const char *tags;
58 Bool isfloating;
59} Rule;
60
61typedef struct {
62 regex_t *propregex;
63 regex_t *tagregex;
64} Regs;
65
66/* functions */
67void applyrules(Client *c);
68void arrange(void);
69void attach(Client *c);
70void attachstack(Client *c);
71void ban(Client *c);
72void buttonpress(XEvent *e);
73void checkotherwm(void);
74void cleanup(void);
75void compileregs(void);
76void configure(Client *c);
77void configurenotify(XEvent *e);
78void configurerequest(XEvent *e);
79void destroynotify(XEvent *e);
80void detach(Client *c);
81void detachstack(Client *c);
82void drawbar(void);
83void drawsquare(Bool filled, Bool empty, unsigned long col[ColLast]);
84void drawtext(const char *text, unsigned long col[ColLast]);
85void *emallocz(unsigned int size);
86void enternotify(XEvent *e);
87void eprint(const char *errstr, ...);
88void expose(XEvent *e);
89void floating(void); /* default floating layout */
90void focus(Client *c);
91void focusnext(const char *arg);
92void focusprev(const char *arg);
93Client *getclient(Window w);
94unsigned long getcolor(const char *colstr);
95long getstate(Window w);
96Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
97void grabbuttons(Client *c, Bool focused);
98unsigned int idxoftag(const char *tag);
99void initfont(const char *fontstr);
100Bool isarrange(void (*func)());
101Bool isoccupied(unsigned int t);
102Bool isprotodel(Client *c);
103Bool isvisible(Client *c);
104void keypress(XEvent *e);
105void killclient(const char *arg);
106void leavenotify(XEvent *e);
107void manage(Window w, XWindowAttributes *wa);
108void mappingnotify(XEvent *e);
109void maprequest(XEvent *e);
110void movemouse(Client *c);
111Client *nexttiled(Client *c);
112void propertynotify(XEvent *e);
113void quit(const char *arg);
114void resize(Client *c, int x, int y, int w, int h, Bool sizehints);
115void resizemouse(Client *c);
116void restack(void);
117void run(void);
118void scan(void);
119void setclientstate(Client *c, long state);
120void setlayout(const char *arg);
121void setmwfact(const char *arg);
122void setup(void);
123void spawn(const char *arg);
124void tag(const char *arg);
125unsigned int textnw(const char *text, unsigned int len);
126unsigned int textw(const char *text);
127void tile(void);
128void togglebar(const char *arg);
129void togglefloating(const char *arg);
130void togglemax(const char *arg);
131void toggletag(const char *arg);
132void toggleview(const char *arg);
133void unban(Client *c);
134void unmanage(Client *c);
135void unmapnotify(XEvent *e);
136void updatebarpos(void);
137void updatesizehints(Client *c);
138void updatetitle(Client *c);
139void view(const char *arg);
140void viewprevtag(const char *arg); /* views previous selected tags */
141int xerror(Display *dpy, XErrorEvent *ee);
142int xerrordummy(Display *dsply, XErrorEvent *ee);
143int xerrorstart(Display *dsply, XErrorEvent *ee);
144void zoom(const char *arg);
145
146/* variables */
147char stext[256];
148double mwfact;
149int screen, sx, sy, sw, sh, wax, way, waw, wah;
150int (*xerrorxlib)(Display *, XErrorEvent *);
151unsigned int bh, bpos;
152unsigned int blw = 0;
153unsigned int ltidx = 0; /* default */
154unsigned int nlayouts = 0;
155unsigned int nrules = 0;
156unsigned int numlockmask = 0;
157void (*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};
171Atom wmatom[WMLast], netatom[NetLast];
172Bool otherwm, readin;
173Bool running = True;
174Bool selscreen = True;
175Client *clients = NULL;
176Client *sel = NULL;
177Client *stack = NULL;
178Cursor cursor[CurLast];
179Display *dpy;
180DC dc = {0};
181Window barwin, root;
182Regs *regs = NULL;
183
184/* configuration, allows nested code to access above variables */
185#include "config.h"
186
187/* statically define the number of tags. */
188unsigned int ntags = sizeof tags / sizeof tags[0];
189Bool seltags[sizeof tags / sizeof tags[0]] = {[0] = True};
190Bool prevtags[sizeof tags / sizeof tags[0]] = {[0] = True};