annotate dwm.h @ 0:7024076fa948

initial add
author paulo@localhost
date Sun, 22 Mar 2009 23:26:35 -0700
parents
children ba504f41828f
rev   line source
paulo@0 1 /* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
paulo@0 2 * See LICENSE file for license details.
paulo@0 3 *
paulo@0 4 * dynamic window manager is designed like any other X client as well. It is
paulo@0 5 * driven through handling X events. In contrast to other X clients, a window
paulo@0 6 * manager selects for SubstructureRedirectMask on the root window, to receive
paulo@0 7 * events about window (dis-)appearance. Only one X connection at a time is
paulo@0 8 * allowed to select for this event mask.
paulo@0 9 *
paulo@0 10 * Calls to fetch an X event from the event queue are blocking. Due reading
paulo@0 11 * status text from standard input, a select()-driven main loop has been
paulo@0 12 * implemented which selects for reads on the X connection and STDIN_FILENO to
paulo@0 13 * handle all data smoothly. The event handlers of dwm are organized in an
paulo@0 14 * array which is accessed whenever a new event has been fetched. This allows
paulo@0 15 * event dispatching in O(1) time.
paulo@0 16 *
paulo@0 17 * Each child of the root window is called a client, except windows which have
paulo@0 18 * set the override_redirect flag. Clients are organized in a global
paulo@0 19 * doubly-linked client list, the focus history is remembered through a global
paulo@0 20 * stack list. Each client contains an array of Bools of the same size as the
paulo@0 21 * global tags array to indicate the tags of a client. For each client dwm
paulo@0 22 * creates a small title window, which is resized whenever the (_NET_)WM_NAME
paulo@0 23 * properties are updated or the client is moved/resized.
paulo@0 24 *
paulo@0 25 * Keys and tagging rules are organized as arrays and defined in the config.h
paulo@0 26 * file. These arrays are kept static in event.o and tag.o respectively,
paulo@0 27 * because no other part of dwm needs access to them. The current layout is
paulo@0 28 * represented by the lt pointer.
paulo@0 29 *
paulo@0 30 * To understand everything else, start reading main.c:main().
paulo@0 31 */
paulo@0 32
paulo@0 33 #include "config.h"
paulo@0 34 #include <X11/Xlib.h>
paulo@0 35
paulo@0 36 /* mask shorthands, used in event.c and client.c */
paulo@0 37 #define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
paulo@0 38
paulo@0 39 enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */
paulo@0 40 enum { WMProtocols, WMDelete, WMState, WMLast }; /* default atoms */
paulo@0 41 enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
paulo@0 42 enum { ColBorder, ColFG, ColBG, ColLast }; /* color */
paulo@0 43
paulo@0 44 typedef union {
paulo@0 45 const char *cmd;
paulo@0 46 int i;
paulo@0 47 } Arg; /* argument type */
paulo@0 48
paulo@0 49 typedef struct {
paulo@0 50 int ascent;
paulo@0 51 int descent;
paulo@0 52 int height;
paulo@0 53 XFontSet set;
paulo@0 54 XFontStruct *xfont;
paulo@0 55 } Fnt;
paulo@0 56
paulo@0 57 typedef struct {
paulo@0 58 int x, y, w, h;
paulo@0 59 unsigned long norm[ColLast];
paulo@0 60 unsigned long sel[ColLast];
paulo@0 61 Drawable drawable;
paulo@0 62 Fnt font;
paulo@0 63 GC gc;
paulo@0 64 } DC; /* draw context */
paulo@0 65
paulo@0 66 typedef struct Client Client;
paulo@0 67 struct Client {
paulo@0 68 char name[256];
paulo@0 69 int x, y, w, h;
paulo@0 70 int rx, ry, rw, rh; /* revert geometry */
paulo@0 71 int basew, baseh, incw, inch, maxw, maxh, minw, minh;
paulo@0 72 int minax, minay, maxax, maxay;
paulo@0 73 long flags;
paulo@0 74 unsigned int border;
paulo@0 75 Bool isbanned, isfixed, ismax, isversatile;
paulo@0 76 Bool *tags;
paulo@0 77 Client *next;
paulo@0 78 Client *prev;
paulo@0 79 Client *snext;
paulo@0 80 Window win;
paulo@0 81 };
paulo@0 82
paulo@0 83 typedef struct {
paulo@0 84 const char *symbol;
paulo@0 85 void (*arrange)(void);
paulo@0 86 } Layout;
paulo@0 87
paulo@0 88 extern const char *tags[]; /* all tags */
paulo@0 89 extern char stext[256]; /* status text */
paulo@0 90 extern int screen, sx, sy, sw, sh; /* screen geometry */
paulo@0 91 extern int wax, way, wah, waw; /* windowarea geometry */
paulo@0 92 extern unsigned int bh, blw; /* bar height, bar layout label width */
paulo@0 93 extern unsigned int master, nmaster; /* master percent, number of master clients */
paulo@0 94 extern unsigned int ntags, numlockmask; /* number of tags, dynamic lock mask */
paulo@0 95 extern void (*handler[LASTEvent])(XEvent *); /* event handler */
paulo@0 96 extern Atom wmatom[WMLast], netatom[NetLast];
paulo@0 97 extern Bool selscreen, *seltag; /* seltag is array of Bool */
paulo@0 98 extern Client *clients, *sel, *stack; /* global client list and stack */
paulo@0 99 extern Cursor cursor[CurLast];
paulo@0 100 extern DC dc; /* global draw context */
paulo@0 101 extern Display *dpy;
paulo@0 102 extern Layout *lt;
paulo@0 103 extern Window root, barwin;
paulo@0 104
paulo@0 105 /* client.c */
paulo@0 106 extern void configure(Client *c); /* send synthetic configure event */
paulo@0 107 extern void focus(Client *c); /* focus c, c may be NULL */
paulo@0 108 extern void killclient(Arg *arg); /* kill c nicely */
paulo@0 109 extern void manage(Window w, XWindowAttributes *wa); /* manage new client */
paulo@0 110 extern void resize(Client *c, int x, int y,
paulo@0 111 int w, int h, Bool sizehints); /* resize with given coordinates c*/
paulo@0 112 extern void toggleversatile(Arg *arg); /* toggles focused client between versatile/and non-versatile state */
paulo@0 113 extern void updatesizehints(Client *c); /* update the size hint variables of c */
paulo@0 114 extern void updatetitle(Client *c); /* update the name of c */
paulo@0 115 extern void unmanage(Client *c); /* destroy c */
paulo@0 116 extern void zoom(Arg *arg); /* zooms the focused client to master area, arg is ignored */
paulo@0 117 extern void pushup(Arg *arg);
paulo@0 118 extern void pushdown(Arg *arg);
paulo@0 119 extern void moveresize(Arg *arg);
paulo@0 120
paulo@0 121 /* draw.c */
paulo@0 122 extern void drawstatus(void); /* draw the bar */
paulo@0 123 extern void drawtext(const char *text,
paulo@0 124 unsigned long col[ColLast]); /* draw text */
paulo@0 125 extern unsigned int textw(const char *text); /* return the width of text in px*/
paulo@0 126
paulo@0 127 /* event.c */
paulo@0 128 extern void grabkeys(void); /* grab all keys defined in config.h */
paulo@0 129
paulo@0 130 /* layout.c */
paulo@0 131 extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */
paulo@0 132 extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */
paulo@0 133 extern void incnmaster(Arg *arg); /* increments nmaster with arg's index value */
paulo@0 134 extern void initlayouts(void); /* initialize layout array */
paulo@0 135 extern Client *nexttiled(Client *c); /* returns tiled successor of c */
paulo@0 136 extern void resizemaster(Arg *arg); /* resizes the master percent with arg's index value */
paulo@0 137 extern void restack(void); /* restores z layers of all clients */
paulo@0 138 extern void setlayout(Arg *arg); /* sets layout, -1 toggles */
paulo@0 139 extern void versatile(void); /* arranges all windows versatile */
paulo@0 140
paulo@0 141 /* main.c */
paulo@0 142 extern void quit(Arg *arg); /* quit dwm nicely */
paulo@0 143 extern void sendevent(Window w, Atom a, long value); /* send synthetic event to w */
paulo@0 144 extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */
paulo@0 145
paulo@0 146 /* tag.c */
paulo@0 147 extern void compileregs(void); /* initialize regexps of rules defined in config.h */
paulo@0 148 extern Bool isvisible(Client *c); /* returns True if client is visible */
paulo@0 149 extern void settags(Client *c, Client *trans); /* sets tags of c */
paulo@0 150 extern void tag(Arg *arg); /* tags c with arg's index */
paulo@0 151 extern void toggletag(Arg *arg); /* toggles c tags with arg's index */
paulo@0 152 extern void toggleview(Arg *arg); /* toggles the tag with arg's index (in)visible */
paulo@0 153 extern void view(Arg *arg); /* views the tag with arg's index */
paulo@0 154 extern void last_view(Arg *arg); /* go to last viewed tag */
paulo@0 155
paulo@0 156 /* util.c */
paulo@0 157 extern void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */
paulo@0 158 extern void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */
paulo@0 159 extern void spawn(Arg *arg); /* forks a new subprocess with arg's cmd */
paulo@0 160