dwm-meillo

annotate dwm.h @ 508:ede48935f2b3

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