dwm-meillo

annotate dwm.h @ 532:651f2c868b31

code polishing, removed unnecessary newlines
author Anselm R. Garbe <arg@10kloc.org>
date Fri, 06 Oct 2006 11:50:15 +0200
parents 451f19d48845
children a5567a0d3011
rev   line source
arg@532 1 /* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
garbeam@0 2 * See LICENSE file for license details.
arg@457 3 *
arg@457 4 * dynamic window manager is designed like any other X client as well. It is
arg@457 5 * driven through handling X events. In contrast to other X clients, a window
arg@468 6 * manager selects for SubstructureRedirectMask on the root window, to receive
arg@468 7 * events about window (dis-)appearance. Only one X connection at a time is
arg@468 8 * allowed to select for this event mask.
arg@457 9 *
arg@468 10 * Calls to fetch an X event from the event queue are blocking. Due reading
arg@469 11 * status text from standard input, a select()-driven main loop has been
arg@468 12 * implemented which selects for reads on the X connection and STDIN_FILENO to
arg@468 13 * handle all data smoothly. The event handlers of dwm are organized in an
arg@468 14 * array which is accessed whenever a new event has been fetched. This allows
arg@468 15 * event dispatching in O(1) time.
arg@457 16 *
arg@460 17 * Each child of the root window is called a client, except windows which have
arg@460 18 * set the override_redirect flag. Clients are organized in a global
arg@460 19 * doubly-linked client list, the focus history is remembered through a global
arg@460 20 * stack list. Each client contains an array of Bools of the same size as the
arg@460 21 * global tags array to indicate the tags of a client. For each client dwm
arg@468 22 * creates a small title window, which is resized whenever the (_NET_)WM_NAME
arg@468 23 * properties are updated or the client is moved/resized.
arg@457 24 *
arg@459 25 * Keys and tagging rules are organized as arrays and defined in the config.h
arg@459 26 * file. These arrays are kept static in event.o and tag.o respectively,
arg@459 27 * because no other part of dwm needs access to them. The current mode is
arg@469 28 * represented by the arrange() function pointer, which wether points to
arg@469 29 * dofloat() or dotile().
arg@457 30 *
arg@468 31 * To understand everything else, start reading main.c:main().
garbeam@0 32 */
garbeam@0 33
arg@166 34 #include "config.h"
garbeam@32 35 #include <X11/Xlib.h>
garbeam@32 36
arg@143 37 /* mask shorthands, used in event.c and client.c */
arg@150 38 #define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
arg@150 39 #define MOUSEMASK (BUTTONMASK | PointerMotionMask)
arg@502 40 /* other stuff used in different places */
arg@502 41 #define BORDERPX 1
arg@157 42 #define PROTODELWIN 1
arg@143 43
arg@452 44 enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */
arg@452 45 enum { WMProtocols, WMDelete, WMLast }; /* default atoms */
arg@452 46 enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
arg@452 47 enum { ColFG, ColBG, ColLast }; /* color */
arg@452 48
arg@452 49 typedef enum {
arg@452 50 TopLeft, TopRight, BotLeft, BotRight
arg@452 51 } Corner; /* window corners */
arg@452 52
arg@333 53 typedef union {
arg@189 54 const char *cmd;
garbeam@49 55 int i;
arg@452 56 } Arg; /* argument type */
arg@99 57
arg@333 58 typedef struct {
garbeam@32 59 int ascent;
garbeam@32 60 int descent;
garbeam@32 61 int height;
garbeam@84 62 XFontSet set;
garbeam@84 63 XFontStruct *xfont;
arg@333 64 } Fnt;
garbeam@32 65
arg@452 66 typedef struct {
garbeam@32 67 int x, y, w, h;
arg@353 68 unsigned long norm[ColLast];
arg@353 69 unsigned long sel[ColLast];
arg@353 70 unsigned long status[ColLast];
garbeam@84 71 Drawable drawable;
garbeam@84 72 Fnt font;
garbeam@84 73 GC gc;
arg@452 74 } DC; /* draw context */
garbeam@32 75
arg@333 76 typedef struct Client Client;
garbeam@0 77 struct Client {
garbeam@31 78 char name[256];
garbeam@13 79 int proto;
arg@115 80 int x, y, w, h;
arg@480 81 int rx, ry, rw, rh; /* revert geometry */
arg@453 82 int tx, ty, tw, th; /* title window geometry */
garbeam@20 83 int basew, baseh, incw, inch, maxw, maxh, minw, minh;
garbeam@29 84 int grav;
arg@164 85 long flags;
arg@381 86 unsigned int border, weight;
arg@480 87 Bool isfloat, ismax;
arg@178 88 Bool *tags;
garbeam@84 89 Client *next;
arg@127 90 Client *prev;
arg@446 91 Client *snext;
garbeam@0 92 Window win;
arg@342 93 Window twin;
garbeam@0 94 };
garbeam@0 95
arg@452 96 extern const char *tags[]; /* all tags */
arg@452 97 extern char stext[1024]; /* status text */
arg@452 98 extern int bx, by, bw, bh, bmw; /* bar geometry, bar mode label width */
arg@524 99 extern int screen, sx, sy, sw, sh; /* screen geometry */
arg@524 100 extern unsigned int master, ntags, numlockmask; /* master percent, number of tags, dynamic lock mask */
arg@452 101 extern void (*handler[LASTEvent])(XEvent *); /* event handler */
arg@452 102 extern void (*arrange)(Arg *); /* arrange function, indicates mode */
garbeam@84 103 extern Atom wmatom[WMLast], netatom[NetLast];
arg@473 104 extern Bool running, issel, *seltag; /* seltag is array of Bool */
arg@488 105 extern Client *clients, *sel, *stack; /* global client list and stack */
garbeam@84 106 extern Cursor cursor[CurLast];
arg@454 107 extern DC dc; /* global draw context */
garbeam@84 108 extern Display *dpy;
garbeam@84 109 extern Window root, barwin;
garbeam@3 110
garbeam@5 111 /* client.c */
arg@454 112 extern void ban(Client *c); /* ban c from screen */
arg@491 113 extern void configure(Client *c); /* send synthetic configure event */
arg@452 114 extern void focus(Client *c); /* focus c, c may be NULL */
arg@452 115 extern Client *getclient(Window w); /* return client of w */
arg@452 116 extern Client *getctitle(Window w); /* return client of title window */
arg@452 117 extern void gravitate(Client *c, Bool invert); /* gravitate c */
arg@452 118 extern void killclient(Arg *arg); /* kill c nicely */
arg@452 119 extern void manage(Window w, XWindowAttributes *wa); /* manage new client */
arg@452 120 extern void resize(Client *c, Bool sizehints, Corner sticky); /* resize c*/
arg@500 121 extern void resizetitle(Client *c); /* resizes c->twin correctly */
arg@454 122 extern void updatesize(Client *c); /* update the size structs of c */
arg@454 123 extern void updatetitle(Client *c); /* update the name of c */
arg@452 124 extern void unmanage(Client *c); /* destroy c */
garbeam@13 125
garbeam@33 126 /* draw.c */
arg@487 127 extern void drawall(void); /* draw all visible client titles and the bar */
arg@487 128 extern void drawstatus(void); /* draw the bar */
arg@452 129 extern void drawtitle(Client *c); /* draw title of c */
arg@452 130 extern unsigned long getcolor(const char *colstr); /* return color of colstr */
arg@452 131 extern void setfont(const char *fontstr); /* set the font for DC */
arg@456 132 extern unsigned int textw(const char *text); /* return the width of text in px*/
garbeam@33 133
garbeam@75 134 /* event.c */
arg@487 135 extern void grabkeys(void); /* grab all keys defined in config.h */
arg@487 136 extern void procevent(void); /* process pending X events */
garbeam@18 137
garbeam@43 138 /* main.c */
arg@452 139 extern int getproto(Window w); /* return protocol mask of WMProtocols property of w */
arg@452 140 extern void quit(Arg *arg); /* quit dwm nicely */
arg@452 141 extern void sendevent(Window w, Atom a, long value); /* send synthetic event to w */
arg@452 142 extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */
garbeam@43 143
garbeam@75 144 /* tag.c */
arg@487 145 extern void initrregs(void); /* initialize regexps of rules defined in config.h */
arg@452 146 extern Client *getnext(Client *c); /* returns next visible client */
arg@452 147 extern Client *getprev(Client *c); /* returns previous visible client */
arg@454 148 extern void settags(Client *c, Client *trans); /* sets tags of c */
arg@456 149 extern void tag(Arg *arg); /* tags c with arg's index */
arg@456 150 extern void toggletag(Arg *arg); /* toggles c tags with arg's index */
garbeam@73 151
garbeam@32 152 /* util.c */
arg@452 153 extern void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */
arg@456 154 extern void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */
arg@452 155 extern void *erealloc(void *ptr, unsigned int size); /* reallocates memory, exits on error */
arg@456 156 extern void spawn(Arg *arg); /* forks a new subprocess with to arg's cmd */
arg@327 157
arg@327 158 /* view.c */
arg@452 159 extern void detach(Client *c); /* detaches c from global client list */
arg@456 160 extern void dofloat(Arg *arg); /* arranges all windows floating, arg is ignored */
arg@456 161 extern void dotile(Arg *arg); /* arranges all windows, arg is ignored */
arg@452 162 extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */
arg@452 163 extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */
arg@452 164 extern Bool isvisible(Client *c); /* returns True if client is visible */
arg@524 165 extern void resizecol(Arg *arg); /* resizes the master percent with arg's index value */
arg@487 166 extern void restack(void); /* restores z layers of all clients */
arg@456 167 extern void togglemode(Arg *arg); /* toggles global arrange function (dotile/dofloat) */
arg@456 168 extern void toggleview(Arg *arg); /* toggles the tag with arg's index (in)visible */
arg@456 169 extern void view(Arg *arg); /* views the tag with arg's index */
arg@454 170 extern void viewall(Arg *arg); /* views all tags, arg is ignored */
arg@508 171 extern void zoom(Arg *arg); /* zooms the focused client to master area, arg is ignored */