summaryrefslogtreecommitdiffstats
path: root/dwm.c
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 /dwm.c
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--dwm.c190
1 files changed, 188 insertions, 2 deletions
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];