JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
refactored Sanders code somewhat
[dwm.git] / dwm.h
1 /*
2  * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3  * See LICENSE file for license details.
4  */
5
6 #include <X11/Xlib.h>
7
8 /********** CUSTOMIZE **********/
9
10 #define FONT                            "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*"
11 #define BGCOLOR                         "#0a2c2d"
12 #define FGCOLOR                         "#ddeeee"
13 #define BORDERCOLOR                     "#176164"
14 /*
15 #define BGCOLOR                         "#666699"
16 #define FGCOLOR                         "#eeeeee"
17 #define BORDERCOLOR                     "#9999CC"
18 */
19 #define MASTERW                         52 /* percent */
20 #define WM_PROTOCOL_DELWIN      1
21
22 /* tags */
23 enum { Tscratch, Tdev, Twww, Twork, TLast };
24
25 /********** CUSTOMIZE **********/
26
27 typedef union Arg Arg;
28 typedef struct Client Client;
29 typedef enum Corner Corner;
30 typedef struct DC DC;
31 typedef struct Fnt Fnt;
32 typedef struct Key Key;
33 typedef struct Rule Rule;
34
35 union Arg {
36         const char **argv;
37         int i;
38 };
39
40 /* atoms */
41 enum { NetSupported, NetWMName, NetLast };
42 enum { WMProtocols, WMDelete, WMLast };
43
44 /* cursor */
45 enum { CurNormal, CurResize, CurMove, CurLast };
46
47 enum Corner { TopLeft, TopRight, BotLeft, BotRight };
48
49 struct Fnt {
50         int ascent;
51         int descent;
52         int height;
53         XFontSet set;
54         XFontStruct *xfont;
55 };
56
57 struct DC { /* draw context */
58         int x, y, w, h;
59         unsigned long bg;
60         unsigned long fg;
61         unsigned long border;
62         Drawable drawable;
63         Fnt font;
64         GC gc;
65 };
66
67 struct Client {
68         char name[256];
69         char *tags[TLast];
70         int proto;
71         int *x, *y, *w, *h; /* current geom */
72         int bx, by, bw, bh; /* title bar */
73         int fx, fy, fw, fh; /* floating geom */
74         int tx, ty, tw, th; /* tiled geom */
75         int basew, baseh, incw, inch, maxw, maxh, minw, minh;
76         int grav;
77         unsigned int border;
78         long flags; 
79         Bool isfloat;
80         Client *next;
81         Client *revert;
82         Window win;
83         Window title;
84 };
85
86 struct Rule {
87         const char *class;
88         const char *instance;
89         char *tags[TLast];
90         Bool isfloat;
91 };
92
93 struct Key {
94         unsigned long mod;
95         KeySym keysym;
96         void (*func)(Arg *arg);
97         Arg arg;
98 };
99
100 extern char *tags[TLast], stext[1024];
101 extern int tsel, screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
102 extern void (*handler[LASTEvent])(XEvent *);
103 extern void (*arrange)(Arg *);
104 extern Atom wmatom[WMLast], netatom[NetLast];
105 extern Bool running, issel;
106 extern Client *clients, *sel;
107 extern Cursor cursor[CurLast];
108 extern DC dc;
109 extern Display *dpy;
110 extern Key key[];
111 extern Window root, barwin;
112
113 /* client.c */
114 extern void ban(Client *c);
115 extern void focus(Client *c);
116 extern void focusnext(Arg *arg);
117 extern void focusprev(Arg *arg);
118 extern Client *getclient(Window w);
119 extern Client *getctitle(Window w);
120 extern void gravitate(Client *c, Bool invert);
121 extern void higher(Client *c);
122 extern void killclient(Arg *arg);
123 extern void lower(Client *c);
124 extern void manage(Window w, XWindowAttributes *wa);
125 extern void maximize(Arg *arg);
126 extern void pop(Client *c);
127 extern void resize(Client *c, Bool inc, Corner sticky);
128 extern void setgeom(Client *c);
129 extern void setsize(Client *c);
130 extern void settitle(Client *c);
131 extern void unmanage(Client *c);
132 extern void zoom(Arg *arg);
133
134 /* draw.c */
135 extern void drawall();
136 extern void drawstatus();
137 extern void drawtitle(Client *c);
138 extern unsigned long getcolor(const char *colstr);
139 extern void setfont(const char *fontstr);
140 extern unsigned int textw(char *text);
141
142 /* event.c */
143 extern void grabkeys();
144
145 /* main.c */
146 extern int getproto(Window w);
147 extern void quit(Arg *arg);
148 extern void sendevent(Window w, Atom a, long value);
149 extern int xerror(Display *dsply, XErrorEvent *ee);
150
151 /* tag.c */
152 extern void appendtag(Arg *arg);
153 extern void dofloat(Arg *arg);
154 extern void dotile(Arg *arg);
155 extern Client *getnext(Client *c, unsigned int t);
156 extern void heretag(Arg *arg);
157 extern void replacetag(Arg *arg);
158 extern void settags(Client *c);
159 extern void view(Arg *arg);
160
161 /* util.c */
162 extern void *emallocz(unsigned int size);
163 extern void eprint(const char *errstr, ...);
164 extern void spawn(Arg *arg);