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@32
|
22 typedef struct Brush Brush;
|
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@32
|
42 struct Brush {
|
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@31
|
82 extern void (*arrange)(void *aux);
|
garbeam@0
|
83
|
garbeam@32
|
84 extern int tsel, screen, sx, sy, sw, sh, th;
|
garbeam@31
|
85 extern char stext[1024], *tags[TLast];
|
garbeam@3
|
86
|
garbeam@3
|
87 extern Brush brush;
|
garbeam@13
|
88 extern Client *clients, *stack;
|
garbeam@3
|
89
|
garbeam@32
|
90 /* draw.c */
|
garbeam@32
|
91 extern void draw(Display *dpy, Brush *b, Bool border, const char *text);
|
garbeam@32
|
92 extern void loadcolors(Display *dpy, int screen, Brush *b,
|
garbeam@32
|
93 const char *bg, const char *fg, const char *bo);
|
garbeam@32
|
94 extern void loadfont(Display *dpy, Fnt *font, const char *fontstr);
|
garbeam@32
|
95 extern unsigned int textnw(Fnt *font, char *text, unsigned int len);
|
garbeam@32
|
96 extern unsigned int textw(Fnt *font, char *text);
|
garbeam@32
|
97 extern unsigned int texth(Fnt *font);
|
garbeam@5
|
98
|
garbeam@5
|
99 /* client.c */
|
garbeam@10
|
100 extern void manage(Window w, XWindowAttributes *wa);
|
garbeam@13
|
101 extern void unmanage(Client *c);
|
garbeam@13
|
102 extern Client *getclient(Window w);
|
garbeam@13
|
103 extern void focus(Client *c);
|
garbeam@13
|
104 extern void update_name(Client *c);
|
garbeam@16
|
105 extern void draw_client(Client *c);
|
garbeam@18
|
106 extern void resize(Client *c);
|
garbeam@20
|
107 extern void update_size(Client *c);
|
garbeam@23
|
108 extern Client *gettitle(Window w);
|
garbeam@32
|
109 extern void craise(Client *c);
|
garbeam@26
|
110 extern void lower(Client *c);
|
garbeam@32
|
111 extern void ckill(void *aux);
|
garbeam@27
|
112 extern void sel(void *aux);
|
garbeam@28
|
113 extern void max(void *aux);
|
garbeam@31
|
114 extern void floating(void *aux);
|
garbeam@31
|
115 extern void grid(void *aux);
|
garbeam@29
|
116 extern void gravitate(Client *c, Bool invert);
|
garbeam@13
|
117
|
garbeam@13
|
118 /* event.c */
|
garbeam@26
|
119 extern void discard_events(long even_mask);
|
garbeam@5
|
120
|
garbeam@8
|
121 /* key.c */
|
garbeam@8
|
122 extern void update_keys();
|
garbeam@9
|
123 extern void keypress(XEvent *e);
|
garbeam@8
|
124
|
garbeam@18
|
125 /* mouse.c */
|
garbeam@18
|
126 extern void mresize(Client *c);
|
garbeam@18
|
127 extern void mmove(Client *c);
|
garbeam@18
|
128
|
garbeam@32
|
129 /* util.c */
|
garbeam@32
|
130 extern void error(char *errstr, ...);
|
garbeam@32
|
131 extern void *emallocz(unsigned int size);
|
garbeam@32
|
132 extern void *emalloc(unsigned int size);
|
garbeam@32
|
133 extern void *erealloc(void *ptr, unsigned int size);
|
garbeam@32
|
134 extern char *estrdup(const char *str);
|
garbeam@32
|
135 extern void spawn(Display *dpy, char *argv[]);
|
garbeam@32
|
136 extern void swap(void **p1, void **p2);
|
garbeam@32
|
137
|
garbeam@0
|
138 /* wm.c */
|
garbeam@10
|
139 extern int error_handler(Display *dpy, XErrorEvent *error);
|
garbeam@13
|
140 extern void send_message(Window w, Atom a, long value);
|
garbeam@13
|
141 extern int win_proto(Window w);
|
garbeam@27
|
142 extern void run(void *aux);
|
garbeam@27
|
143 extern void quit(void *aux);
|