JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
small change to comments, renamed two set* functions in client.c into update*
[dwm.git] / dwm.h
1 /*
2  * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3  * See LICENSE file for license details.
4  */
5
6 #include "config.h"
7 #include <X11/Xlib.h>
8
9 /* mask shorthands, used in event.c and client.c */
10 #define BUTTONMASK              (ButtonPressMask | ButtonReleaseMask)
11 #define MOUSEMASK               (BUTTONMASK | PointerMotionMask)
12 #define PROTODELWIN             1
13
14 enum { NetSupported, NetWMName, NetLast };              /* EWMH atoms */
15 enum { WMProtocols, WMDelete, WMLast };                 /* default atoms */
16 enum { CurNormal, CurResize, CurMove, CurLast };        /* cursor */
17 enum { ColFG, ColBG, ColLast };                         /* color */
18
19 typedef enum {
20         TopLeft, TopRight, BotLeft, BotRight
21 } Corner; /* window corners */
22
23 typedef union {
24         const char *cmd;
25         int i;
26 } Arg; /* argument type */
27
28 typedef struct {
29         int ascent;
30         int descent;
31         int height;
32         XFontSet set;
33         XFontStruct *xfont;
34 } Fnt;
35
36 typedef struct {
37         int x, y, w, h;
38         unsigned long norm[ColLast];
39         unsigned long sel[ColLast];
40         unsigned long status[ColLast];
41         Drawable drawable;
42         Fnt font;
43         GC gc;
44 } DC; /* draw context */
45
46 typedef struct Client Client;
47 struct Client {
48         char name[256];
49         int proto;
50         int x, y, w, h;
51         int tx, ty, tw, th; /* title window geometry */
52         int basew, baseh, incw, inch, maxw, maxh, minw, minh;
53         int grav;
54         long flags; 
55         unsigned int border, weight;
56         Bool isfloat;
57         Bool *tags;
58         Client *next;
59         Client *prev;
60         Client *snext;
61         Window win;
62         Window twin;
63 };
64
65 extern const char *tags[];                      /* all tags */
66 extern char stext[1024];                        /* status text */
67 extern int bx, by, bw, bh, bmw;                 /* bar geometry, bar mode label width */
68 extern int mw, screen, sx, sy, sw, sh;          /* screen geometry, master width */
69 extern unsigned int ntags, numlockmask;         /* number of tags, dynamic lock mask */
70 extern void (*handler[LASTEvent])(XEvent *);    /* event handler */
71 extern void (*arrange)(Arg *);                  /* arrange function, indicates mode  */
72 extern Atom wmatom[WMLast], netatom[NetLast];
73 extern Bool running, issel, maximized, *seltag; /* seltag is array of Bool */
74 extern Client *clients, *sel, *stack;           /* global cleint list and stack */
75 extern Cursor cursor[CurLast];
76 extern DC dc;                                   /* global draw context */
77 extern Display *dpy;
78 extern Window root, barwin;
79
80 /* client.c */
81 extern void ban(Client *c);                     /* ban c from screen */
82 extern void focus(Client *c);                   /* focus c, c may be NULL */
83 extern Client *getclient(Window w);             /* return client of w */
84 extern Client *getctitle(Window w);             /* return client of title window */
85 extern void gravitate(Client *c, Bool invert);  /* gravitate c */
86 extern void killclient(Arg *arg);               /* kill c nicely */
87 extern void manage(Window w, XWindowAttributes *wa);    /* manage new client */
88 extern void resize(Client *c, Bool sizehints, Corner sticky); /* resize c*/
89 extern void updatesize(Client *c);                      /* update the size structs of c */
90 extern void updatetitle(Client *c);             /* update the name of c */
91 extern void togglemax(Arg *arg);                /* (un)maximize c */
92 extern void unmanage(Client *c);                /* destroy c */
93
94 /* draw.c */
95 extern void drawall();                          /* draw all visible client titles and the bar */
96 extern void drawstatus();                       /* draw the bar */
97 extern void drawtitle(Client *c);               /* draw title of c */
98 extern unsigned long getcolor(const char *colstr);      /* return color of colstr */
99 extern void setfont(const char *fontstr);       /* set the font for DC */
100 extern unsigned int textw(const char *text);    /* return the text width of text */
101
102 /* event.c */
103 extern void grabkeys();                         /* grab all keys defined in config.h */
104 extern void procevent();                        /* process pending X events */
105
106 /* main.c */
107 extern int getproto(Window w);                  /* return protocol mask of WMProtocols property of w */
108 extern void quit(Arg *arg);                     /* quit dwm nicely */
109 extern void sendevent(Window w, Atom a, long value);    /* send synthetic event to w */
110 extern int xerror(Display *dsply, XErrorEvent *ee);     /* dwm's X error handler */
111
112 /* tag.c */
113 extern void initrregs();                        /* initialize regexps of rules defined in config.h */
114 extern Client *getnext(Client *c);              /* returns next visible client */
115 extern Client *getprev(Client *c);              /* returns previous visible client */
116 extern void settags(Client *c, Client *trans);  /* sets tags of c */
117 extern void tag(Arg *arg);                      /* tags c accordingly to arg's index */
118 extern void toggletag(Arg *arg);                /* toggles c tags accordingly to arg's index */
119
120 /* util.c */
121 extern void *emallocz(unsigned int size);       /* allocates zero-initialized memory, exits on error */
122 extern void eprint(const char *errstr, ...);    /* prints error string and exits with return code 1 */
123 extern void *erealloc(void *ptr, unsigned int size);    /* reallocates memory, exits on error */
124 extern void spawn(Arg *arg);                    /* forks a new subprocess accordingly to arg's cmd */
125
126 /* view.c */
127 extern void detach(Client *c);                  /* detaches c from global client list */
128 extern void dofloat(Arg *arg);                  /* arranges all windows in a floating way, arg is ignored */
129 extern void dotile(Arg *arg);                   /* arranges all windows in a tiled way, arg is ignored */
130 extern void focusnext(Arg *arg);                /* focuses next visible client, arg is ignored  */
131 extern void focusprev(Arg *arg);                /* focuses previous visible client, arg is ignored */
132 extern Bool isvisible(Client *c);               /* returns True if client is visible */
133 extern void resizecol(Arg *arg);                /* resizes the master width accordingly to arg's index value */
134 extern void restack();                          /* restores z layers of all clients */
135 extern void togglemode(Arg *arg);               /* toggles global arrange function (between dotile and dofloat) */
136 extern void toggleview(Arg *arg);               /* toggles the tag accordingly to arg's index (in)visible */
137 extern void view(Arg *arg);                     /* views the tag accordingly to arg's index */
138 extern void viewall(Arg *arg);                  /* views all tags, arg is ignored */
139 extern void zoom(Arg *arg);                     /* zooms the focused client to master column, arg is ignored */