dwm.h (view raw)
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};
191