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