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