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@32
|
10 #define FONT "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*"
|
garbeam@43
|
11 #define BGCOLOR "DarkSlateGrey"
|
garbeam@43
|
12 #define FGCOLOR "LightSteelBlue"
|
garbeam@43
|
13 #define BORDERCOLOR "SlateGray"
|
garbeam@13
|
14 #define WM_PROTOCOL_DELWIN 1
|
garbeam@13
|
15
|
garbeam@32
|
16 /* tags */
|
garbeam@32
|
17 enum { Tscratch, Tdev, Tirc, Twww, Twork, TLast };
|
garbeam@32
|
18
|
garbeam@32
|
19 /********** CUSTOMIZE **********/
|
garbeam@32
|
20
|
garbeam@34
|
21 typedef struct DC DC;
|
garbeam@18
|
22 typedef struct Client Client;
|
garbeam@32
|
23 typedef struct Fnt Fnt;
|
garbeam@18
|
24 typedef struct Key Key;
|
garbeam@49
|
25 typedef union Arg Arg;
|
garbeam@49
|
26
|
garbeam@49
|
27 union Arg {
|
garbeam@49
|
28 const char **argv;
|
garbeam@49
|
29 int i;
|
garbeam@49
|
30 };
|
garbeam@18
|
31
|
garbeam@5
|
32 /* atoms */
|
garbeam@13
|
33 enum { WMProtocols, WMDelete, WMLast };
|
garbeam@0
|
34 enum { NetSupported, NetWMName, NetLast };
|
garbeam@0
|
35
|
garbeam@5
|
36 /* cursor */
|
garbeam@0
|
37 enum { CurNormal, CurResize, CurMove, CurInput, CurLast };
|
garbeam@0
|
38
|
garbeam@32
|
39 struct Fnt {
|
garbeam@32
|
40 XFontStruct *xfont;
|
garbeam@32
|
41 XFontSet set;
|
garbeam@32
|
42 int ascent;
|
garbeam@32
|
43 int descent;
|
garbeam@32
|
44 int height;
|
garbeam@32
|
45 };
|
garbeam@32
|
46
|
garbeam@34
|
47 struct DC { /* draw context */
|
garbeam@32
|
48 GC gc;
|
garbeam@32
|
49 Drawable drawable;
|
garbeam@32
|
50 int x, y, w, h;
|
garbeam@32
|
51 Fnt font;
|
garbeam@32
|
52 unsigned long bg;
|
garbeam@32
|
53 unsigned long fg;
|
garbeam@32
|
54 unsigned long border;
|
garbeam@32
|
55 };
|
garbeam@32
|
56
|
garbeam@0
|
57 struct Client {
|
garbeam@31
|
58 char name[256];
|
garbeam@31
|
59 char *tags[TLast];
|
garbeam@13
|
60 int proto;
|
garbeam@20
|
61 int x, y, w, h;
|
garbeam@22
|
62 int tx, ty, tw, th;
|
garbeam@20
|
63 int basew, baseh, incw, inch, maxw, maxh, minw, minh;
|
garbeam@29
|
64 int grav;
|
garbeam@29
|
65 unsigned int border;
|
garbeam@20
|
66 long flags;
|
garbeam@0
|
67 Window win;
|
garbeam@0
|
68 Window trans;
|
garbeam@0
|
69 Window title;
|
garbeam@0
|
70 Client *next;
|
garbeam@50
|
71 Client *revert;
|
garbeam@0
|
72 };
|
garbeam@0
|
73
|
garbeam@8
|
74 struct Key {
|
garbeam@8
|
75 unsigned long mod;
|
garbeam@8
|
76 KeySym keysym;
|
garbeam@49
|
77 void (*func)(Arg *arg);
|
garbeam@49
|
78 Arg arg;
|
garbeam@8
|
79 };
|
garbeam@8
|
80
|
garbeam@0
|
81 extern Display *dpy;
|
garbeam@32
|
82 extern Window root;
|
garbeam@13
|
83 extern Atom wm_atom[WMLast], net_atom[NetLast];
|
garbeam@0
|
84 extern Cursor cursor[CurLast];
|
garbeam@31
|
85 extern Bool running, issel;
|
garbeam@5
|
86 extern void (*handler[LASTEvent]) (XEvent *);
|
garbeam@0
|
87
|
garbeam@32
|
88 extern int tsel, screen, sx, sy, sw, sh, th;
|
garbeam@31
|
89 extern char stext[1024], *tags[TLast];
|
garbeam@3
|
90
|
garbeam@34
|
91 extern DC dc;
|
garbeam@50
|
92 extern Client *clients, *sel;
|
garbeam@3
|
93
|
garbeam@5
|
94 /* client.c */
|
garbeam@10
|
95 extern void manage(Window w, XWindowAttributes *wa);
|
garbeam@13
|
96 extern void unmanage(Client *c);
|
garbeam@13
|
97 extern Client *getclient(Window w);
|
garbeam@13
|
98 extern void focus(Client *c);
|
garbeam@13
|
99 extern void update_name(Client *c);
|
garbeam@16
|
100 extern void draw_client(Client *c);
|
garbeam@18
|
101 extern void resize(Client *c);
|
garbeam@20
|
102 extern void update_size(Client *c);
|
garbeam@23
|
103 extern Client *gettitle(Window w);
|
garbeam@32
|
104 extern void craise(Client *c);
|
garbeam@26
|
105 extern void lower(Client *c);
|
garbeam@49
|
106 extern void ckill(Arg *arg);
|
garbeam@49
|
107 extern void nextc(Arg *arg);
|
garbeam@49
|
108 extern void prevc(Arg *arg);
|
garbeam@49
|
109 extern void max(Arg *arg);
|
garbeam@49
|
110 extern void floating(Arg *arg);
|
garbeam@49
|
111 extern void tiling(Arg *arg);
|
garbeam@50
|
112 extern void tag(Arg *arg);
|
garbeam@50
|
113 extern void view(Arg *arg);
|
garbeam@50
|
114 extern void zoom(Arg *arg);
|
garbeam@29
|
115 extern void gravitate(Client *c, Bool invert);
|
garbeam@13
|
116
|
garbeam@33
|
117 /* draw.c */
|
garbeam@34
|
118 extern void draw(Bool border, const char *text);
|
garbeam@43
|
119 extern unsigned long initcolor(const char *colstr);
|
garbeam@43
|
120 extern void initfont(const char *fontstr);
|
garbeam@43
|
121 extern unsigned int textnw(char *text, unsigned int len);
|
garbeam@43
|
122 extern unsigned int textw(char *text);
|
garbeam@43
|
123 extern unsigned int texth(void);
|
garbeam@33
|
124
|
garbeam@13
|
125 /* event.c */
|
garbeam@26
|
126 extern void discard_events(long even_mask);
|
garbeam@5
|
127
|
garbeam@42
|
128 /* dev.c */
|
garbeam@33
|
129 extern void update_keys(void);
|
garbeam@9
|
130 extern void keypress(XEvent *e);
|
garbeam@18
|
131 extern void mresize(Client *c);
|
garbeam@18
|
132 extern void mmove(Client *c);
|
garbeam@18
|
133
|
garbeam@43
|
134 /* main.c */
|
garbeam@43
|
135 extern int error_handler(Display *dsply, XErrorEvent *e);
|
garbeam@43
|
136 extern void send_message(Window w, Atom a, long value);
|
garbeam@43
|
137 extern int win_proto(Window w);
|
garbeam@49
|
138 extern void quit(Arg *arg);
|
garbeam@43
|
139
|
garbeam@32
|
140 /* util.c */
|
garbeam@33
|
141 extern void error(const char *errstr, ...);
|
garbeam@32
|
142 extern void *emallocz(unsigned int size);
|
garbeam@32
|
143 extern void *emalloc(unsigned int size);
|
garbeam@32
|
144 extern void *erealloc(void *ptr, unsigned int size);
|
garbeam@32
|
145 extern char *estrdup(const char *str);
|
garbeam@49
|
146 extern void spawn(Arg *arg);
|
garbeam@32
|
147 extern void swap(void **p1, void **p2);
|