diff dwm.h @ 0:7024076fa948

initial add
author paulo@localhost
date Sun, 22 Mar 2009 23:26:35 -0700
parents
children ba504f41828f
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dwm.h	Sun Mar 22 23:26:35 2009 -0700
     1.3 @@ -0,0 +1,160 @@
     1.4 +/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
     1.5 + * See LICENSE file for license details.
     1.6 + *
     1.7 + * dynamic window manager is designed like any other X client as well. It is
     1.8 + * driven through handling X events. In contrast to other X clients, a window
     1.9 + * manager selects for SubstructureRedirectMask on the root window, to receive
    1.10 + * events about window (dis-)appearance.  Only one X connection at a time is
    1.11 + * allowed to select for this event mask.
    1.12 + *
    1.13 + * Calls to fetch an X event from the event queue are blocking.  Due reading
    1.14 + * status text from standard input, a select()-driven main loop has been
    1.15 + * implemented which selects for reads on the X connection and STDIN_FILENO to
    1.16 + * handle all data smoothly. The event handlers of dwm are organized in an
    1.17 + * array which is accessed whenever a new event has been fetched. This allows
    1.18 + * event dispatching in O(1) time.
    1.19 + *
    1.20 + * Each child of the root window is called a client, except windows which have
    1.21 + * set the override_redirect flag.  Clients are organized in a global
    1.22 + * doubly-linked client list, the focus history is remembered through a global
    1.23 + * stack list. Each client contains an array of Bools of the same size as the
    1.24 + * global tags array to indicate the tags of a client.  For each client dwm
    1.25 + * creates a small title window, which is resized whenever the (_NET_)WM_NAME
    1.26 + * properties are updated or the client is moved/resized.
    1.27 + *
    1.28 + * Keys and tagging rules are organized as arrays and defined in the config.h
    1.29 + * file. These arrays are kept static in event.o and tag.o respectively,
    1.30 + * because no other part of dwm needs access to them.  The current layout is
    1.31 + * represented by the lt pointer.
    1.32 + *
    1.33 + * To understand everything else, start reading main.c:main().
    1.34 + */
    1.35 +
    1.36 +#include "config.h"
    1.37 +#include <X11/Xlib.h>
    1.38 +
    1.39 +/* mask shorthands, used in event.c and client.c */
    1.40 +#define BUTTONMASK		(ButtonPressMask | ButtonReleaseMask)
    1.41 +
    1.42 +enum { NetSupported, NetWMName, NetLast };		/* EWMH atoms */
    1.43 +enum { WMProtocols, WMDelete, WMState, WMLast };	/* default atoms */
    1.44 +enum { CurNormal, CurResize, CurMove, CurLast };	/* cursor */
    1.45 +enum { ColBorder, ColFG, ColBG, ColLast };		/* color */
    1.46 +
    1.47 +typedef union {
    1.48 +	const char *cmd;
    1.49 +	int i;
    1.50 +} Arg; /* argument type */
    1.51 +
    1.52 +typedef struct {
    1.53 +	int ascent;
    1.54 +	int descent;
    1.55 +	int height;
    1.56 +	XFontSet set;
    1.57 +	XFontStruct *xfont;
    1.58 +} Fnt;
    1.59 +
    1.60 +typedef struct {
    1.61 +	int x, y, w, h;
    1.62 +	unsigned long norm[ColLast];
    1.63 +	unsigned long sel[ColLast];
    1.64 +	Drawable drawable;
    1.65 +	Fnt font;
    1.66 +	GC gc;
    1.67 +} DC; /* draw context */
    1.68 +
    1.69 +typedef struct Client Client;
    1.70 +struct Client {
    1.71 +	char name[256];
    1.72 +	int x, y, w, h;
    1.73 +	int rx, ry, rw, rh; /* revert geometry */
    1.74 +	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
    1.75 +	int minax, minay, maxax, maxay;
    1.76 +	long flags; 
    1.77 +	unsigned int border;
    1.78 +	Bool isbanned, isfixed, ismax, isversatile;
    1.79 +	Bool *tags;
    1.80 +	Client *next;
    1.81 +	Client *prev;
    1.82 +	Client *snext;
    1.83 +	Window win;
    1.84 +};
    1.85 +
    1.86 +typedef struct {
    1.87 +	const char *symbol;
    1.88 +	void (*arrange)(void);
    1.89 +} Layout;
    1.90 +
    1.91 +extern const char *tags[];			/* all tags */
    1.92 +extern char stext[256];				/* status text */
    1.93 +extern int screen, sx, sy, sw, sh;		/* screen geometry */
    1.94 +extern int wax, way, wah, waw;			/* windowarea geometry */
    1.95 +extern unsigned int bh, blw;			/* bar height, bar layout label width */
    1.96 +extern unsigned int master, nmaster;		/* master percent, number of master clients */
    1.97 +extern unsigned int ntags, numlockmask;		/* number of tags, dynamic lock mask */
    1.98 +extern void (*handler[LASTEvent])(XEvent *);	/* event handler */
    1.99 +extern Atom wmatom[WMLast], netatom[NetLast];
   1.100 +extern Bool selscreen, *seltag;			/* seltag is array of Bool */
   1.101 +extern Client *clients, *sel, *stack;		/* global client list and stack */
   1.102 +extern Cursor cursor[CurLast];
   1.103 +extern DC dc;					/* global draw context */
   1.104 +extern Display *dpy;
   1.105 +extern Layout *lt;
   1.106 +extern Window root, barwin;
   1.107 +
   1.108 +/* client.c */
   1.109 +extern void configure(Client *c);		/* send synthetic configure event */
   1.110 +extern void focus(Client *c);			/* focus c, c may be NULL */
   1.111 +extern void killclient(Arg *arg);		/* kill c nicely */
   1.112 +extern void manage(Window w, XWindowAttributes *wa);	/* manage new client */
   1.113 +extern void resize(Client *c, int x, int y,
   1.114 +		int w, int h, Bool sizehints);	/* resize with given coordinates c*/
   1.115 +extern void toggleversatile(Arg *arg);		/* toggles focused client between versatile/and non-versatile state */
   1.116 +extern void updatesizehints(Client *c);		/* update the size hint variables of c */
   1.117 +extern void updatetitle(Client *c);		/* update the name of c */
   1.118 +extern void unmanage(Client *c);		/* destroy c */
   1.119 +extern void zoom(Arg *arg);			/* zooms the focused client to master area, arg is ignored */
   1.120 +extern void pushup(Arg *arg);
   1.121 +extern void pushdown(Arg *arg);
   1.122 +extern void moveresize(Arg *arg);
   1.123 +
   1.124 +/* draw.c */
   1.125 +extern void drawstatus(void);			/* draw the bar */
   1.126 +extern void drawtext(const char *text,
   1.127 +		unsigned long col[ColLast]);	/* draw text */
   1.128 +extern unsigned int textw(const char *text);	/* return the width of text in px*/
   1.129 +
   1.130 +/* event.c */
   1.131 +extern void grabkeys(void);			/* grab all keys defined in config.h */
   1.132 +
   1.133 +/* layout.c */
   1.134 +extern void focusnext(Arg *arg);		/* focuses next visible client, arg is ignored  */
   1.135 +extern void focusprev(Arg *arg);		/* focuses previous visible client, arg is ignored */
   1.136 +extern void incnmaster(Arg *arg);		/* increments nmaster with arg's index value */
   1.137 +extern void initlayouts(void);			/* initialize layout array */
   1.138 +extern Client *nexttiled(Client *c);		/* returns tiled successor of c */
   1.139 +extern void resizemaster(Arg *arg);		/* resizes the master percent with arg's index value */
   1.140 +extern void restack(void);			/* restores z layers of all clients */
   1.141 +extern void setlayout(Arg *arg);		/* sets layout, -1 toggles */
   1.142 +extern void versatile(void);			/* arranges all windows versatile */
   1.143 +
   1.144 +/* main.c */
   1.145 +extern void quit(Arg *arg);			/* quit dwm nicely */
   1.146 +extern void sendevent(Window w, Atom a, long value);	/* send synthetic event to w */
   1.147 +extern int xerror(Display *dsply, XErrorEvent *ee);	/* dwm's X error handler */
   1.148 +
   1.149 +/* tag.c */
   1.150 +extern void compileregs(void);			/* initialize regexps of rules defined in config.h */
   1.151 +extern Bool isvisible(Client *c);		/* returns True if client is visible */
   1.152 +extern void settags(Client *c, Client *trans);	/* sets tags of c */
   1.153 +extern void tag(Arg *arg);			/* tags c with arg's index */
   1.154 +extern void toggletag(Arg *arg);		/* toggles c tags with arg's index */
   1.155 +extern void toggleview(Arg *arg);		/* toggles the tag with arg's index (in)visible */
   1.156 +extern void view(Arg *arg);			/* views the tag with arg's index */
   1.157 +extern void last_view(Arg *arg);			/* go to last viewed tag */
   1.158 +
   1.159 +/* util.c */
   1.160 +extern void *emallocz(unsigned int size);	/* allocates zero-initialized memory, exits on error */
   1.161 +extern void eprint(const char *errstr, ...);	/* prints errstr and exits with 1 */
   1.162 +extern void spawn(Arg *arg);			/* forks a new subprocess with arg's cmd */
   1.163 +