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